/* ============================================================
   SARL ESQUIROL - TMS Transport Management System
   Fichier CSS principal
   ============================================================ */

:root {
    --primary: #0f172a;
    --secondary: #dc2626;
    --accent: #f59e0b;
    --success: #22c55e;
    --info: #3b82f6;
    --bg-light: #f1f5f9;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-light);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding-bottom: 80px;
}

/* ===== NAVBAR ===== */
.navbar-esquirol {
    background-color: var(--primary);
    border-bottom: 4px solid var(--secondary);
    padding: 6px 0;
}

.logo-esquirol-svg {
    height: 38px;
    width: auto;
    margin-right: 10px;
}

.company-tagline {
    font-size: 11px;
    letter-spacing: 1px;
    color: #94a3b8;
}

/* ===== SIDEBAR ===== */
.sidebar {
    background-color: var(--primary);
    min-height: calc(100vh - 60px);
    color: white;
    padding: 15px 10px;
}

.sidebar .nav-link {
    color: #94a3b8;
    transition: all 0.3s;
    border-radius: 8px;
    margin-bottom: 3px;
    cursor: pointer;
    padding: 10px 15px;
    font-size: 14px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: white;
    background-color: rgba(220, 38, 38, 0.2);
    border-left: 4px solid var(--secondary);
}

.sidebar .nav-link i {
    width: 22px;
    text-align: center;
}

/* ===== STAT CARDS ===== */
.stat-card {
    border-radius: 12px;
    padding: 18px;
    color: white;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-card .stat-number {
    font-size: 28px;
    font-weight: 700;
}

.stat-card .stat-label {
    font-size: 13px;
    opacity: 0.85;
}

/* ===== KPI CARDS ===== */
.card-kpi {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    background: white;
    transition: transform 0.2s;
}

.card-kpi:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* ===== HOME BUTTONS ===== */
.home-btn {
    transition: all 0.3s;
    border: none;
    border-radius: 16px;
    height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.home-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.25);
    background: #1a2744 !important;
}

.home-btn .btn-text {
    color: white !important;
    font-weight: 600;
}

/* ===== TABLES ===== */
.table-tms {
    font-size: 13px;
}

.table-tms th {
    background: var(--primary) !important;
    color: white;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 8px;
}

.table-tms td {
    vertical-align: middle;
    padding: 10px 8px;
}

.table-tms tr:hover {
    background-color: #f1f5f9;
}

.table-tms .checkbox-col {
    width: 40px;
    text-align: center;
}

.table-tms .checkbox-col input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ===== BADGES ===== */
.flux-badge {
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.flux-dist {
    background: #dbeafe;
    color: #1e40af;
}
.flux-tpf {
    background: #d1fae5;
    color: #065f46;
}
.flux-temb {
    background: #fef3c7;
    color: #92400e;
}
.flux-tmp {
    background: #fce4ec;
    color: #b71c1c;
}
.flux-rpal {
    background: #ede9fe;
    color: #5b21b6;
}
.flux-rcli {
    background: #fecaca;
    color: #991b1b;
}

.status-badge {
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

.status-attente {
    background: #fef3c7;
    color: #92400e;
}
.status-pret {
    background: #dbeafe;
    color: #1e40af;
}
.status-livre {
    background: #d1fae5;
    color: #065f46;
}

.wilaya-badge {
    font-size: 10px;
    padding: 2px 10px;
    border-radius: 12px;
    background: #dbeafe;
    color: #1e40af;
}

.site-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e2e8f0;
    color: #1e293b;
}

.tarif-type-badge {
    font-size: 10px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.tarif-type-distribution {
    background: #dbeafe;
    color: #1e40af;
}
.tarif-type-transfert {
    background: #fef3c7;
    color: #92400e;
}

.vehicule-tarif-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e2e8f0;
    color: #1e293b;
}

/* ===== BUTTONS ===== */
.btn-pret {
    background: #f59e0b;
    color: white;
}
.btn-pret:hover {
    background: #d97706;
    color: white;
}

.btn-livrer {
    background: #22c55e;
    color: white;
}
.btn-livrer:hover {
    background: #16a34a;
    color: white;
}

/* ===== ACTION COLUMN ===== */
.action-column {
    min-width: 120px;
}

.action-column .btn-group {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.action-column .btn {
    padding: 2px 8px;
    font-size: 12px;
}

/* ===== MODULE TOOLBAR ===== */
.module-toolbar {
    background: white;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ===== FILTERS ===== */
.filter-section {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.date-filter-input {
    max-width: 180px;
}

.filter-date-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-date-group .form-control {
    width: auto;
    min-width: 150px;
}

/* ===== TARIF INFO ===== */
.tarif-info {
    font-size: 12px;
    margin-top: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    background: #f8f9fa;
    border-left: 3px solid #6c757d;
}

.tarif-info.success {
    background: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.tarif-info.error {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.tarif-info.warning {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.tarif-info.info {
    background: #d1ecf1;
    border-left-color: #17a2b8;
    color: #0c5464;
}

/* ===== COST COLUMN ===== */
.cost-column {
    display: table-cell;
}

.cost-column-hidden {
    display: none !important;
}

/* ===== FIREBASE STATUS ===== */
.firebase-status {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
}

.firebase-online {
    background: #d4edda;
    color: #155724;
}
.firebase-offline {
    background: #f8d7da;
    color: #721c24;
}
.firebase-sync {
    background: #fff3cd;
    color: #856404;
}

/* ===== USER INFO ===== */
.user-site-info {
    font-size: 12px;
    color: #94a3b8;
}

/* ===== FOOTER ===== */
.app-footer {
    background: var(--primary);
    color: #94a3b8;
    padding: 15px 0;
    margin-top: 30px;
    border-top: 2px solid var(--secondary);
    text-align: center;
    font-size: 13px;
}

.app-footer strong {
    color: white;
}

.app-footer .credit {
    color: var(--secondary);
    font-weight: 600;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast-custom {
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    margin-bottom: 10px;
    min-width: 250px;
    border-left: 4px solid var(--success);
    animation: slideInRight 0.4s ease;
}

.toast-custom.error {
    border-left-color: var(--secondary);
}

.toast-custom.warning {
    border-left-color: var(--accent);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .date-filter-input {
        max-width: 100%;
    }
    .filter-date-group .form-control {
        width: 100%;
        min-width: unset;
    }
    .login-help {
        display: block !important;
    }
}

/* ===== PRINT ===== */
@media print {
    .sidebar,
    .navbar-esquirol,
    .no-print {
        display: none !important;
    }
    .col-md-9 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
    body {
        background: white;
        padding-bottom: 0;
    }
}

/* ===== MODAL ===== */
.modal-header .btn-close-white {
    filter: invert(1);
}