/**
 * Tracking Caisses - Design System
 * Base copiee depuis Agenda, etendue pour Tracking
 */

:root {
    --color-primary: #3B82F6;
    --color-primary-hover: #2563EB;
    --color-primary-light: #DBEAFE;
    --color-primary-dark: #1D4ED8;

    --color-success: #10b981;
    --color-success-light: #d1fae5;
    --color-warning: #f59e0b;
    --color-warning-light: #fef3c7;
    --color-danger: #ef4444;
    --color-danger-light: #fee2e2;
    --color-info: #3b82f6;
    --color-info-light: #dbeafe;

    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;

    --sidebar-width: 220px;
    --sidebar-bg: #1e293b;
    --sidebar-bg-hover: #334155;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-accent: #3B82F6;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;

    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.5;
}

/* ============================================
   Layout
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.sidebar-header {
    padding: var(--space-5) var(--space-4);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--sidebar-text-active);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    text-decoration: none;
}

.sidebar-brand:hover { opacity: 0.9; color: var(--sidebar-text-active); }
.sidebar-brand i { font-size: 1.5rem; color: var(--sidebar-accent); }

.sidebar-nav {
    flex: 1;
    padding: var(--space-4) 0;
    overflow-y: auto;
}

.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-item { margin: var(--space-1) 0; }

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    margin: 0 var(--space-2);
    color: var(--sidebar-text);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-link i { font-size: 1.25rem; width: 24px; text-align: center; }
.nav-link:hover { background-color: var(--sidebar-bg-hover); color: var(--sidebar-text-active); }
.nav-link.active { background-color: var(--sidebar-accent); color: var(--sidebar-text-active); }

.nav-section-title {
    list-style: none;
    padding: var(--space-3) var(--space-4);
    margin-top: var(--space-2);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text);
    opacity: 0.6;
}

.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================
   Mobile Menu
   ============================================ */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: var(--space-3);
    left: var(--space-3);
    width: 40px;
    height: 40px;
    background-color: var(--sidebar-bg);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active { display: block; }

/* ============================================
   Page Layout
   ============================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.page-header h1 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    margin: 0;
}

.page-body {
    padding: var(--space-5) var(--space-6);
}

/* ============================================
   Cards
   ============================================ */
.card-custom {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-custom .card-header-custom {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    font-weight: var(--font-weight-semibold);
}

.card-custom .card-body-custom {
    padding: var(--space-5);
}

/* ============================================
   Stat Cards (Dashboard)
   ============================================ */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-card .stat-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-1);
}

.stat-card .stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.stat-card.stat-success { border-left: 4px solid var(--color-success); }
.stat-card.stat-danger { border-left: 4px solid var(--color-danger); }
.stat-card.stat-warning { border-left: 4px solid var(--color-warning); }
.stat-card.stat-info { border-left: 4px solid var(--color-info); }

/* ============================================
   Scanner Input
   ============================================ */
.scan-input-group .form-control {
    font-size: var(--font-size-lg);
    padding: var(--space-3) var(--space-4);
}

.scan-input-group .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
}

.input-flash {
    background-color: var(--color-success-light) !important;
    transition: background-color 0.5s ease;
}

/* ============================================
   Scan Counter (above scanned list)
   ============================================ */
.scan-counter {
    text-align: center;
    margin-bottom: var(--space-3);
    padding: var(--space-2) 0;
}

/* ============================================
   Scanned Items List
   ============================================ */
.caisse-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-1);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.caisse-item.duplicate {
    border-color: var(--color-danger);
    background: var(--color-danger-light);
}

.caisse-code {
    font-weight: var(--font-weight-semibold);
    font-family: 'Courier New', monospace;
    font-size: var(--font-size-sm);
}

.remove-btn {
    cursor: pointer;
    color: var(--color-danger);
    font-size: var(--font-size-lg);
    padding: var(--space-1);
    background: none;
    border: none;
}

.remove-btn:hover { opacity: 0.7; }

/* ============================================
   Alert Box (scanner duplicates)
   ============================================ */
.alert-box {
    display: none;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background-color: var(--color-warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
    margin-bottom: var(--space-3);
}

/* ============================================
   Status Badges
   ============================================ */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
}

.status-fournil {
    background-color: var(--color-success-light);
    color: #065f46;
}

.status-client {
    background-color: var(--color-danger-light);
    color: #991b1b;
}

.status-inconnue {
    background-color: var(--color-warning-light);
    color: #92400e;
}

/* ============================================
   Scan Result Cards (statut_caisse)
   ============================================ */
.scan-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
}

.scan-item {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.scan-item.fournil { background-color: var(--color-success-light); border-color: #a7f3d0; }
.scan-item.client { background-color: var(--color-danger-light); border-color: #fecaca; }
.scan-item.inconnue { background-color: var(--color-warning-light); border-color: #fde68a; }

/* ============================================
   Movement Rows
   ============================================ */
.mouvement-depart { background-color: var(--color-danger-light) !important; }
.mouvement-retour { background-color: var(--color-success-light) !important; }

.sans-retour {
    color: var(--color-danger);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
}

/* ============================================
   Admin Sections (accordion)
   ============================================ */
.admin-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-4);
    overflow: hidden;
}

.admin-section-header {
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: var(--font-weight-semibold);
    transition: background-color var(--transition-fast);
}

.admin-section-header:hover { background-color: var(--color-bg); }

.admin-section-body {
    padding: 0 var(--space-5) var(--space-5);
    display: none;
}

.admin-section-body.show { display: block; }

/* ============================================
   Quick Action Cards (Dashboard)
   ============================================ */
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--color-text);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.quick-action:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    color: var(--color-primary);
    transform: translateY(-2px);
}

.quick-action i { font-size: 1.75rem; }
.quick-action span { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); }

/* ============================================
   Login Page
   ============================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: var(--space-4);
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-8);
    width: 100%;
    max-width: 420px;
}

.login-brand {
    text-align: center;
    margin-bottom: var(--space-6);
}

.login-brand i {
    font-size: 3rem;
    color: var(--color-primary);
    display: block;
    margin-bottom: var(--space-3);
}

.login-brand h1 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    margin: 0;
    color: var(--color-text);
}

.login-brand p {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-top: var(--space-1);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .main-content {
        margin-left: 0;
    }

    .page-header {
        padding: var(--space-4);
        padding-top: 56px;
    }

    .page-body {
        padding: var(--space-3);
    }

    .scan-results {
        grid-template-columns: 1fr;
    }
}
