/* =============================================================================
   TIKOO DELIVERY - Styles principaux
   Mobile-first PWA | Bootstrap 5 overrides + custom
   ============================================================================= */

/* --- Variables CSS --- */
:root {
    --tikoo-orange:     #f97316;
    --tikoo-orange-dark:#ea6800;
    --tikoo-dark:       #1a1a2e;
    --tikoo-dark2:      #16213e;
    --tikoo-blue:       #0f3460;
    --tikoo-green:      #10b981;
    --tikoo-red:        #ef4444;
    --tikoo-yellow:     #f59e0b;
    --tikoo-gray:       #6b7280;
    --tikoo-light:      #f8fafc;
    --tikoo-white:      #ffffff;
    --sidebar-width:    250px;
    --header-height:    60px;
    --radius:           12px;
    --shadow:           0 2px 15px rgba(0,0,0,.08);
    --shadow-md:        0 4px 25px rgba(0,0,0,.12);
    --transition:       all .2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--tikoo-light);
    color: #1e293b;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--tikoo-orange); text-decoration: none; }
a:hover { color: var(--tikoo-orange-dark); }

/* --- Scrollbar custom --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--tikoo-orange); border-radius: 3px; }

/* =============================================================================
   HEADER / TOPBAR
   ============================================================================= */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--tikoo-dark);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 1030;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
}

.topbar .brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--tikoo-orange);
    letter-spacing: -0.5px;
}

.topbar .brand span { color: var(--tikoo-white); }

.btn-sidebar-toggle {
    background: none;
    border: none;
    color: var(--tikoo-white);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-sidebar-toggle:hover { background: rgba(255,255,255,.1); }

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Badge notifications */
.notif-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--tikoo-white);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.notif-btn:hover { background: rgba(255,255,255,.1); }

.notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--tikoo-red);
    color: white;
    font-size: .65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--tikoo-orange);
    cursor: pointer;
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--tikoo-dark2);
    overflow-y: auto;
    z-index: 1020;
    transition: transform .3s ease;
    padding-bottom: 80px;
}

.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-menu { list-style: none; padding: 16px 0; margin: 0; }

.sidebar-section-title {
    font-size: .7rem;
    font-weight: 700;
    color: var(--tikoo-gray);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 20px 6px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #94a3b8;
    transition: var(--transition);
    font-size: .92rem;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    color: var(--tikoo-white);
    background: rgba(249,115,22,.12);
    border-left-color: var(--tikoo-orange);
}

.sidebar-menu a .icon { font-size: 1.1rem; width: 20px; text-align: center; }

/* Overlay sidebar mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1010;
}

.sidebar-overlay.active { display: block; }

/* =============================================================================
   MAIN CONTENT
   ============================================================================= */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 24px;
    min-height: calc(100vh - var(--header-height));
    transition: margin-left .3s ease;
}

.main-content.full { margin-left: 0; }

/* =============================================================================
   CARDS
   ============================================================================= */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    background: var(--tikoo-white);
    border-bottom: 1px solid #f1f5f9;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding: 16px 20px;
    font-weight: 600;
}

.card-body { padding: 20px; }

/* --- Stat Cards (tableau de bord) --- */
.stat-card {
    border-radius: var(--radius);
    padding: 20px;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -20px; right: -20px;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
}

.stat-card .stat-icon {
    font-size: 2rem;
    opacity: .8;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: .82rem;
    opacity: .85;
    font-weight: 500;
}

.stat-card.orange  { background: linear-gradient(135deg, #f97316, #ea580c); }
.stat-card.green   { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.blue    { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-card.purple  { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-card.red     { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card.yellow  { background: linear-gradient(135deg, #f59e0b, #d97706); }

/* =============================================================================
   BOUTONS
   ============================================================================= */
.btn-tikoo {
    background: var(--tikoo-orange);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
}

.btn-tikoo:hover {
    background: var(--tikoo-orange-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249,115,22,.35);
}

.btn-tikoo:active { transform: translateY(0); }

.btn-tikoo-outline {
    background: transparent;
    color: var(--tikoo-orange);
    border: 2px solid var(--tikoo-orange);
    border-radius: 8px;
    padding: 8px 18px;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
}

.btn-tikoo-outline:hover {
    background: var(--tikoo-orange);
    color: white;
}

/* =============================================================================
   FORMULAIRES
   ============================================================================= */
.form-control, .form-select {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .94rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--tikoo-orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.15);
    outline: none;
}

.form-label { font-weight: 600; font-size: .88rem; color: #374151; margin-bottom: 5px; }

.input-group-text {
    background: var(--tikoo-light);
    border: 1.5px solid #e2e8f0;
    color: var(--tikoo-gray);
}

/* =============================================================================
   TABLES
   ============================================================================= */
.table-tikoo {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table-tikoo thead th {
    background: var(--tikoo-dark);
    color: white;
    padding: 13px 16px;
    font-size: .82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    border: none;
}

.table-tikoo tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: .9rem;
    vertical-align: middle;
}

.table-tikoo tbody tr:last-child td { border-bottom: none; }
.table-tikoo tbody tr:hover { background: #fafbfc; }

/* Responsive table */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* =============================================================================
   STATUTS / BADGES
   ============================================================================= */
.badge-statut { padding: 5px 11px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge-nouveau   { background: #f1f5f9; color: #475569; }
.badge-assigne   { background: #dbeafe; color: #1d4ed8; }
.badge-en_cours  { background: #fef3c7; color: #92400e; }
.badge-livre     { background: #d1fae5; color: #065f46; }
.badge-annule    { background: #fee2e2; color: #991b1b; }
.badge-reporte   { background: #ede9fe; color: #5b21b6; }
.badge-retourne  { background: #f3f4f6; color: #1f2937; }

/* =============================================================================
   PAGE TITRE
   ============================================================================= */
.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--tikoo-dark);
    margin: 0;
}

.breadcrumb-tikoo { font-size: .83rem; color: var(--tikoo-gray); }
.breadcrumb-tikoo a { color: var(--tikoo-orange); }

/* =============================================================================
   COMMANDE CARD (liste des commandes)
   ============================================================================= */
.commande-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid #e2e8f0;
    transition: var(--transition);
    cursor: pointer;
}

.commande-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.commande-card.statut-assigne   { border-left-color: #3b82f6; }
.commande-card.statut-en_cours  { border-left-color: var(--tikoo-yellow); }
.commande-card.statut-livre     { border-left-color: var(--tikoo-green); }
.commande-card.statut-annule    { border-left-color: var(--tikoo-red); }
.commande-card.statut-reporte   { border-left-color: #8b5cf6; }

.commande-code { font-size: .78rem; color: var(--tikoo-gray); font-weight: 500; }
.commande-client { font-size: 1rem; font-weight: 700; color: var(--tikoo-dark); }
.commande-adresse { font-size: .85rem; color: var(--tikoo-gray); }
.commande-montant { font-size: 1rem; font-weight: 700; color: var(--tikoo-orange); }

/* =============================================================================
   ALERTES
   ============================================================================= */
.alert { border-radius: var(--radius); border: none; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info    { background: #dbeafe; color: #1e40af; }

/* =============================================================================
   PAGINATION
   ============================================================================= */
.pagination-tikoo {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 20px 0;
    flex-wrap: wrap;
}

.pagination-tikoo a, .pagination-tikoo span {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 500;
    border: 1.5px solid #e2e8f0;
    color: var(--tikoo-dark);
    background: white;
    transition: var(--transition);
}

.pagination-tikoo a:hover { background: var(--tikoo-orange); color: white; border-color: var(--tikoo-orange); }
.pagination-tikoo .active { background: var(--tikoo-orange); color: white; border-color: var(--tikoo-orange); }
.pagination-tikoo .disabled { opacity: .5; pointer-events: none; }

/* =============================================================================
   SPINNER CHARGEMENT
   ============================================================================= */
.tikoo-spinner {
    display: inline-block;
    width: 24px; height: 24px;
    border: 3px solid rgba(249,115,22,.2);
    border-top-color: var(--tikoo-orange);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================================
   RECHERCHE / FILTRES
   ============================================================================= */
.filter-bar {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* =============================================================================
   EMPTY STATE
   ============================================================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--tikoo-gray);
}

.empty-state .empty-icon { font-size: 4rem; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: #374151; }
.empty-state p { font-size: .9rem; }

/* =============================================================================
   MODAL CUSTOM
   ============================================================================= */
.modal-content { border: none; border-radius: var(--radius); }
.modal-header { background: var(--tikoo-dark); color: white; border-radius: var(--radius) var(--radius) 0 0; }
.modal-header .btn-close { filter: invert(1); }

/* =============================================================================
   RESPONSIVE - DESKTOP (≥ 992px)
   ============================================================================= */
@media (min-width: 992px) {
    .sidebar-overlay { display: none !important; }
}

/* =============================================================================
   RESPONSIVE - TABLET (≥ 768px)
   ============================================================================= */
@media (min-width: 768px) {
    .main-content { padding: 28px 32px; }
}

/* =============================================================================
   RESPONSIVE - MOBILE (< 768px)
   ============================================================================= */
@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1040;
    }

    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0;
        padding: 12px;
    }

    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .stat-card .stat-icon  { font-size: 1.5rem; margin-bottom: 4px; }

    .page-title { margin-bottom: 14px; }
    .page-title h1 { font-size: 1.1rem; }

    /* Tables : scroll horizontal (plus fiable que data-label) */
    .table-tikoo-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
    .table-responsive  { -webkit-overflow-scrolling: touch; }
    .table-tikoo { min-width: 520px; font-size: .82rem; }
    .table-tikoo thead th { padding: 10px 12px; font-size: .75rem; }
    .table-tikoo tbody td { padding: 9px 12px; }

    /* Cards compact */
    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }

    /* Formulaires compacts */
    .form-control, .form-select {
        padding: 8px 12px;
        font-size: .92rem;
    }
    .form-label { font-size: .84rem; margin-bottom: 4px; }
    .input-group-text { padding: 8px 10px; }

    /* Boutons compacts */
    .btn-tikoo { padding: 9px 16px; font-size: .9rem; }

    /* Filter bar */
    .filter-bar { flex-direction: column; padding: 12px; gap: 8px; }
    .filter-bar > * { width: 100%; }

    /* Page title actions */
    .page-title .btn { font-size: .82rem; padding: 7px 12px; }

    /* Row gutters réduits */
    .row.g-3 { --bs-gutter-x: .75rem; --bs-gutter-y: .75rem; }
    .row.g-4 { --bs-gutter-x: 1rem;   --bs-gutter-y: 1rem;   }

    /* Badges & statuts */
    .badge-statut { padding: 4px 9px; font-size: .74rem; }

    /* Modals full-width bas d'écran */
    .modal-dialog { margin: auto 0 0; }
    .modal-content { border-radius: var(--radius) var(--radius) 0 0; }

    /* Alertes compactes */
    .alert { padding: 10px 14px; font-size: .88rem; }
}

/* =============================================================================
   PRINT
   ============================================================================= */
@media print {
    .sidebar, .topbar, .btn, .no-print { display: none !important; }
    .main-content { margin: 0 !important; padding: 20px !important; }
}
