/* SODAC Dashboard - Custom Styles */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --info-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --warning-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --danger-gradient: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    --dark-gradient: linear-gradient(135deg, #434343 0%, #000000 100%);
}

body {
    background: #f8f9fc;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Navigation moderne */
.sidebar {
    background: var(--dark-gradient);
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    min-height: 100vh;
}

.sidebar .navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    padding: 1.5rem 1rem;
    color: white !important;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 1rem 1.5rem;
    margin: 0.25rem 0.75rem;
    border-radius: 10px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.sidebar .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    transform: translateX(5px);
}

.sidebar .nav-link.active {
    background: var(--primary-gradient);
    color: white !important;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Cartes statistiques modernes */
.stat-card {
    border-radius: 12px;
    border: none;
    overflow: hidden;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    min-height: 140px;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
}

.stat-card.success::before {
    background: var(--success-gradient);
}

.stat-card.info::before {
    background: var(--info-gradient);
}

.stat-card.warning::before {
    background: var(--warning-gradient);
}

.stat-icon-bg {
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 4rem;
    opacity: 0.06;
    transform: rotate(-10deg);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: #6c757d;
}

.stat-badge {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* En-tete de page */
.page-header-modern {
    background: var(--primary-gradient);
    border-radius: 25px;
    padding: 3rem 2rem;
    margin-bottom: 3rem;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.page-header-modern::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.page-header-modern h1 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 1rem;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.page-header-modern p {
    font-size: 1.3rem;
    font-weight: 500;
    opacity: 0.9;
    margin: 0;
    color: white;
}

.btn-refresh {
    background: white;
    color: #667eea;
    padding: 1.2rem 3rem;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.2rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.btn-refresh:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(0,0,0,0.3);
    background: white;
    color: #667eea;
}

.btn-refresh:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    background: white;
    color: #667eea;
}

/* Table moderne */
.modern-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.modern-table thead {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.modern-table thead th {
    border: none;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #495057;
}

.modern-table tbody td {
    padding: 1rem;
    border-top: 1px solid #f1f3f5;
    vertical-align: middle;
    font-size: 0.875rem;
}

.modern-table tbody tr {
    transition: all 0.2s ease;
}

.modern-table tbody tr:hover {
    background: #f8f9fc;
}

/* Status badges */
.status-online {
    background: var(--success-gradient);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(17, 153, 142, 0.3);
}

.status-offline {
    background: var(--danger-gradient);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.3);
    }
}

/* Agency details */
.agency-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #2c3e50;
    margin-bottom: 0.3rem;
}

.agency-subtitle {
    color: #6c757d;
    font-size: 0.9rem;
}

.priority-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
}

.metric-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: #2c3e50;
    display: block;
    margin-bottom: 0.5rem;
}

.metric-label {
    display: inline-block;
    background: #e7f3ff;
    color: #0066cc;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.metric-label.success {
    background: #e8f8f5;
    color: #11998e;
}

/* Loading spinner */
.modern-spinner {
    width: 4rem;
    height: 4rem;
    border: 5px solid rgba(102, 126, 234, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Card header */
.card-header-modern {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: none;
    padding: 1.5rem 2rem;
    border-bottom: 2px solid #e9ecef;
}

.card-header-modern h4 {
    margin: 0;
    font-weight: 700;
    color: #2c3e50;
}

/* Footer info */
.info-footer {
    background: linear-gradient(135deg, #f8f9fc 0%, #e9ecef 100%);
    padding: 1.2rem 2rem;
    border-top: 2px solid #dee2e6;
    text-align: center;
}

.info-footer small {
    color: #6c757d;
    font-weight: 500;
}

/* =====================================================
   MOBILE RESPONSIVE
   ===================================================== */

/* Mobile hamburger button */
.mobile-toggle-btn {
    display: none;
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 1050;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.mobile-toggle-btn:hover {
    transform: scale(1.05);
}

/* Mobile overlay behind sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
}

/* Tablets */
@media (max-width: 991px) {
    .stat-value {
        font-size: 1.6rem;
    }

    .page-header-modern {
        padding: 2rem 1.5rem;
    }

    .page-header-modern h1 {
        font-size: 2.2rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Show hamburger button */
    .mobile-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Sidebar slide-in from left */
    .page > .sidebar {
        position: fixed !important;
        top: 0;
        left: -280px;
        width: 270px;
        height: 100vh !important;
        z-index: 1040;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .page > .sidebar.mobile-open {
        left: 0;
    }

    /* Show overlay when sidebar is open */
    .sidebar-overlay.show {
        display: block;
    }

    /* Top row adjustments */
    .top-row {
        padding-left: 3.5rem !important;
        height: auto;
        min-height: 3rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Content adjustments */
    .content {
        padding: 0.5rem !important;
    }

    /* Stat cards */
    .stat-card {
        min-height: 110px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    /* Page header */
    .page-header-modern {
        border-radius: 15px;
        padding: 1.5rem 1rem;
        margin-bottom: 1.5rem;
    }

    .page-header-modern h1 {
        font-size: 1.5rem;
    }

    .page-header-modern p {
        font-size: 0.9rem;
    }

    /* Tables - ensure horizontal scroll works */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .modern-table thead th,
    .modern-table tbody td {
        padding: 0.5rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Agency table font sizes */
    .agency-table .fs-5 {
        font-size: 0.85rem !important;
    }

    /* Cards spacing */
    .row.g-4 {
        --bs-gutter-y: 0.75rem;
        --bs-gutter-x: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    /* Container */
    .container-fluid.py-4 {
        padding: 1rem !important;
    }

    .container-fluid h2 {
        font-size: 1.3rem;
    }

    /* Card header modern */
    .card-header-modern {
        padding: 1rem;
    }

    /* btn-refresh */
    .btn-refresh {
        padding: 0.6rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .stat-value {
        font-size: 1.2rem;
    }

    .stat-card {
        min-height: 90px;
    }

    .page-header-modern h1 {
        font-size: 1.2rem;
    }

    .container-fluid h2 {
        font-size: 1.1rem;
    }

    /* Hide user info on very small screens */
    .top-row .user-info {
        display: none;
    }
}

/* Animation d'entree */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.6s ease-out;
}

.animate-in-delay-1 {
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.animate-in-delay-2 {
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.animate-in-delay-3 {
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

.animate-in-delay-4 {
    animation: fadeInUp 0.6s ease-out 0.4s both;
}

/* Styles pour l'export PDF et l'impression */
@media print {
    body {
        background: white !important;
    }

    .card-header button {
        display: none !important;
    }

    .sidebar,
    nav,
    .no-print,
    .mobile-toggle-btn {
        display: none !important;
    }

    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    .table {
        font-size: 10pt;
    }

    .table thead {
        background-color: #f8f9fa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table-info,
    .table-light,
    .table-secondary {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* Amelioration visuelle des tableaux pour l'export */
#bilan-simple-export .table,
#bilan-detaille-export .table {
    border-collapse: collapse;
    width: 100%;
}

#bilan-simple-export .table thead,
#bilan-detaille-export .table thead {
    background-color: #e9ecef;
    font-weight: bold;
}

#bilan-simple-export .table-info,
#bilan-detaille-export .table-info {
    background-color: #cff4fc !important;
}

#bilan-simple-export .table-light,
#bilan-detaille-export .table-light {
    background-color: #f8f9fa !important;
}

#bilan-simple-export .table-secondary,
#bilan-detaille-export .table-secondary {
    background-color: #e9ecef !important;
}

#bilan-simple-export .table-dark,
#bilan-detaille-export .table-dark {
    background-color: #212529 !important;
    color: white !important;
}

/* Spinner et boutons disabled */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
