:root {
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Couleurs Thème Lavande Moderne */
    --primary: #6c5ce7;
    --primary-hover: #5849df;
    --primary-light: rgba(108, 92, 231, 0.12);
    --primary-glow: rgba(108, 92, 231, 0.35);

    --gemini-gradient: linear-gradient(135deg, #4e54c8 0%, #8f94fb 50%, #ff758c 100%);
    --gemini-glow: rgba(142, 148, 251, 0.4);

    --success: #00b894;
    --success-bg: rgba(0, 184, 148, 0.12);
    --warning: #fdcb6e;
    --warning-text: #e17055;
    --warning-bg: rgba(253, 203, 110, 0.15);
    --danger: #ff4757;
    --danger-bg: rgba(255, 71, 87, 0.15);

    /* Thème Sombre par défaut */
    --bg-base: #0f111a;
    --bg-surface: #171926;
    --bg-surface-elevated: #1e2235;
    --bg-glass: rgba(23, 25, 38, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(108, 92, 231, 0.5);

    --text-primary: #f8f9fa;
    --text-secondary: #a0a5b8;
    --text-muted: #6c7289;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 25px var(--primary-glow);

    --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-light {
    --bg-base: #f4f5f9;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f8f9fc;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(108, 92, 231, 0.6);

    --text-primary: #1e2235;
    --text-secondary: #5a6078;
    --text-muted: #8b92a8;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* LAYOUT PRINCIPAL */
.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-emoji {
    font-size: 28px;
    background: var(--primary-light);
    padding: 8px;
    border-radius: var(--radius-md);
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.foyer-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-surface-elevated);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.nav-item:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-pseudo {
    font-size: 13px;
    font-weight: 700;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.text-danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* MAIN CONTENT */
.main-content {
    padding: 30px 40px;
    max-width: 1400px;
}

/* TOPBAR & STATS */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.stats-ribbon {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 170px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.stat-icon {
    font-size: 24px;
    padding: 8px;
    background: var(--bg-surface-elevated);
    border-radius: var(--radius-md);
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-warning .stat-value { color: var(--warning-text); }
.stat-danger .stat-value { color: var(--danger); }

.topbar-actions {
    display: flex;
    gap: 12px;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--border-color);
}

.btn-gemini {
    background: var(--gemini-gradient);
    color: #ffffff;
    box-shadow: 0 4px 16px var(--gemini-glow);
}
.btn-gemini:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--gemini-glow);
}

.btn-outline-gemini {
    background: var(--bg-surface);
    border: 1px solid rgba(143, 148, 251, 0.4);
    color: #a29bfe;
}
.btn-outline-gemini:hover {
    background: var(--bg-surface-elevated);
    border-color: #a29bfe;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-surface-elevated);
}

.btn-block {
    width: 100%;
}

/* FILTRES & BARRE DE RECHERCHE */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: var(--bg-surface);
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    flex: 1;
    min-width: 240px;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 100%;
    font-family: inherit;
    font-size: 14px;
}

.location-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-surface-elevated);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.chip:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.chip.active {
    background: var(--primary-light);
    color: #a29bfe;
    border-color: var(--primary);
}

.sort-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.sort-selector select {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    outline: none;
}

/* GRILLE DES PRODUITS */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.product-image-container {
    height: 140px;
    background: var(--bg-surface-elevated);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-placeholder-icon {
    font-size: 48px;
    opacity: 0.6;
}

.badge-expiration {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(8px);
}

.badge-expired {
    background: rgba(255, 71, 87, 0.9);
    color: white;
}

.badge-urgent {
    background: rgba(253, 203, 110, 0.95);
    color: #2d3436;
}

.badge-fresh {
    background: rgba(0, 184, 148, 0.9);
    color: white;
}

.product-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.product-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.product-location {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface-elevated);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.product-nutri {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-surface-elevated);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.product-quantity {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.btn-consume {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(255, 71, 87, 0.3);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-consume:hover {
    background: var(--danger);
    color: white;
}

/* GEMINI RECIPES VIEW */
.gemini-hero {
    background: linear-gradient(135deg, rgba(78, 84, 200, 0.2) 0%, rgba(143, 148, 251, 0.1) 100%);
    border: 1px solid rgba(143, 148, 251, 0.3);
    border-radius: var(--radius-xl);
    padding: 36px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 28px;
    backdrop-filter: blur(10px);
}

.hero-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: rgba(143, 148, 251, 0.25);
    color: #a29bfe;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
}

.gemini-hero-content h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 10px;
}

.gemini-hero-content p {
    color: var(--text-secondary);
    max-width: 580px;
    margin-bottom: 24px;
}

.gemini-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.badge-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 30px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.badge-title {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    display: block;
}

.badge-count {
    font-size: 42px;
    font-weight: 800;
    color: var(--warning-text);
    line-height: 1.1;
    margin: 6px 0;
}

.badge-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

.prompt-preview-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 28px;
}

.prompt-preview-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.prompt-text {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

.ia-result-box {
    background: var(--bg-surface);
    border: 1px solid rgba(143, 148, 251, 0.4);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.15);
}

.markdown-body {
    white-space: pre-line;
    line-height: 1.7;
    color: var(--text-primary);
    font-size: 15px;
}

/* HISTORIQUE TABLE */
.history-table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th, .data-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.badge-action-add {
    color: var(--success);
    font-weight: 700;
}
.badge-action-remove {
    color: var(--danger);
    font-weight: 700;
}

/* MEMBRES LAYOUT */
.members-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

.members-list-card, .members-add-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    margin-bottom: 8px;
}

/* MODAL & AUTH */
.auth-overlay, .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 12, 18, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.auth-card, .modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 36px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card {
    max-width: 580px;
}

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

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-light);
    color: #a29bfe;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-weight: 700;
    margin-bottom: 16px;
}

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

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input, .form-group select {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.nutrition-accordion {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 26px;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

/* TOASTS */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* UTILITIES */
.hidden { display: none !important; }
.app-view { display: none; }
.app-view.active { display: block; animation: fadeIn 0.25s ease; }

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

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        height: auto;
        position: relative;
    }
    .main-content {
        padding: 20px;
    }
    .gemini-hero {
        flex-direction: column;
    }
    .members-layout {
        grid-template-columns: 1fr;
    }
}
