:root {
    --bs-primary: #dd153c;
    --bs-primary-rgb: 221, 21, 60;
    --bs-secondary: #555555;
    --bs-secondary-rgb: 85, 85, 85;
    --bs-info: #0dcaf0;
    --bs-success: #198754;
    --bs-danger: #dc3545;
    --bs-warning: #ffc107;
}

[data-bs-theme="dark"] {
    --bs-body-bg: #0f172a;
    --bs-body-color: #e5e7eb;
    --bs-secondary-color: #a7b0bf;
    --bs-tertiary-bg: #1f2937;
    --bs-border-color: #334155;
}

body {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--bs-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #c82333;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Navbar improvements */
.navbar {
    backdrop-filter: blur(10px);
    background: linear-gradient(135deg, #dd153c 0%, #ac112f 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.navbar-brand {
    transition: transform 0.2s ease;
    color: #ffffff !important;
}

.navbar-brand:hover {
    transform: scale(1.02);
    color: #ffffff !important;
}

.brand-text span:first-child {
    font-size: 1.1rem;
    letter-spacing: 1px;
    font-weight: 800;
}

.nav-link {
    transition: all 0.2s ease;
    border-radius: 8px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85) !important;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff !important;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff !important;
}

/* Fix pour le dropdown-toggle quand la navbar est dark */
.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* User Profile Circle */
.avatar-circle {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.9rem;
    background-color: white !important;
    color: #dd153c !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Dropdown styling */
.dropdown-menu {
    border: none;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Footer improvements */
footer {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

/* Flash messages animation */
.flash-messages {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10050;
    width: min(420px, calc(100vw - 2rem));
    pointer-events: none;
}

.flash-messages .alert {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
    padding: 0.9rem 2.75rem 0.9rem 1rem;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18) !important;
    pointer-events: auto;
}

.flash-messages .alert > i {
    flex: 0 0 auto;
    margin-top: 0.08rem;
    font-size: 1.1rem;
}

.flash-messages .btn-close {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
}

.alert {
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--bs-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-track {
    background: #111827;
}

[data-bs-theme="dark"] .navbar {
    background: linear-gradient(135deg, #9f1239 0%, #111827 100%) !important;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #111827;
    border: 1px solid #334155;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35) !important;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e5e7eb;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #1f2937;
    color: #ffffff;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-top-color: #334155;
}

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .list-group-item {
    background-color: #111827;
    border-color: #334155;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .card-footer,
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    background-color: #172033 !important;
    border-color: #334155;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: #111827;
    --bs-table-color: #e5e7eb;
    --bs-table-border-color: #334155;
    --bs-table-striped-bg: #172033;
    --bs-table-hover-bg: rgba(221, 21, 60, 0.14);
    color: #e5e7eb;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .ts-control {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #e5e7eb !important;
}

[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] .ts-control input::placeholder {
    color: #94a3b8;
}

[data-bs-theme="dark"] .ts-dropdown {
    background: #111827 !important;
    border-color: #334155 !important;
    color: #e5e7eb !important;
}

[data-bs-theme="dark"] .ts-dropdown .option {
    color: #e5e7eb !important;
}

[data-bs-theme="dark"] .ts-dropdown .active,
[data-bs-theme="dark"] .ts-dropdown .option:hover {
    background-color: #1f2937 !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #a7b0bf !important;
}

[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light {
    background-color: #172033 !important;
}

[data-bs-theme="dark"] .navbar-brand.bg-white {
    background-color: #ffffff !important;
}

[data-bs-theme="dark"] .text-dark {
    color: #e5e7eb !important;
}

[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end {
    border-color: #334155 !important;
}

[data-bs-theme="dark"] footer {
    background: linear-gradient(135deg, #111827 0%, #172033 100%);
}

[data-bs-theme="dark"] .loading-overlay {
    background: rgba(15, 23, 42, 0.92);
}

[data-bs-theme="dark"] .loading-spinner {
    border-color: #334155;
    border-top-color: var(--bs-primary);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .navbar-collapse {
        background: linear-gradient(135deg, var(--bs-primary) 0%, #c82333 100%);
        padding: 1rem;
        border-radius: 0 0 12px 12px;
        margin-top: 0.5rem;
    }

    [data-bs-theme="dark"] .navbar-collapse {
        background: linear-gradient(135deg, #9f1239 0%, #111827 100%);
    }

    .navbar-nav {
        width: 100%;
    }

    .nav-item {
        width: 100%;
        margin: 0.25rem 0;
    }

    .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 8px;
        display: flex;
        align-items: center;
    }

    .nav-link i {
        width: 24px;
    }
}

@media (max-width: 768px) {
    .flash-messages {
        top: 76px;
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
    }

    .flash-messages .alert {
        padding: 0.85rem 2.75rem 0.85rem 0.95rem;
    }

    .flash-messages .btn-close {
        top: 0.85rem;
        right: 0.85rem;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .navbar-brand i {
        font-size: 1.2rem;
    }

    .navbar-toggler {
        padding: 0.5rem;
    }

    .navbar-toggler-icon {
        width: 1.25em;
        height: 1.25em;
    }

    .nav-link {
        padding: 0.6rem 0.8rem;
        font-size: 0.95rem;
    }

    .nav-link i {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .navbar-brand {
        font-size: 0.9rem;
    }

    .navbar-brand i {
        font-size: 1.1rem;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .nav-link i {
        font-size: 0.9rem;
        width: 20px;
    }
}

/* Dark mode support */
[data-bs-theme="dark"] tbody tr:hover {
    background-color: rgba(221, 21, 60, 0.14) !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: #172033 !important;
}
