/* Custom CSS for the "What can I design for you?" form section
   This CSS improves the desktop experience by creating a more ergonomic width and layout
*/

/* Main card container - optimal width for desktop */
.lqd-creator-card {
  max-width: 1200px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 0 !important; /* No padding on mobile - full width */
}

.myup-create-hero {
  position: relative;
  width: calc(100% + 2rem) !important;
  max-width: none !important;
  margin-left: -1rem !important;
  margin-right: -1rem !important;
  margin-top: calc(var(--header-height) * -1) !important;
  overflow: hidden;
  isolation: isolate;
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
  background-color: #0f1115 !important;
  background-image:
    linear-gradient(180deg, rgba(8, 10, 14, 0.3) 0%, rgba(8, 10, 14, 0.56) 100%),
    var(--myup-create-hero-image) !important;
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
}

.myup-create-hero::before {
  content: none;
}

.myup-create-hero > .lqd-card-body {
  position: relative;
  z-index: 1;
  padding: 0 !important;
}

.myup-create-hero__inner {
  position: relative;
  z-index: 1;
  padding-top: calc(var(--header-height) + 1.5rem) !important;
}

@media (max-width: 1023px) {
  .myup-create-hero {
    margin-top: -65px !important;
  }

  .myup-create-hero__inner {
    padding-top: calc(65px + 1.5rem) !important;
  }
}

@media (min-width: 768px) {
  .myup-create-hero__inner {
    padding-top: calc(var(--header-height) + 2rem) !important;
  }
}

/* Mobile specific adjustments - formulaire avec bordures arrondies préservées */
@media (max-width: 767px) {
  .lqd-creator-card {
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0.75rem !important;
  }

  .myup-create-hero {
    width: calc(100% + 2rem) !important;
    max-width: none !important;
    margin-left: -1rem !important;
    margin-right: -1rem !important;
  }
  
  /* Formulaire principal avec bordures arrondies - Plus prononcées comme sur desktop */
  .lqd-myup-creator .form-area > div.relative {
    border-radius: 1.25rem !important; /* Plus arrondi, proche du desktop */
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* Container parent sans padding */
  .lqd-page-content-wrapper {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  .lqd-myup-creator .grid {
    gap: 1rem !important;
  }
  
  /* Reduce form elements size on mobile */
  .lqd-myup-creator .form-area,
  .lqd-myup-creator .preview-area {
    padding: 0 !important;
    margin-bottom: 1rem !important;
  }
  
  /* Make buttons smaller on mobile */
  .lqd-myup-creator .action-buttons-row {
    padding: 0.25rem 0.5rem !important;
  }
  
  /* Optimized border radius for mobile - cibler spécifiquement le conteneur principal */
  .lqd-myup-creator .form-area > div.relative {
    padding: 1rem !important;
    border-radius: 1.25rem !important; /* Bordures bien arrondies comme sur desktop */
  }
  
  /* Smaller font size for mobile */
  .lqd-myup-creator #prompt {
    font-size: 14px !important;
  }
  
  /* Mobile textarea specific styles */
  .mobile-textarea {
    font-size: 14px !important;
    line-height: 1.4 !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    min-height: 40px !important;
  }
  
  /* Reduce card title size on mobile */
  .lqd-creator-card .text-2xl.md\:text-3xl {
    font-size: 1.25rem !important;
  }

  .myup-create-hero {
    background-position: center top !important;
  }
  
  /* Ensure proper spacing between elements on mobile */
  .lqd-myup-creator > div:not(:last-child) {
    margin-bottom: 0.75rem !important;
  }
}

/* Small phone optimizations */
@media (max-width: 479px) {
  .lqd-creator-card {
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0.5rem !important;
  }

  .myup-create-hero {
    width: calc(100% + 2rem) !important;
    max-width: none !important;
    margin-left: -1rem !important;
    margin-right: -1rem !important;
  }
  
  /* Assurer que même les très petits écrans gardent les bordures arrondies */
  .lqd-myup-creator .form-area {
    padding: 0 !important;
    margin: 0 !important;  
  }
  
  .lqd-myup-creator .form-area > div.relative {
    border-radius: 1rem !important; /* Bordures bien arrondies même sur très petits écrans */
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
  }
  
  .lqd-myup-creator .action-buttons-row {
    padding: 0.2rem 0.4rem !important;
    gap: 0.25rem !important;
  }
  
  .lqd-myup-creator .action-buttons-row button {
    padding: 0.25rem !important;
  }
  
  .mobile-textarea {
    font-size: 13px !important;
    min-height: 36px !important;
  }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
  .lqd-creator-card {
    padding: 0 1rem !important;
  }
  
  .lqd-myup-creator .grid {
    gap: 1.5rem !important;
  }
  
  .lqd-myup-creator .form-area,
  .lqd-myup-creator .preview-area {
    padding: 0 0.5rem !important;
  }
  
  /* Bordures arrondies moyennes pour tablettes */
  .lqd-myup-creator .form-area > div.relative {
    border-radius: 1.375rem !important; /* Progression fluide vers le desktop */
  }
}

/* Center the preview and form on all screens */
.lqd-myup-creator .preview-area,
.lqd-myup-creator .form-area {
  width: 100% !important;
  max-width: 800px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Enhanced preview area styling */
.lqd-myup-creator .preview-area {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  margin-bottom: 2rem !important;
}

/* Adjust spacing when preview is not visible - form should be centered vertically */
.lqd-myup-creator .form-area:only-child {
  margin-top: 2rem !important;  
}

/* Desktop specific adjustments */
@media (min-width: 1024px) {
  .lqd-creator-card {
    padding: 0 1.5rem !important;
  }
  
  /* Form area - optimal line length for readability */
  .lqd-myup-creator .form-area {
    max-width: 800px !important;
    width: 100% !important;
    padding: 0 1rem !important;
  }
  
  /* Preview area - centered and balanced size */
  .lqd-myup-creator .preview-area {
    max-width: 800px !important;
    min-height: 300px !important;
    padding: 0 1rem !important;
  }
  
  /* Form centered when alone */
  .lqd-myup-creator .form-area:only-child {
    margin-top: 3rem !important;
  }
  
  /* Textarea optimal width */
  .lqd-myup-creator #prompt {
    max-width: 100% !important;
    width: 100% !important;
    font-size: 16px !important;
    line-height: 1.5 !important;
  }
  
  /* Action buttons row - better positioning */
  .lqd-myup-creator .action-buttons-row {
    max-width: 100% !important;
    margin: 0 auto !important;
  }
  
  /* Préserver le design desktop avec grandes bordures arrondies */
  .lqd-myup-creator .form-area > div.relative {
    border-radius: 1.5rem !important; /* Équivalent de rounded-3xl pour desktop */
  }
}

/* Improve the form padding - cibler spécifiquement le conteneur principal */
.lqd-myup-creator .form-area > div.relative {
  padding: 1.5rem !important;
}

/* Add a subtle hover effect */
.lqd-myup-creator .form-area > div.relative:hover {
  transform: translateY(-5px) !important;
  transition: transform 0.3s ease-in-out !important;
}

/* Better text readability */
.lqd-myup-creator #prompt::placeholder {
  color: rgba(107, 114, 128, 0.7) !important;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .lqd-myup-creator #prompt::placeholder {
    color: rgba(156, 163, 175, 0.7) !important;
  }
} 

/* ===== STYLES DÉPLACÉS DEPUIS CREATOR.BLADE.PHP ===== */

/* Alpine.js initialisation styling */
[x-cloak] {
    display: none !important;
}

/* Empêcher le zoom automatique sur mobile */
@media screen and (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
        -webkit-user-select: text;
        -webkit-touch-callout: default;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Styles spécifiques pour le textarea principal */
    #prompt {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
        zoom: 1;
        -webkit-transform: scale(1);
        transform: scale(1);
    }
}

.ultra-thin-border {
    border: 1px solid rgba(209, 213, 219, 0.15); /* Extremely subtle light gray border for light mode */
}

.dark .ultra-thin-border {
    border: 1px solid rgba(75, 85, 99, 0.15); /* Extremely subtle darker border for dark mode */
}

/* Styles communs pour les éléments d'interface */

/* Apple-style send button styling */
#generate-button {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    transform-origin: center;
    padding: 0;
}

#generate-button:not([disabled]):hover {
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

#generate-button:active:not([disabled]) {
    transform: scale(0.95);
    transition: all 0.1s ease;
}

/* Effet de flou et d'ombre */
.blur-firm-shadow {
    box-shadow: 0 20px 30px -12px rgba(0, 0, 0, 0.2), 0 0 10px 0 rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.blur-firm-shadow:hover {
    box-shadow: 0 25px 35px -12px rgba(0, 0, 0, 0.25), 0 0 15px 0 rgba(0, 0, 0, 0.15);
}

/* Animation multicolore pour le chargement */
@keyframes gradient-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes pulse-scale {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

@keyframes float-up-down {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.loading-container {
    position: relative;
}

.loading-container::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 14px;
    background: linear-gradient(45deg, 
        #ff3d00 0%, 
        #ff9e80 10%, 
        #00c853 20%, 
        #00e5ff 30%, 
        #304ffe 40%, 
        #aa00ff 50%, 
        #d50000 60%, 
        #ff6d00 70%, 
        #ffab00 80%, 
        #00bfa5 90%, 
        #6200ea 100%);
    background-size: 200% 200%;
    animation: gradient-animation 5s ease infinite;
    z-index: 0;
    filter: blur(5px);
    opacity: 0.8;
}

.dark .loading-container::before {
    opacity: 0.6;
}

.loading-content {
    position: relative;
    z-index: 1;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.dark .loading-content {
    background-color: rgba(31, 41, 55, 0.8);
}

.loading-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse-scale 1.5s ease infinite;
}

.loading-dot:nth-child(1) { background-color: #4f46e5; animation-delay: 0s; }
.loading-dot:nth-child(2) { background-color: #8b5cf6; animation-delay: 0.2s; }
.loading-dot:nth-child(3) { background-color: #ec4899; animation-delay: 0.4s; }
.loading-dot:nth-child(4) { background-color: #10b981; animation-delay: 0.6s; }
.loading-dot:nth-child(5) { background-color: #f59e0b; animation-delay: 0.8s; }

.generating-text {
    display: inline-block;
    background: linear-gradient(45deg, #4f46e5, #8b5cf6, #ec4899, #10b981, #f59e0b);
    background-size: 400% 400%;
    animation: gradient-animation 5s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: bold;
}

.dark .generating-text {
    background: linear-gradient(45deg, #818cf8, #a78bfa, #f472b6, #34d399, #fbbf24);
    background-size: 400% 400%;
    animation: gradient-animation 5s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.floating-container {
    animation: float-up-down 3s ease-in-out infinite;
}

/* Effet de glassmorphism gradient */
.glassmorphism-gradient {
    position: relative;
    overflow: hidden;
    z-index: 1;
    border-radius: 8px;
}

/* Styles pour les boutons de filtre - Style Apple épuré */
.filter-button {
    border: none;
    cursor: pointer;
    font-weight: 500;
    letter-spacing: -0.01em;
    outline: none;
    position: relative;
}

.filter-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

/* Couleur personnalisée pour bouton sélectionné */
.filter-button-selected {
    background-color: #3e516b !important;
    color: white !important;
}

.dark .filter-button-selected {
    background-color: #d1d5db !important;
    color: #2d3b4c !important;
}

/* Styles pour le design Pixabay des filtres */
.pixabay-tabs-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    border-bottom: 0;
    padding-bottom: 0;
}

.tab-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.46);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.tab-nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.72);
    transform: translateY(-1px);
}

.tab-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.pixabay-category-tabs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    scroll-behavior: smooth;
    flex: 1;
}

.pixabay-category-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.pixabay-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.48);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: max-content;
}

.pixabay-tab-btn:hover {
    background: rgba(255, 255, 255, 0.075);
    color: rgba(255, 255, 255, 0.74);
}

.pixabay-tab-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.82);
    box-shadow: none;
}

/* Styles pour le thème sombre */
.dark .pixabay-tabs-container {
    border-bottom: 0;
}

.dark .tab-nav-btn {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.46);
}

.dark .tab-nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.72);
}

.dark .pixabay-tab-btn {
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.48);
}

.dark .pixabay-tab-btn:hover {
    background: rgba(255, 255, 255, 0.075);
    color: rgba(255, 255, 255, 0.74);
}

.dark .pixabay-tab-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.82);
}

.template-gallery-shell {
    margin-top: 1.5rem;
}

.template-gallery-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.template-gallery-title {
    margin: 0;
    color: #9ca3af;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.25rem;
}

.template-toolbar-shell {
    position: sticky;
    top: 1rem;
    z-index: 18;
    margin-bottom: 1.35rem;
    padding: 1rem 1.1rem;
    border-radius: 1.35rem;
    border: 1px solid transparent;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.template-tabs-bar {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.template-load-more-wrap {
    display: flex;
    justify-content: center;
    padding: 1.25rem 0 0.5rem;
}

.template-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 220px;
    padding: 0.95rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(148, 163, 184, 0.08));
    color: #f8fafc;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.template-load-more-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
}

.template-load-more-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

/* Styles pour le scrollbar des filtres - Style Apple */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Amélioration des filtres avec scroll fluide */
.filter-scroll-container {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Animation fluide pour les changements de filtres */
@keyframes filter-fade-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.template-filter-animation {
    animation: filter-fade-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Effet de pulsation pour le compteur de designs */
@keyframes pulse-counter {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1.05);
    }
}

.counter-pulse {
    animation: pulse-counter 0.3s ease-in-out;
}

/* CSS pour le modal de template - Solution complète */
.template-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
}

.template-modal-overlay.show {
    display: flex;
}

.template-modal-container {
    width: 100vw;
    height: 100dvh;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.35rem, 1vw, 0.85rem);
}

.template-modal-content {
    position: relative;
    background: #131314;
    color: #f9fafb;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: min(94vw, var(--template-modal-width, 920px));
    max-width: 94vw;
    max-height: 97vh;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-dark .template-modal-content {
    background: #131314;
}

.template-modal-shell {
    padding: 0.9rem 0 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 98vh;
    overflow-y: auto;
}

.template-modal-top {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 0 0.5rem;
    min-width: 0;
}

.template-modal-topbar {
    display: flex;
    position: relative;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 1.25rem;
    padding-right: 56px;
}

.template-modal-heading {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.template-modal-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.template-modal-category {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    border-radius: 999px;
    padding: 0.14rem 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.15;
    text-transform: capitalize;
}

.template-modal-creator {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.15;
}

.template-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 12;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 0.75rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.template-modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.template-modal-title {
    font-size: 1.35rem;
    font-weight: 650;
    color: #ffffff;
    line-height: 1.25;
    margin: 0;
}

.template-modal-actions-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    align-items: flex-start;
    width: 100%;
    overflow: visible;
}

.template-modal-action-stack {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.42rem;
    width: 100%;
}

.template-modal-action-note {
    margin: 0;
    color: rgba(226, 232, 240, 0.72);
    font-size: 0.8rem;
    line-height: 1.35;
    text-align: center;
}

.template-modal-upload-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    width: 100%;
    grid-column: 1 / -1;
    align-items: stretch;
}

.template-modal-upload-cards > .template-modal-upload-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.template-modal-upload-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.32rem;
    width: 100%;
    min-height: 132px;
    max-height: 132px;
    padding: 0.45rem;
    border-radius: 1.2rem;
    appearance: none;
    border: 1px dashed rgba(176, 191, 210, 0.28);
    background: #202122;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    cursor: pointer;
    text-align: center;
    transition: none;
}

.template-modal-upload-card:focus-visible {
    outline: 2px solid rgba(197, 208, 225, 0.72);
    outline-offset: 2px;
}

.template-modal-upload-card.is-filled {
    border-color: rgba(202, 216, 235, 0.52);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.template-modal-upload-card::after {
    content: none;
}

.template-modal-upload-preview {
    width: 100%;
    height: 92px;
    max-height: 92px;
    min-width: 0;
    border-radius: 1rem;
    border: 0;
    background: transparent;
    overflow: hidden;
    flex: 1 1 auto;
}

.template-modal-upload-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 1rem;
}

.template-modal-upload-placeholder {
    width: 100%;
    height: 100%;
    min-height: 94px;
    padding: 0.4rem 0.38rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    color: rgba(233, 238, 248, 0.9);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.template-modal-upload-placeholder svg {
    width: 32px;
    height: 32px;
    padding: 7px;
    border-radius: 999px;
    border: 1px solid rgba(193, 208, 229, 0.2);
    background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05) 62%, rgba(255, 255, 255, 0.02) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.template-modal-upload-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 0.35rem 0.05rem;
    gap: 0.15rem;
}

.template-modal-upload-hint {
    color: rgba(236, 242, 251, 0.9);
    font-size: 0.86rem;
    font-weight: 590;
    line-height: 1.3;
    max-width: 100%;
    letter-spacing: 0;
}

.template-modal-upload-action {
    color: #7dd3fc;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
}

.template-modal-upload-file {
    color: rgba(224, 232, 244, 0.88);
    font-size: 0.72rem;
    font-weight: 520;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    border-radius: 999px;
    border: 1px solid rgba(183, 197, 217, 0.24);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.22rem 0.58rem;
}

.template-modal-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.56rem 0.85rem;
    border-radius: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.92);
    font-weight: 650;
    font-size: 0.93rem;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.template-modal-action svg {
    width: 14px;
    height: 14px;
}

.template-modal-action:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.template-modal-action-primary {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 0.2rem;
    min-height: 44px;
    justify-content: center;
    border-radius: 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.96);
    background: #ffffff;
    color: #111827;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
    font-size: clamp(0.9rem, 1.1vw, 0.97rem);
    font-weight: 620;
    letter-spacing: 0;
}

.template-modal-action-primary:hover {
    background: #f5f7fa;
    border-color: #ffffff;
    box-shadow: 0 7px 16px rgba(0, 0, 0, 0.24);
}

.template-modal-action-primary:active {
    transform: translateY(1px);
    box-shadow: 0 4px 11px rgba(0, 0, 0, 0.2);
}

.template-modal-action:disabled {
    cursor: not-allowed;
    opacity: 0.88;
    transform: none;
}

.template-modal-action.is-loading {
    pointer-events: none;
}

.template-modal-action.is-loading > svg {
    display: none;
}

.template-modal-action.is-loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    animation: template-use-spin 0.75s linear infinite;
}

@keyframes template-use-spin {
    to {
        transform: rotate(360deg);
    }
}

.template-modal-preview {
    position: relative;
    border-radius: 0.65rem;
    border: 0;
    background: transparent;
    height: var(--template-modal-preview-height, min(74vh, 820px));
    overflow: hidden;
}

.template-modal-preview-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #131314;
}

.template-modal-preview-media {
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
}

.template-modal-video-controls {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.template-modal-video-controls.hidden {
    display: none !important;
}

.template-modal-video-controls .video-control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
    outline: none;
}

.template-modal-video-controls .video-control-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.05);
}

.template-modal-video-controls .video-control-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.template-modal-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0;
    padding: 0;
}

@media (max-width: 1279px) {
    .template-modal-shell {
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
    }

    .template-modal-preview {
        order: 1;
    }

    .template-modal-bottom {
        order: 2;
        padding: 0 0.35rem;
    }

    .template-modal-top {
        order: 3;
        padding: 0 0.5rem 0.2rem;
    }

    .template-modal-actions-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.65rem;
    }

    .template-modal-upload-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .template-modal-upload-card {
        min-height: 118px;
        max-height: 118px;
        padding: 0.4rem;
    }

    .template-modal-upload-preview {
        height: 76px;
        max-height: 76px;
    }

    .template-modal-upload-placeholder {
        min-height: 78px;
        padding: 0.34rem 0.3rem;
        gap: 0.26rem;
    }

    .template-modal-upload-placeholder svg {
        width: 28px;
        height: 28px;
        padding: 6px;
    }

    .template-modal-upload-hint {
        font-size: 0.72rem;
    }

    .template-modal-action-primary {
        width: 100%;
        justify-content: center;
        min-height: 40px;
        font-size: clamp(0.84rem, 3.3vw, 0.9rem);
    }
}

@media (min-width: 1280px) {
    .template-modal-shell {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
        grid-template-rows: minmax(0, 1fr) auto;
        grid-template-areas:
            "preview top"
            "bottom top";
        column-gap: 1rem;
        row-gap: 0.9rem;
        padding: 0.95rem;
        align-items: start;
        height: calc(97vh - 1.9rem);
        max-height: calc(97vh - 1.9rem);
        overflow: hidden;
    }

    .template-modal-preview {
        grid-area: preview;
        height: 100%;
        min-height: 0;
    }

    .template-modal-bottom {
        grid-area: bottom;
        margin-top: 0;
        padding: 0;
        align-self: end;
    }

    .template-modal-top {
        grid-area: top;
        align-self: start;
        padding: 0;
        gap: 1rem;
        max-height: 100%;
        overflow: visible;
        position: sticky;
        top: 0;
    }

    .template-modal-title {
        font-size: clamp(1.25rem, 1.45vw, 1.7rem);
    }

    .template-modal-actions-row {
        grid-template-columns: minmax(0, 1fr);
        align-items: flex-start;
        gap: 0.75rem;
        overflow: visible;
    }

    .template-modal-upload-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .template-modal-upload-card {
        width: 100%;
        min-height: 132px;
        max-height: 132px;
    }

    .template-modal-action-primary {
        width: 100%;
        justify-content: center;
    }
}

/* Modal slider: match documents single thumbnails-horizontal-list look */
#templateModal .thumbnails-horizontal-scroll {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    background: rgba(34, 39, 44, 0.005);
    backdrop-filter: blur(2px);
    border-top: none;
    padding: 0 2px 16px 2px;
    overflow: hidden;
    mask: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    -webkit-mask: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
}

#templateModal .thumbnails-horizontal-scroll.hidden {
    display: none !important;
}

#templateModal .thumbnails-horizontal-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 8px 0 18px 0;
    flex: 1;
    margin-top: 0;
}

#templateModal .thumbnails-horizontal-list::-webkit-scrollbar {
    display: none;
}

#templateModal .image-thumbnail-horizontal {
    position: relative;
    width: 160px;
    height: 105px;
    min-width: 160px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    flex-shrink: 0;
}

#templateModal .image-thumbnail-horizontal.selected {
    border-color: rgba(255, 255, 255, 0.78);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.05);
}

#templateModal .image-thumbnail-horizontal img,
#templateModal .image-thumbnail-horizontal video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    background: #23243a;
    transition: all 0.3s ease;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
    -khtml-user-drag: none !important;
    -moz-user-drag: none !important;
    -o-user-drag: none !important;
    pointer-events: none !important;
}

#templateModal .image-thumbnail-horizontal .layer-number {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(34, 39, 44, 0.8);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    padding: 2px 6px;
    min-width: 16px;
    text-align: center;
    z-index: 3;
}

#templateModal .empty-thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 39, 44, 0.6);
    border-radius: 8px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#templateModal .empty-thumbnail-placeholder::before {
    content: '';
    width: 40px;
    height: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' ry='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpolyline points='21 15 16 10 5 21'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.5;
}

#templateModal .image-thumbnail-horizontal:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 32px rgba(88, 143, 244, 0.3);
    border-color: rgba(88, 143, 244, 0.8);
    background: rgba(255, 255, 255, 0.25);
}

.template-modal-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.96);
    margin-top: 0.55rem;
}

.template-creations-row {
    display: flex;
    gap: 1.1rem;
    overflow-x: auto;
    padding: 1rem 0 0.4rem;
    scroll-snap-type: x mandatory;
}

.template-creations-row::-webkit-scrollbar {
    height: 8px;
}
.template-creations-row::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}

.template-creation-card {
    position: relative;
    flex: 0 0 auto;
    width: 180px;
    height: 120px;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.04);
    overflow: hidden;
    scroll-snap-align: start;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.template-creation-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
}

.template-creation-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #0b0d10;
}

.template-creation-play {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 640px) {
    .template-modal-shell {
        padding: 0.65rem 0 0.65rem;
        gap: 0.7rem;
    }
    .template-modal-title {
        font-size: 1.1rem;
    }
    .template-modal-preview {
        height: min(62vh, 540px);
    }
    .template-modal-preview-inner {
        padding: 0;
    }
    .template-modal-top,
    .template-modal-bottom {
        padding: 0 0.3rem;
    }
    .template-modal-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }
    .template-creation-card {
        width: 150px;
        height: 105px;
    }
}


.template-modal-image-section {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex: 1;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
}

.theme-dark .template-modal-image-section {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 25%, #334155 50%, #1e293b 75%, #0f172a 100%);
}

@media (min-width: 1024px) {
    .template-modal-image-section {
        min-height: 45vh;
        max-width: none;
        padding: 1.25rem;
        z-index: auto;
    }
}

.template-modal-bg-effects {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.15;
    overflow: hidden;
}

.theme-dark .template-modal-bg-effects {
    opacity: 0.25;
}

.template-bg-blob {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    mix-blend-mode: multiply;
    filter: blur(40px);
    animation: blob 20s infinite;
}

.template-bg-blob-1 {
    background: #ff3d71;
    top: 0;
    left: -100px;
}

.template-bg-blob-2 {
    background: #3d71ff;
    top: 0;
    right: -100px;
    animation-delay: 2s;
}

.template-bg-blob-3 {
    background: #3dff71;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: 4s;
}

/* Blobs pour le mode sombre */
.theme-dark .template-bg-blob-1 {
    background: linear-gradient(45deg, #1e40af, #3730a3);
}

.theme-dark .template-bg-blob-2 {
    background: linear-gradient(45deg, #7c3aed, #5b21b6);
}

.theme-dark .template-bg-blob-3 {
    background: linear-gradient(45deg, #059669, #047857);
}

@keyframes blob {
    0%, 100% {
        transform: translate(0, 0);
    }
    33% {
        transform: translate(30px, -50px);
    }
    66% {
        transform: translate(-20px, 20px);
    }
}

.template-modal-image-container {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-modal-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.theme-dark .template-modal-image {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 255, 255, 0.08);
}

.template-modal-info-section {
    flex: 2;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    min-height: 50vh;
    overflow-y: auto;
}

.theme-dark .template-modal-info-section {
    background: #111827;
}

@media (min-width: 1280px) {
    .template-modal-info-section {
        max-width: none;
    }
}

@media (min-width: 1280px) {
    .template-modal-content {
        width: min(94vw, var(--template-modal-width, 920px));
        max-width: 94vw;
        max-height: 97vh;
        height: auto;
        border-radius: 1rem;
    }

    .template-modal-layout {
        position: relative;
        width: 100%;
        max-height: 95vh;
    }

    .template-modal-image-section {
        width: 100%;
        min-height: 45vh;
    }

    .template-modal-image-container {
        width: 100%;
        height: auto;
        padding: 0;
    }

    .template-modal-image {
        max-width: 100%;
        max-height: 45vh;
        width: auto;
        height: auto;
        position: relative;
        z-index: 1;
        object-fit: contain;
    }

    .template-modal-info-section {
        position: static;
        inset: auto;
        z-index: 0;
        background: #f9fafb;
        pointer-events: none;
        overflow: auto;
        max-height: calc(95vh - 45vh);
    }

    .template-modal-info-content {
        pointer-events: auto;
        height: auto;
        align-items: flex-start;
        justify-content: flex-start;
        position: relative;
        z-index: 2;
        padding: 1.25rem;
    }

    .template-modal-info-section .template-linked-contents,
    .template-modal-info-section .template-modal-header {
        pointer-events: auto;
    }
}

#templateModal .template-modal-info-section .template-modal-info-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    background: transparent;
    color: #1f2937;
}

.theme-dark #templateModal .template-modal-info-section .template-modal-info-content {
    color: #f9fafb;
}

#templateModal .template-modal-info-section .template-modal-header {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 1rem;
}

.theme-dark #templateModal .template-modal-info-section .template-modal-header {
    border-bottom-color: #374151;
}

#templateModal .template-modal-info-section .template-modal-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.theme-dark #templateModal .template-modal-info-section .template-modal-title {
    color: white;
}

#templateModal .template-modal-info-section .template-modal-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#templateModal .template-modal-info-section .template-modal-badge {
    display: inline-block;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
}

.theme-dark #templateModal .template-modal-info-section .template-modal-badge {
    background: #374151;
    color: #9ca3af;
}

.template-modal-form-section {
    flex: 1;
}

.template-modal-form-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 1rem;
}

.theme-dark .template-modal-form-title {
    color: white;
}

.template-modal-form-container {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1rem;
    box-shadow: 0 15px 25px -12px rgba(15, 23, 42, 0.16), 0 0 8px 0 rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    transition: all 0.3s ease;
}

.template-modal-form-container:hover {
    transform: translateY(-2px);
}

.theme-dark .template-modal-form-container {
    background: rgba(17, 24, 39, 0.8);
    border: 1px solid rgba(75, 85, 99, 0.3);
    box-shadow: 0 15px 25px -12px rgba(0, 0, 0, 0.32), 0 0 8px 0 rgba(255, 255, 255, 0.06);
}

.template-modal-textarea-container {
    position: relative;
}

.template-modal-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 120px;
    padding: 0.75rem;
    background: transparent;
    color: #1f2937;
    border: none;
    outline: none;
    resize: vertical;
    font-size: 1rem;
    line-height: 1.5;
}

.theme-dark .template-modal-textarea {
    color: #d1d5db;
}

.template-modal-textarea::placeholder {
    color: #9ca3af;
}

.theme-dark .template-modal-textarea::placeholder {
    color: #6b7280;
}

.template-modal-actions {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    position: sticky;
    bottom: 0;
    background: #f9fafb;
    z-index: 10;
}

/* Reduce padding when warning message is present */
.template-modal-actions:has(#template-credits-warning) {
    padding-top: 0.25rem;
}

/* Alternative for browsers that don't support :has() */
.template-modal-actions.has-warning {
    padding-top: 0.25rem;
}

.theme-dark .template-modal-actions {
    border-top-color: #374151;
    background: #111827;
}

.template-modal-button {
    width: 100%;
    background: white;
    color: #1f2937;
    font-weight: 600;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.template-modal-button:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.template-modal-button:active {
    transform: translateY(0);
}

/* Mode sombre pour le bouton blanc */
.theme-dark .template-modal-button {
    background: white !important;
    color: #1f2937 !important;
    border: 1px solid #e5e7eb !important;
}

.theme-dark .template-modal-button:hover {
    background: #f9fafb !important;
    border-color: #d1d5db !important;
}

/* Style for disabled template button (no credits) */
.template-modal-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.template-modal-button:disabled:hover {
    transform: none;
    background: white !important;
    border-color: #e5e7eb !important;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .template-modal-container {
        padding: 0.25rem;
        height: 100vh;
        align-items: stretch;
    }
    
    .template-modal-content {
        max-width: 100%;
        border-radius: 0.5rem;
        height: 100%;
        max-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .template-modal-layout {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    .template-modal-image-section {
        min-height: 35vh;
        max-height: 35vh;
        flex: none;
    }
    
    .template-modal-info-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    .template-modal-info-content {
        padding: 1rem;
        gap: 1rem;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        padding-bottom: 0;
    }
    
    .template-modal-form-section {
        flex: 1;
        min-height: 0;
    }
    
    .template-modal-close {
        top: 0.5rem;
        right: 0.5rem;
        width: 32px;
        height: 32px;
    }
    
    .template-modal-actions {
        flex: none;
        padding: 1rem;
        margin-top: 0;
        position: sticky;
        bottom: 0;
        background: #f9fafb;
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
        z-index: 20;
    }
    
    .theme-dark .template-modal-actions {
        background: #111827;
    }
    
    .template-modal-button {
        padding: 1rem;
        font-size: 1rem;
        font-weight: 700;
        min-height: 52px;
    }
}

.glassmorphism-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        #ff3d00 0%, 
        #ff9e80 10%, 
        #00c853 20%, 
        #00e5ff 30%, 
        #304ffe 40%, 
        #aa00ff 50%, 
        #d50000 60%, 
        #ff6d00 70%, 
        #ffab00 80%, 
        #00bfa5 90%, 
        #6200ea 100%);
    background-size: 200% 200%;
    animation: gradient-animation 5s ease infinite;
    z-index: -1;
    border-radius: 6px;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: rgba(107, 114, 128, 0.5); }
}

@keyframes changeText {
  0%, 15% { content: "logo for a tech startup"; }
  20%, 35% { content: "social media post"; }
  40%, 55% { content: "website banner"; }
  60%, 75% { content: "product mockup"; }
  80%, 95% { content: "advertisement"; }
  100% { content: "logo for a tech startup"; }
}

/* Classe pour créer l'effet dynamique du texte dans le placeholder */
.dynamic-placeholder::placeholder {
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

/* Animation spécifique pour le texte changeant après "Ask MyUP to create a..." */
.dynamic-placeholder {
    position: relative;
}
  
/* Style pour le pseudo-élément qui va créer notre animation */
.dynamic-placeholder:focus::placeholder {
    color: transparent; /* Cacher le placeholder quand l'input est en focus */
}

/* Masonry Layout respectant les dimensions réelles des images */
.inspiration-masonry-grid {
    column-count: 4;
    column-gap: 12px;
    column-fill: balance;
}

.inspiration-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 6px;
    break-inside: avoid;
    page-break-inside: avoid;
}

.inspiration-item img {
    width: 100%;
    height: auto;
    display: block;
}

.template-card-shell {
    border-radius: 0.625rem;
    background: #121317;
    border: 0;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
    overflow: hidden;
    transform: translateZ(0);
}

.template-card-shell:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.template-card-media {
    display: block;
    width: 100%;
    min-height: 220px;
    object-fit: cover;
}

.template-card-media-stage {
    position: relative;
    min-height: 220px;
    overflow: hidden;
    background: #121317;
}

.template-card-media-slide {
    display: block;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity 1.85s linear;
    will-change: opacity;
    backface-visibility: hidden;
}

.template-card-media-stage .template-card-media-slide:first-child {
    position: relative;
}

.template-card-media-stage .template-card-media-slide:not(:first-child) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.template-card-media-slide.is-active {
    opacity: 1;
    z-index: 2;
}

.template-card-media-slide.is-outgoing {
    opacity: 0;
    z-index: 3;
}

.template-card-content {
    z-index: 2;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.template-card-category-inline {
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.2;
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}

.template-card-loader {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: #121317;
    z-index: 4;
    pointer-events: none;
}

.template-card-loader::after {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.07);
    border-top-color: rgba(255, 255, 255, 0.38);
    animation: tpl-card-spin 0.65s linear infinite;
}

@keyframes tpl-card-spin {
    to { transform: rotate(360deg); }
}

/* Visible dès qu'une carte a une image ou vidéo lazy-load */
.template-card-shell:has(img[data-template-seq-src]) .template-card-loader,
.template-card-shell:has(video[data-template-load-state]) .template-card-loader {
    display: flex;
}

/* Disparaît une fois le média chargé ou en erreur */
.template-card-shell:has(img[data-template-seq-src]:not([data-template-slide])[data-template-load-state="loaded"]) .template-card-loader,
.template-card-shell:has(img[data-template-seq-src]:not([data-template-slide])[data-template-load-state="error"]) .template-card-loader,
.template-card-shell:has(.is-active[data-template-load-state="loaded"]) .template-card-loader,
.template-card-shell:has(.is-active[data-template-load-state="error"]) .template-card-loader,
.template-card-shell:has(video[data-template-load-state="loaded"]) .template-card-loader,
.template-card-shell:has(video[data-template-load-state="error"]) .template-card-loader {
    display: none;
}

.template-card-kicker {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.84);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.template-card-kicker-meta {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.template-card-kicker > .template-card-kicker-meta:first-child {
    flex: 1 1 auto;
    min-width: 0;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

/* Responsive column count */
@media (max-width: 640px) {
    .template-gallery-header {
        align-items: stretch;
    }

    .template-toolbar-shell {
        top: 0.5rem;
        padding: 0.85rem;
        border-radius: 1rem;
    }

    .inspiration-masonry-grid {
        column-count: 2;
        column-gap: 6px;
    }
    .inspiration-item {
        margin-bottom: 6px;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .template-gallery-header {
        align-items: stretch;
    }

    .inspiration-masonry-grid {
        column-count: 2;
        column-gap: 8px;
    }
    .inspiration-item {
        margin-bottom: 8px;
    }
}

@media (min-width: 769px) and (max-width: 1280px) {
    .inspiration-masonry-grid {
        column-count: 3;
        column-gap: 12px;
    }
    .inspiration-item {
        margin-bottom: 12px;
    }
}

@media (min-width: 1281px) {
    .inspiration-masonry-grid {
        column-count: 4;
        column-gap: 12px;
    }
    .inspiration-item {
        margin-bottom: 12px;
    }
}

/* Template Modal Styles */

/* Responsive image handling in modal */
@media (max-width: 768px) {
    .template-modal-image {
        max-height: 40vh !important;
        width: auto;
        border-radius: 8px;
    }
    
    #templateModal .flex-col {
        max-height: 95vh;
    }
    
    #templateModal .overflow-y-auto {
        max-height: 50vh;
    }
}

@media (min-width: 769px) {
    .template-modal-image {
        max-height: calc(95vh - 120px) !important;
    }
}

/* Ensure modal content doesn't overflow */
#templateModal .modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Sticky buttons on mobile */
@media (max-width: 768px) {
    #templateModal .sticky {
        position: sticky;
        bottom: 0;
        z-index: 10;
        margin-top: auto;
        padding-top: 1rem;
        padding-bottom: 1rem;
        border-top: 1px solid rgba(156, 163, 175, 0.2);
        background: inherit;
        backdrop-filter: blur(10px);
    }
    
    /* Ensure close button is always on top on mobile */
    #templateModal button[onclick="closeTemplateModal()"] {
        position: fixed !important;
        top: 8px !important;
        right: 8px !important;
        z-index: 99999 !important;
        background: rgba(0, 0, 0, 0.8) !important;
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        padding: 6px !important;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #templateModal button[onclick="closeTemplateModal()"] svg {
        width: 14px !important;
        height: 14px !important;
    }
    
    #templateModal button[onclick="closeTemplateModal()"]:hover {
        background: rgba(0, 0, 0, 0.95) !important;
        transform: scale(1.05);
    }
}

/* Line clamp utility */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Better scrollbar styling */
#templateModal .overflow-y-auto::-webkit-scrollbar {
    width: 4px;
}

#templateModal .overflow-y-auto::-webkit-scrollbar-track {
    background: transparent;
}

#templateModal .overflow-y-auto::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.3);
    border-radius: 2px;
}

#templateModal .overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.5);
}

/* Animated background blobs */
@keyframes blob-2 {
    0% {
        transform: translate(0px, 0px) scale(1);
    }
    33% {
        transform: translate(30px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

.animate-blob {
    animation: blob-2 7s infinite;
}

.animation-delay-2000 {
    animation-delay: 2s;
}

.animation-delay-4000 {
    animation-delay: 4s;
}

/* Enhanced image shadow for dark background */
.template-modal-image {
    transition: all 0.3s ease;
    border-radius: 12px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 0 50px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(1px);
}

/* Dark mode adjustments */
.dark .template-modal-image {
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 0 30px rgba(99, 102, 241, 0.2);
}

/* Close button enhancements */
#templateModal button[onclick="closeTemplateModal()"] {
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#templateModal button[onclick="closeTemplateModal()"] svg {
    transition: transform 0.2s ease;
}

#templateModal button[onclick="closeTemplateModal()"]:hover svg {
    transform: rotate(90deg);
}

/* ===== SUCCESS EXPLOSION ANIMATION STYLES ===== */

/* Color Explosion Background */
.color-explosion-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    pointer-events: none;
    z-index: 1;
}

.explosion-circle {
    position: absolute;
    border-radius: 50%;
    animation: colorExplosion 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
}

.circle-1 {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 0.05s;
}

.circle-2 {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 0.1s;
}

.circle-3 {
    width: 25px;
    height: 25px;
    background: linear-gradient(135deg, #45b7d1, #74b9ff);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 0.15s;
}

.circle-4 {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 0.2s;
}

.circle-5 {
    width: 15px;
    height: 15px;
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 0.25s;
}

/* Floating Design Elements */
.floating-design-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.design-element {
    position: absolute;
    font-size: 2.2rem;
    animation: designFloat 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.6));
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.element-1 {
    animation-delay: 0.1s;
    --start-color: #ff6b6b;
    --mid-color: #4ecdc4;
    --end-color: #45b7d1;
}

.element-2 {
    animation-delay: 0.15s;
    --start-color: #4ecdc4;
    --mid-color: #45b7d1;
    --end-color: #f093fb;
}

.element-3 {
    animation-delay: 0.2s;
    --start-color: #45b7d1;
    --mid-color: #f093fb;
    --end-color: #4facfe;
}

.element-4 {
    animation-delay: 0.25s;
    --start-color: #f093fb;
    --mid-color: #4facfe;
    --end-color: #ff6b6b;
}

.element-5 {
    animation-delay: 0.3s;
    --start-color: #4facfe;
    --mid-color: #ff6b6b;
    --end-color: #4ecdc4;
}

.element-6 {
    animation-delay: 0.35s;
    --start-color: #ff6b6b;
    --mid-color: #4ecdc4;
    --end-color: #45b7d1;
}

.element-7 {
    animation-delay: 0.4s;
    --start-color: #4ecdc4;
    --mid-color: #45b7d1;
    --end-color: #f093fb;
}

.element-8 {
    animation-delay: 0.45s;
    --start-color: #45b7d1;
    --mid-color: #f093fb;
    --end-color: #4facfe;
}

.success-glow {
    animation: successGlow 2s ease-in-out infinite alternate;
}

.success-text {
    color: #10b981 !important;
    font-weight: 700 !important;
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.5) !important;
}

.success-pulse-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: successPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

/* Keyframes for animations */
@keyframes colorExplosion {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(3);
    }
}

@keyframes designFloat {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.2) rotate(0deg);
        filter: drop-shadow(0 0 15px var(--start-color, #ff6b6b)) hue-rotate(0deg);
    }
    15% {
        opacity: 1;
        transform: translate(0, 0) scale(2.0) rotate(45deg);
        filter: drop-shadow(0 0 25px var(--mid-color, #4ecdc4)) hue-rotate(90deg);
    }
    40% {
        opacity: 1;
        transform: translate(calc(var(--float-x, 0) * 0.3), calc(var(--float-y, 0) * 0.3)) scale(1.5) rotate(180deg);
        filter: drop-shadow(0 0 20px var(--mid-color, #4ecdc4)) hue-rotate(180deg);
    }
    70% {
        opacity: 0.8;
        transform: translate(calc(var(--float-x, 0) * 0.7), calc(var(--float-y, 0) * 0.7)) scale(1.2) rotate(270deg);
        filter: drop-shadow(0 0 15px var(--end-color, #45b7d1)) hue-rotate(270deg);
    }
    100% {
        opacity: 0.6;
        transform: translate(var(--float-x, 0), var(--float-y, 0)) scale(1) rotate(360deg);
        filter: drop-shadow(0 0 10px var(--end-color, #45b7d1)) hue-rotate(360deg);
    }
}

@keyframes successGlow {
    0% {
        box-shadow: 0 0 20px rgba(78, 205, 196, 0.3);
    }
    100% {
        box-shadow: 0 0 30px rgba(78, 205, 196, 0.6), 0 0 40px rgba(78, 205, 196, 0.3);
    }
}

@keyframes successPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* Random floating directions for design elements - Explosion from center */
.element-1 { --float-x: -120px; --float-y: -80px; }
.element-2 { --float-x: 120px; --float-y: -80px; }
.element-3 { --float-x: -80px; --float-y: -120px; }
.element-4 { --float-x: 80px; --float-y: -120px; }
.element-5 { --float-x: -120px; --float-y: 80px; }
.element-6 { --float-x: 120px; --float-y: 80px; }
.element-7 { --float-x: -80px; --float-y: 120px; }
.element-8 { --float-x: 80px; --float-y: 120px; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .design-element {
        font-size: 1.4rem;
    }
    
    .color-explosion-bg {
        width: 150px;
        height: 150px;
    }
    
    .element-1 { --float-x: -80px; --float-y: -60px; }
    .element-2 { --float-x: 80px; --float-y: -60px; }
    .element-3 { --float-x: -60px; --float-y: -80px; }
    .element-4 { --float-x: 60px; --float-y: -80px; }
    .element-5 { --float-x: -80px; --float-y: 60px; }
    .element-6 { --float-x: 80px; --float-y: 60px; }
    .element-7 { --float-x: -60px; --float-y: 80px; }
    .element-8 { --float-x: 60px; --float-y: 80px; }
}

/* Template modal mobile: stop layout right after primary action */
@media (max-width: 1279px) {
    #templateModal .template-modal-container {
        align-items: flex-start;
        min-height: 100dvh;
        padding: 0.3rem 0.3rem calc(0.8rem + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #templateModal .template-modal-content {
        display: block !important;
        height: auto !important;
        min-height: 0;
        max-height: none !important;
    }

    #templateModal .template-modal-shell {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        max-height: none;
        overflow: visible;
        padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
    }

    #templateModal .template-modal-preview {
        height: min(44vh, 420px);
    }

    #templateModal .template-modal-top {
        padding: 0 0.3rem 0.05rem;
    }

    #templateModal .template-modal-bottom {
        padding: 0 0.3rem;
        margin-bottom: 0;
    }

    #templateModal .thumbnails-horizontal-list {
        padding-bottom: 8px;
    }

    #templateModal .template-modal-actions-row {
        margin-bottom: 0;
        padding-bottom: calc(0.45rem + env(safe-area-inset-bottom, 0px));
    }

    #templateModal .template-modal-action-primary {
        width: 100%;
        justify-content: center;
        margin-bottom: 0;
    }
}
