/**
 * Styles Mobile-First pour Le Nut's Menu Generator
 * Design ultra moderne et responsive
 *
 * Breakpoints:
 * - Mobile: 0 - 767px (base)
 * - Tablet: 768px - 1023px
 * - Desktop: 1024px+
 */

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    /* Couleurs principales */
    --primary: #556B2F;
    --primary-dark: #3d4d22;
    --primary-light: #6b8339;
    --accent: #8B0000;
    --accent-light: #a52a2a;

    /* Couleurs neutres */
    --cream: #FAF8F0;
    --cream-dark: #F0EDE0;
    --white: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --border: #e0e0e0;
    --border-light: #f0f0f0;

    /* Couleurs traduction */
    --translate-blue: #2563eb;
    --translate-light: #dbeafe;

    /* Ombres */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.15);

    /* Rayons */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Espacements */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Safe areas pour iPhone */
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

/* ============================================
   RESET & BASE (Mobile-First)
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--cream);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ============================================
   HEADER MOBILE
   ============================================ */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: calc(var(--safe-top) + var(--space-md)) var(--space-md) var(--space-md);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.header-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-logo img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    border: 2px solid rgba(255,255,255,0.3);
    object-fit: cover;
}

.header-text {
    flex: 1;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
}

/* Bouton preview mobile */
.btn-preview-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-preview-mobile:active {
    background: rgba(255,255,255,0.25);
    transform: scale(0.95);
}

/* ============================================
   CONTAINER
   ============================================ */
.container {
    padding: var(--space-md);
    max-width: 100%;
}

/* ============================================
   ALERTES
   ============================================ */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ============================================
   TEMPLATES - SCROLL HORIZONTAL MOBILE
   ============================================ */
.templates-section {
    margin-bottom: var(--space-lg);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.templates-scroll {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-sm);
    margin: 0 calc(var(--space-md) * -1);
    padding-left: var(--space-md);
    padding-right: var(--space-md);
}

.templates-scroll::-webkit-scrollbar {
    display: none;
}

.template-card {
    flex-shrink: 0;
    width: 120px;
    background: var(--white);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-sm);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    scroll-snap-align: start;
    box-shadow: var(--shadow-sm);
}

.template-card:active {
    transform: scale(0.97);
}

.template-card.active {
    border-color: var(--primary);
    background: linear-gradient(180deg, var(--white) 0%, var(--cream) 100%);
}

.template-icon {
    font-size: 2rem;
    margin-bottom: var(--space-xs);
}

.template-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    line-height: 1.3;
}

/* ============================================
   FORMULAIRE PRINCIPAL
   ============================================ */
.main-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.form-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow);
}

/* ============================================
   CHAMPS DE FORMULAIRE
   ============================================ */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-sm);
}

.form-input {
    width: 100%;
    padding: var(--space-md);
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    transition: var(--transition-fast);
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(85, 107, 47, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* Checkbox stylé */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--cream);
    border-radius: var(--radius);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.form-check input[type="checkbox"] {
    width: 24px;
    height: 24px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ============================================
   LISTE DES PLATS
   ============================================ */
.dishes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.dishes-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--cream);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
}

.dishes-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* ============================================
   CARTE D'UN PLAT
   ============================================ */
.dish-card {
    background: var(--cream);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dish-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--primary);
    color: var(--white);
}

.dish-number {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    font-size: 0.9rem;
}

.dish-number span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
}

.dish-actions {
    display: flex;
    gap: var(--space-sm);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition-fast);
}

.btn-icon:active {
    transform: scale(0.9);
}

.btn-translate-sm {
    background: var(--translate-blue);
    color: var(--white);
}

.dish-remove {
    background: rgba(255,255,255,0.15);
    color: var(--white);
}

/* Section française */
.dish-section {
    padding: var(--space-md);
}

.dish-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    margin-bottom: var(--space-md);
}

/* Section anglaise */
.dish-section-en {
    background: var(--translate-light);
    border-top: 2px dashed var(--translate-blue);
}

.dish-section-en .dish-section-title {
    color: var(--translate-blue);
}

.translation-status {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-loading { color: #f59e0b; }
.status-success { color: #10b981; }
.status-error { color: #ef4444; }

/* Grille des champs */
.dish-fields {
    display: grid;
    gap: var(--space-md);
}

.dish-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-sm);
}

.dish-input {
    width: 100%;
    padding: var(--space-md);
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    transition: var(--transition-fast);
}

.dish-input:focus {
    outline: none;
    border-color: var(--primary);
}

.dish-section-en .dish-input:focus {
    border-color: var(--translate-blue);
}

.dish-input.translated {
    background: rgba(16, 185, 129, 0.08);
    border-color: #10b981;
}

.price-input {
    width: 100px;
    text-align: right;
}

.price-wrapper {
    position: relative;
}

.price-wrapper::after {
    content: '€';
    position: absolute;
    right: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
}

.price-wrapper .dish-input {
    padding-right: 36px;
}

/* ============================================
   BOUTONS D'ACTION
   ============================================ */
.actions-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(85, 107, 47, 0.3);
}

.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-translate {
    background: linear-gradient(135deg, var(--translate-blue) 0%, #1d4ed8 100%);
    color: var(--white);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    color: var(--white);
}

.btn-lg {
    padding: var(--space-lg);
    font-size: 1.1rem;
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
}

/* Boutons inline */
.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

/* ============================================
   MODAL PREVIEW (Mobile)
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cream);
    border: none;
    border-radius: var(--radius-full);
    font-size: 1.25rem;
    cursor: pointer;
}

.modal-body {
    padding: var(--space-md);
    overflow-y: auto;
    max-height: calc(90vh - 120px);
    padding-bottom: calc(var(--safe-bottom) + var(--space-lg));
}

/* ============================================
   PREVIEW DU MENU
   ============================================ */
.preview-frame {
    background: var(--cream);
    border: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: var(--space-lg);
    position: relative;
    min-height: 400px;
}

.preview-frame::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid var(--primary);
    pointer-events: none;
    border-radius: calc(var(--radius) - 4px);
}

.preview-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    opacity: 0.08;
    pointer-events: none;
}

.preview-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.preview-header {
    margin-bottom: var(--space-lg);
}

.preview-diamond {
    width: 12px;
    height: 12px;
    background: var(--primary);
    transform: rotate(45deg);
    margin: 0 auto var(--space-sm);
}

.preview-lines {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
}

.preview-line {
    width: 40px;
    height: 2px;
    background: var(--primary);
}

.preview-title {
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: var(--space-md);
}

.preview-dishes {
    padding: var(--space-md) 0;
}

.preview-dish {
    padding: var(--space-md) 0;
    border-bottom: 1px solid rgba(85, 107, 47, 0.2);
}

.preview-dish:last-child {
    border-bottom: none;
}

.preview-dish-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.preview-dish-desc {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
}

.preview-dish-price {
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: var(--space-xs);
}

.preview-dish-en {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.preview-footer {
    margin-top: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
}

.preview-footer-line {
    width: 30px;
    height: 2px;
    background: var(--primary);
}

.preview-footer-circle {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: var(--radius-full);
}

/* ============================================
   FICHIERS GÉNÉRÉS
   ============================================ */
.files-section {
    margin-top: var(--space-lg);
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.file-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    overflow: hidden;
}

.file-icon {
    font-size: 1.5rem;
}

.file-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-link {
    padding: var(--space-sm) var(--space-md);
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    padding-bottom: calc(var(--safe-bottom) + var(--space-xl));
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============================================
   TABLET (768px+)
   ============================================ */
@media (min-width: 768px) {
    .container {
        padding: var(--space-lg);
        max-width: 720px;
        margin: 0 auto;
    }

    .header-content {
        max-width: 720px;
        margin: 0 auto;
    }

    .header-logo img {
        width: 56px;
        height: 56px;
    }

    .header-title {
        font-size: 1.5rem;
    }

    .templates-scroll {
        flex-wrap: wrap;
        overflow-x: visible;
        margin: 0;
        padding: 0;
    }

    .template-card {
        width: calc(33.333% - var(--space-sm));
    }

    .dish-row {
        grid-template-columns: 1fr 120px;
    }

    .btn-row {
        grid-template-columns: 1fr 1fr;
    }

    .modal-content {
        max-width: 500px;
        margin: auto;
        border-radius: var(--radius-xl);
        max-height: 85vh;
    }
}

/* ============================================
   DESKTOP (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    .container {
        max-width: 1200px;
        padding: var(--space-xl);
    }

    .header {
        padding: var(--space-lg) var(--space-xl);
    }

    .header-content {
        max-width: 1200px;
    }

    .btn-preview-mobile {
        display: none;
    }

    .main-form {
        display: grid;
        grid-template-columns: 1fr 400px;
        gap: var(--space-xl);
        align-items: start;
    }

    .preview-section {
        position: sticky;
        top: 100px;
    }

    .preview-section .section-title {
        margin-bottom: var(--space-md);
    }

    .templates-scroll {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
    }

    .template-card {
        width: auto;
    }

    .template-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow);
    }

    .btn:hover {
        transform: translateY(-2px);
    }

    .btn-primary:hover {
        box-shadow: 0 6px 16px rgba(85, 107, 47, 0.4);
    }

    .actions-group {
        flex-direction: row;
    }

    .actions-group .btn {
        flex: 1;
    }
}

/* ============================================
   DESKTOP LARGE (1400px+)
   ============================================ */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
    }

    .main-form {
        grid-template-columns: 1fr 450px;
    }
}

/* ============================================
   UTILITAIRES
   ============================================ */
.hidden-mobile {
    display: none !important;
}

.hidden-desktop {
    display: block;
}

@media (min-width: 1024px) {
    .hidden-mobile {
        display: block !important;
    }

    .hidden-desktop {
        display: none !important;
    }
}

/* Focus visible pour accessibilité */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Scrollbar stylée */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--cream);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: var(--radius-full);
}
