/* =============================================
   Budget App - Green Finance Theme
   ============================================= */

:root {
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-200: #bbf7d0;
    --green-300: #86efac;
    --green-400: #4ade80;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --green-700: #15803d;
    --green-800: #166534;
    --green-900: #14532d;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --red-50: #fef2f2;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --red-700: #b91c1c;

    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--green-700); text-decoration: none; }
a:hover { color: var(--green-800); }
img { max-width: 100%; height: auto; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; width: 100%; }
.container-sm { max-width: 500px; margin: 0 auto; padding: 0 1rem; width: 100%; }

/* =============================================
   Header
   ============================================= */
.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.logo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--green-800);
}
.logo-link:hover { color: var(--green-700); }
.site-logo-img { height: 36px; width: auto; }
.site-title { white-space: nowrap; }

.main-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--green-50); color: var(--green-700); }
.nav-link.active { background: var(--green-100); color: var(--green-800); }
.nav-admin { color: var(--green-700); }
.nav-logout { color: var(--red-600); }
.nav-logout:hover { background: var(--red-50); color: var(--red-700); }

.lang-switch { display: flex; gap: 2px; margin-right: 0.5rem; }
.lang-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 4px;
    color: var(--gray-500);
    transition: all var(--transition);
}
.lang-btn:hover { color: var(--green-700); background: var(--green-50); }
.lang-btn.active { background: var(--green-700); color: var(--white); }

/* Mobile menu */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}
.mobile-menu-toggle span {
    width: 24px; height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: all var(--transition);
}

/* =============================================
   Main content
   ============================================= */
.main-content { flex: 1; padding: 2rem 0; }

/* =============================================
   Cards
   ============================================= */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gray-800);
}

/* =============================================
   Stat cards (balance, min, max)
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--green-700);
}
.stat-value.negative { color: var(--red-600); }
.stat-card.stat-current { border-top: 3px solid var(--green-500); }
.stat-card.stat-min { border-top: 3px solid var(--red-500); }
.stat-card.stat-max { border-top: 3px solid var(--green-400); }

/* =============================================
   Buttons
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.4;
    white-space: nowrap;
}
.btn-primary { background: var(--green-600); color: var(--white); }
.btn-primary:hover { background: var(--green-700); color: var(--white); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger { background: var(--red-600); color: var(--white); }
.btn-danger:hover { background: var(--red-700); color: var(--white); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--green-600);
    color: var(--green-700);
}
.btn-outline:hover { background: var(--green-50); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Icon buttons (edit, delete, clone) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1rem;
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-icon.btn-icon-edit:hover { color: var(--green-700); background: var(--green-50); }
.btn-icon.btn-icon-delete:hover { color: var(--red-600); background: var(--red-50); }
.btn-icon.btn-icon-clone:hover { color: var(--green-600); background: var(--green-50); }

/* =============================================
   Forms
   ============================================= */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.3rem;
}
.form-input, .form-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}
.form-input::placeholder { color: var(--gray-400); }
.form-hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.2rem; }
.form-error { font-size: 0.8rem; color: var(--red-600); margin-top: 0.2rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-inline { display: flex; gap: 0.5rem; align-items: end; }

/* Honeypot */
.hp-field { position: absolute; left: -9999px; opacity: 0; height: 0; }

/* Checkbox */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.form-check input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: checkbox;
    display: inline-block;
    margin-top: 0.3rem;
    accent-color: var(--green-600);
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    opacity: 1;
    position: static;
}

/* =============================================
   Budget table
   ============================================= */
.budget-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.budget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.budget-table th {
    background: var(--green-50);
    color: var(--green-800);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 0.5rem;
    border-bottom: 2px solid var(--green-200);
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.budget-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.budget-table tr:hover { background: var(--gray-50); }
.budget-table tr.row-past { opacity: 0.5; }
.budget-table tr.row-past:hover { opacity: 0.75; }
.budget-table tr.row-today { background: var(--green-50); font-weight: 600; }

.col-date { white-space: nowrap; width: 110px; }
.col-desc { min-width: 150px; }
.col-amount { text-align: right; white-space: nowrap; width: 120px; font-weight: 600; }
.col-balance { text-align: right; white-space: nowrap; width: 120px; font-weight: 700; }
.col-actions { text-align: center; white-space: nowrap; width: 110px; }

.amount-positive { color: var(--green-700); }
.amount-negative { color: var(--red-600); }
.balance-negative { color: var(--red-600); }

/* =============================================
   Account tabs
   ============================================= */
.account-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0;
}
.account-tab {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-500);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all var(--transition);
}
.account-tab:hover { color: var(--green-700); }
.account-tab.active {
    color: var(--green-700);
    border-bottom-color: var(--green-600);
}

/* =============================================
   Modal
   ============================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    background: none; border: none;
    font-size: 1.5rem; color: var(--gray-400);
    cursor: pointer; padding: 0.25rem;
}
.modal-close:hover { color: var(--gray-700); }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }

/* =============================================
   Flash messages
   ============================================= */
.flash {
    padding: 0.75rem 1rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
}
.flash-success { background: var(--green-100); color: var(--green-800); }
.flash-error { background: var(--red-50); color: var(--red-700); }
.flash-close {
    background: none; border: none;
    font-size: 1.25rem; cursor: pointer;
    color: inherit; opacity: 0.7;
    padding: 0 0.5rem;
}

/* =============================================
   Cookie banner (Loi 25)
   ============================================= */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--gray-900);
    color: var(--gray-100);
    z-index: 300;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}
.cookie-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}
.cookie-inner p { font-size: 0.85rem; flex: 1; min-width: 200px; }
.cookie-actions { display: flex; align-items: center; gap: 1rem; }
.cookie-link { color: var(--green-300); font-size: 0.85rem; }

/* =============================================
   Landing page
   ============================================= */
.hero {
    text-align: center;
    padding: 4rem 1rem;
    background: linear-gradient(135deg, var(--green-50) 0%, var(--white) 50%, var(--green-50) 100%);
}
.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--green-800);
    margin-bottom: 1rem;
    line-height: 1.2;
}
.hero-subtitle {
    font-size: 1.15rem;
    color: var(--gray-600);
    max-width: 600px;
    margin: 0 auto 2rem;
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0 3rem;
}
.feature-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
}
.feature-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.feature-icon {
    width: 56px; height: 56px;
    margin: 0 auto 1rem;
    background: var(--green-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.feature-title { font-weight: 700; margin-bottom: 0.5rem; color: var(--gray-800); }
.feature-desc { font-size: 0.9rem; color: var(--gray-500); }

/* =============================================
   Auth pages
   ============================================= */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    padding: 2rem 1rem;
}
.auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
}
.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--green-800);
}
.auth-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* =============================================
   Admin
   ============================================= */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; min-height: 60vh; }
.admin-sidebar {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    height: fit-content;
    position: sticky;
    top: 80px;
}
.admin-nav-link {
    display: block;
    padding: 0.6rem 1.25rem;
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}
.admin-nav-link:hover { background: var(--green-50); color: var(--green-700); }
.admin-nav-link.active { background: var(--green-100); color: var(--green-800); font-weight: 700; }
.admin-content { min-width: 0; }

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.users-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.users-table th {
    text-align: left; padding: 0.75rem 0.5rem;
    border-bottom: 2px solid var(--gray-200);
    font-size: 0.8rem; text-transform: uppercase;
    color: var(--gray-500); letter-spacing: 0.05em;
}
.users-table td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--gray-100); }
.users-table tr:hover { background: var(--gray-50); }
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-admin { background: var(--green-100); color: var(--green-800); }
.badge-inactive { background: var(--red-50); color: var(--red-700); }

/* =============================================
   Footer
   ============================================= */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 1.5rem 0;
    margin-top: auto;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--gray-500);
    flex-wrap: wrap;
    gap: 0.5rem;
}
.footer-links { display: flex; gap: 1rem; }
.footer-links a { color: var(--gray-500); }
.footer-links a:hover { color: var(--green-700); }

/* =============================================
   Sharing page
   ============================================= */
.share-list { list-style: none; }
.share-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
    gap: 0.5rem;
}
.share-info { display: flex; flex-direction: column; }
.share-name { font-weight: 600; color: var(--gray-800); }
.share-email { font-size: 0.8rem; color: var(--gray-500); }
.share-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-weight: 600;
}
.share-badge.readonly { background: var(--gray-100); color: var(--gray-600); }
.share-badge.readwrite { background: var(--green-100); color: var(--green-700); }

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .mobile-menu-toggle { display: flex; }
    .main-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--gray-200);
        box-shadow: var(--shadow-md);
    }
    .main-nav.open { display: flex; }
    .main-nav .nav-link, .main-nav .btn { width: 100%; text-align: center; }
    .lang-switch { justify-content: center; margin-right: 0; margin-bottom: 0.5rem; }

    .hero-title { font-size: 1.75rem; }
    .hero-subtitle { font-size: 1rem; }
    .hero { padding: 2.5rem 1rem; }

    .stats-grid { grid-template-columns: 1fr; }
    .stat-value { font-size: 1.25rem; }

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

    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; }

    .budget-table { font-size: 0.8rem; }
    .budget-table th, .budget-table td { padding: 0.5rem 0.3rem; }
    .col-date { width: auto; }
    .col-amount, .col-balance { width: auto; }

    .btn-icon { width: 28px; height: 28px; font-size: 0.85rem; }

    .cookie-inner { flex-direction: column; text-align: center; }

    .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
    .header-inner { height: 56px; }
    .site-title { font-size: 1rem; }
    .hero-title { font-size: 1.5rem; }
    .card { padding: 1rem; }
    .auth-card { padding: 1.25rem; }
    .modal { padding: 1rem; }
}

/* =============================================
   Utilities
   ============================================= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-none { display: none; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
