:root {
  --primary: #2c2cd1;
  --primary-hover: #1a1a9f;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --background: #f3f4f6;
  --surface: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --sidebar-width: 260px;
  --header-height: 64px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--background); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; }

/* Layout */
.app-container { display: flex; min-height: 100vh; }
.main-content { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.views-container { padding: 1.5rem; flex: 1; overflow-y: auto; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); background: var(--surface); border-right: 1px solid var(--border); position: fixed; height: 100vh; display: flex; flex-direction: column; z-index: 50; }
.sidebar-header { height: var(--header-height); display: flex; align-items: center; padding: 0 1.5rem; border-bottom: 1px solid var(--border); }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--primary); display: flex; align-items: center; gap: 0.5rem; }
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 1.5rem; color: var(--text-muted); font-weight: 500; transition: 0.2s; }
.nav-item:hover, .nav-item.active { color: var(--primary); background: #eff6ff; border-right: 3px solid var(--primary); }
.nav-item i { font-size: 1.25rem; }
.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 0.5rem; }
.user-info { flex: 1; display: flex; align-items: center; gap: 0.5rem; overflow: hidden; }
.user-info img { width: 32px; height: 32px; border-radius: 50%; }
.user-info h4 { margin: 0; font-size: 0.9rem; white-space: nowrap; }
.user-info small { font-size: 0.75rem; color: var(--text-muted); }

/* Topbar */
.topbar { height: var(--header-height); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; position: sticky; top: 0; z-index: 40; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text); }
#pageTitle { margin: 0; font-size: 1.25rem; }

/* Cards */
.card { background: var(--surface); border-radius: 0.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid var(--border); margin-bottom: 1.5rem; }
.card-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.card-header h3 { margin: 0; font-size: 1.1rem; }
.card-body { padding: 1.5rem; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.stat-card { background: var(--surface); padding: 1.5rem; border-radius: 0.5rem; border: 1px solid var(--border); display: flex; align-items: center; gap: 1rem; }
.icon-box { width: 48px; height: 48px; border-radius: 0.5rem; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.icon-box.blue { background: #eff6ff; color: #3b82f6; }
.icon-box.orange { background: #fff7ed; color: #f97316; }
.icon-box.green { background: #f0fdf4; color: #22c55e; }
.icon-box.purple { background: #faf5ff; color: #a855f7; }
.stat-info h3 { margin: 0 0 0.25rem 0; font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.stat-info .value { margin: 0; font-size: 1.5rem; font-weight: 700; }

/* Tables */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #f9fafb; font-weight: 600; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:last-child td { border-bottom: none; }

/* Forms & Buttons */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }
.form-control { width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 0.375rem; font-size: 0.95rem; transition: border-color 0.2s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(44, 44, 209, 0.1); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.6rem 1.2rem; border-radius: 0.375rem; font-weight: 500; cursor: pointer; border: none; transition: 0.2s; font-size: 0.95rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: #f9fafb; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.icon-btn { background: none; border: none; cursor: pointer; padding: 0.4rem; border-radius: 0.25rem; color: var(--text-muted); transition: 0.2s; font-size: 1.1rem; }
.icon-btn:hover { background: #f3f4f6; color: var(--text); }
.w-100 { width: 100%; }
.btn-block { width: 100%; }
.input-group {
    display: flex;
    align-items: center;
}
.input-group .input-group-addon {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    background-color: #f9fafb;
    border-right: 0;
    border-radius: 0.375rem 0 0 0.375rem;
}
.input-group .form-control { border-radius: 0 0.375rem 0.375rem 0; }
.input-group-icon {
    position: relative;
}
.input-group-icon > i:first-child {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    z-index: 1;
}
.input-group-icon .form-control {
    padding-left: 2.5rem;
}


/* Badges */
.badge { display: inline-block; padding: 0.25rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.badge.delivered { background: #dcfce7; color: #166534; }
.badge.inprogress { background: #dbeafe; color: #1e40af; }
.badge.ready { background: #ffedd5; color: #9a3412; }
.badge.partial { background: #fee2e2; color: #991b1b; }

/* Mobile & Responsive */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); height: 60px; z-index: 40; justify-content: space-around; align-items: center; }
.bottom-item { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.75rem; color: var(--text-muted); padding: 0.5rem; }
.bottom-item.active { color: var(--primary); }
.bottom-item i { font-size: 1.25rem; }

.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; opacity: 0; pointer-events: none; transition: 0.3s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer-content { position: absolute; top: 0; left: 0; bottom: 0; width: 280px; background: var(--surface); transform: translateX(-100%); transition: 0.3s; display: flex; flex-direction: column; }
.drawer-overlay.open .drawer-content { transform: translateX(0); }
.drawer-header { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.drawer-links { padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.drawer-links a { padding: 0.75rem; border-radius: 0.375rem; font-weight: 500; }
.drawer-links a:hover { background: #f3f4f6; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; margin-bottom: 60px; }
  .menu-toggle { display: block; }
  .bottom-nav { display: flex; }
  .topbar { padding: 0 1rem; }
  .views-container { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
}

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: 0.2s; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-container { background: var(--surface); width: 100%; max-width: 500px; border-radius: 0.5rem; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); max-height: 90vh; display: flex; flex-direction: column; margin: 1rem; }
.modal-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; background: #f9fafb; border-radius: 0 0 0.5rem 0.5rem; }

/* Utilities */
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.col { flex: 1; }
.col-12 { width: 100%; }
.col-md-6 { flex: 0 0 50%; }
.col-md-4 { flex: 0 0 33.33%; }
.col-md-8 { flex: 0 0 66.66%; }
@media (max-width: 768px) { .col-md-6, .col-md-4, .col-md-8 { flex: 0 0 100%; } }

/* Services Selection List */
.services-selection-list { border: 1px solid var(--border); border-radius: 0.375rem; max-height: 200px; overflow-y: auto; }
.service-option { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.service-option:last-child { border-bottom: none; }
.service-option label { margin: 0; display: flex; align-items: center; gap: 0.5rem; cursor: pointer; flex: 1; }
.service-price { font-weight: 600; color: var(--text-muted); font-size: 0.9rem; }

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Auth & Login Pages */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--background);
    padding: 1rem;
}
.login-card {
    background: var(--surface);
    padding: 2rem 2.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out forwards;
}
.login-card form {
    min-height: 340px; /* Hauteur fixe pour éviter les sauts entre les étapes */
    transition: min-height 0.3s ease;
}
.form-step { display: none; }
.form-step.active { display: block; animation: fadeIn 0.3s ease-in-out; }
.login-card .logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
}
.login-card .logo h2 {
    margin: 0.5rem 0 0 0;
}
.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}
.login-footer a {
    color: var(--primary);
}
.login-footer a:hover {
    text-decoration: underline;
}
.login-register-link {
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
}
.login-register-link a {
    color: var(--primary);
    font-weight: 500;
}
.alert { padding: 0.75rem 1rem; border-radius: 0.375rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert.error { background-color: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.alert.success { background-color: #dcfce7; color: #166534; border-color: #bbf7d0; }

/* Login Checkbox */
.checkbox-group { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-group input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }
.checkbox-group label { margin: 0; cursor: pointer; font-weight: normal; }

/* Static pages (Terms, Privacy, etc.) */
.static-page-card {
    max-width: 800px;
    margin: 2rem auto;
}
.static-page-card h1 {
    margin-top: 0;
    font-size: 1.8rem;
}
.static-page-card h2 {
    margin-top: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    font-size: 1.4rem;
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1f2937;
    color: white;
    padding: 1rem;
    z-index: 9999;
    display: none; /* Masqué par défaut, affiché via JS */
    box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.1);
}
.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.cookie-text { flex: 1; font-size: 0.9rem; }
.cookie-text a { color: #60a5fa; text-decoration: underline; }
.cookie-buttons { display: flex; gap: 0.5rem; }