/* ============================================================================
   1mai.fr - Générateur de muguet militant
   ============================================================================ */

:root {
    --mai-yellow: #FFE845;
    --mai-red: #E53935;
    --mai-red-dark: #B71C1C;
    --mai-green: #2E7D32;
    --mai-green-light: #66BB6A;
    --mai-white: #FFFFFF;
    --mai-black: #1A1A1A;
    --mai-gray: #616161;
    --mai-gray-light: #F5F5F5;
    --mai-shadow: 0 4px 20px rgba(0,0,0,0.1);
    --mai-shadow-hover: 0 8px 30px rgba(0,0,0,0.15);
    --mai-radius: 12px;
    --mai-radius-lg: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--mai-yellow);
    color: var(--mai-black);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.site-header {
    background: var(--mai-white);
    padding: 1rem 2rem;
    box-shadow: var(--mai-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--mai-black);
}

.logo-icon {
    font-size: 2rem;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--mai-gray);
    font-weight: 400;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-nav a {
    color: var(--mai-gray);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s;
}

.header-nav a:hover {
    color: var(--mai-red);
}

/* ============================================================================
   HERO BANNER
   ============================================================================ */

.hero-banner {
    background: linear-gradient(135deg, var(--mai-yellow) 0%, #FFD600 100%);
    padding: 2.5rem 2rem 2rem;
    text-align: center;
}

.hero-banner h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--mai-black);
}

.hero-banner p {
    font-size: 1rem;
    color: var(--mai-gray);
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================================================
   GENERATOR LAYOUT
   ============================================================================ */

.generator-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 320px 380px;
    gap: 1.5rem;
    min-height: calc(100vh - 250px);
}

/* ============================================================================
   MODELS PANEL (Left)
   ============================================================================ */

.models-panel {
    background: var(--mai-white);
    border-radius: var(--mai-radius-lg);
    box-shadow: var(--mai-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.category-filters {
    display: flex;
    gap: 6px;
    padding: 0.75rem 1.25rem;
    flex-wrap: wrap;
    flex-shrink: 0;
    border-bottom: 1px solid #f0f0f0;
}

.category-btn {
    padding: 5px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    background: var(--mai-white);
    font-family: 'Poppins', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--mai-gray);
    cursor: pointer;
    transition: all 0.2s;
}

.category-btn:hover {
    border-color: var(--mai-red);
    color: var(--mai-red);
}

.category-btn.active {
    background: var(--mai-red);
    border-color: var(--mai-red);
    color: var(--mai-white);
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    padding: 1rem 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.model-card {
    aspect-ratio: 2/3;
    border: 3px solid transparent;
    border-radius: var(--mai-radius);
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    background: #FAFAFA;
    position: relative;
}

.model-card:hover {
    border-color: var(--mai-yellow);
    transform: translateY(-2px);
    box-shadow: var(--mai-shadow-hover);
}

.model-card.selected {
    border-color: var(--mai-red);
    box-shadow: 0 0 0 2px var(--mai-red);
}

.model-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.model-card .model-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 0.6rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.model-card:hover .model-name {
    opacity: 1;
}

.models-pagination {
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    border-top: 1px solid #f0f0f0;
}

.page-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: var(--mai-white);
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-btn:hover { border-color: var(--mai-red); }
.page-btn.active { background: var(--mai-red); color: white; border-color: var(--mai-red); }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* ============================================================================
   CUSTOMIZATION PANEL (Center)
   ============================================================================ */

.customize-panel {
    background: var(--mai-white);
    border-radius: var(--mai-radius-lg);
    box-shadow: var(--mai-shadow);
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    position: sticky;
    top: 80px;
}

.customize-panel .panel-header {
    position: sticky;
    top: 0;
    background: var(--mai-white);
    z-index: 5;
}

.customize-content {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--mai-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    background: var(--mai-white);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--mai-red);
}

.form-group input[type="range"] {
    width: 100%;
    accent-color: var(--mai-red);
}

.range-value {
    font-size: 0.75rem;
    color: var(--mai-gray);
    text-align: right;
}

/* Color picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-picker-wrapper input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
}

.color-picker-wrapper input[type="text"] {
    flex: 1;
}

/* Color palette */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.color-swatch:hover {
    transform: scale(1.2);
}

.color-swatch.active {
    border-color: var(--mai-black);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--mai-black);
}

/* Gradients */
.gradient-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.gradient-swatch {
    height: 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.gradient-swatch:hover {
    transform: scale(1.05);
}

.gradient-swatch.active {
    border-color: var(--mai-black);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--mai-black);
}

/* Bg type toggle */
.bg-type-toggle {
    display: flex;
    gap: 4px;
    background: var(--mai-gray-light);
    border-radius: 8px;
    padding: 3px;
}

.bg-type-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--mai-gray);
}

.bg-type-btn.active {
    background: var(--mai-white);
    color: var(--mai-black);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Text position */
.text-position-btns {
    display: flex;
    gap: 4px;
}

.text-pos-btn {
    flex: 1;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: var(--mai-white);
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.text-pos-btn:hover { border-color: var(--mai-red); }
.text-pos-btn.active { background: var(--mai-red); color: white; border-color: var(--mai-red); }

/* Format toggle */
.format-toggle {
    display: flex;
    gap: 4px;
}

.format-btn {
    flex: 1;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: var(--mai-white);
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.format-btn:hover { border-color: var(--mai-red); }
.format-btn.active { background: var(--mai-red); color: white; border-color: var(--mai-red); }

/* ============================================================================
   PREVIEW PANEL (Right)
   ============================================================================ */

.preview-panel {
    position: sticky;
    top: 80px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 200px);
}

.preview-card {
    background: var(--mai-white);
    border-radius: var(--mai-radius-lg);
    box-shadow: var(--mai-shadow);
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.preview-card .panel-header {
    padding: 0 0 0.75rem 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.75rem;
}

.preview-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#preview-container {
    width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: var(--mai-radius);
}

#preview-container.portrait {
    aspect-ratio: 2/3;
}

#preview-container.square {
    aspect-ratio: 1/1;
}

.preview-bg {
    position: absolute;
    inset: 0;
}

.preview-muguet {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-muguet img {
    max-width: 80%;
    max-height: 75%;
    object-fit: contain;
}

.preview-text {
    position: absolute;
    left: 5%;
    right: 5%;
    text-align: center;
    z-index: 10;
    word-wrap: break-word;
    text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.preview-text.pos-top { top: 6%; }
.preview-text.pos-center { top: 50%; transform: translateY(-50%); }
.preview-text.pos-bottom { bottom: 6%; }

/* Action buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-download {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    background: var(--mai-red);
    color: white;
    border: none;
    border-radius: var(--mai-radius);
    font-family: 'Poppins', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-download:hover {
    background: var(--mai-red-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229,57,53,0.4);
}

.btn-download:active {
    transform: translateY(0);
}

.btn-download svg {
    width: 22px;
    height: 22px;
}

.btn-share {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--mai-white);
    color: var(--mai-gray);
    border: 2px solid #e0e0e0;
    border-radius: var(--mai-radius);
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-share:hover {
    border-color: var(--mai-green);
    color: var(--mai-green);
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.site-footer {
    background: var(--mai-black);
    color: rgba(255,255,255,0.6);
    padding: 2rem;
    text-align: center;
    font-size: 0.8rem;
    margin-top: 2rem;
}

.site-footer a {
    color: var(--mai-yellow);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* ============================================================================
   LOADING / TOAST
   ============================================================================ */

.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: var(--mai-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--mai-black);
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    z-index: 1000;
    transition: transform 0.3s ease;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success { background: var(--mai-green); }
.toast.error { background: var(--mai-red); }

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 1100px) {
    .generator-container {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }

    .models-panel {
        grid-column: 1 / -1;
        max-height: 400px;
    }

    .customize-panel {
        position: static;
        max-height: none;
    }

    .preview-panel {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .generator-container {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }

    .models-panel {
        max-height: 350px;
    }

    .models-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }

    .hero-banner h2 {
        font-size: 1.3rem;
    }

    .hero-banner {
        padding: 1.5rem 1rem 1rem;
    }

    .site-header {
        padding: 0.75rem 1rem;
    }

    .logo-text h1 {
        font-size: 1.2rem;
    }

    .customize-panel, .preview-panel {
        position: static;
        max-height: none;
    }

    #preview-container {
        max-height: 400px;
    }
}

@media (max-width: 480px) {
    .models-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 0.75rem;
    }

    .category-filters {
        padding: 0.5rem 0.75rem;
        gap: 4px;
    }

    .category-btn {
        font-size: 0.7rem;
        padding: 4px 10px;
    }

    .gradient-palette {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================================================
   PRINT HIDDEN
   ============================================================================ */

@media print {
    .site-header, .hero-banner, .models-panel, .customize-panel, .action-buttons, .site-footer {
        display: none !important;
    }
}
