/* ========================================
   THEME CONFIGURATION - CSS Variables
   ======================================== */
:root {
    /* Primary Colors */
    --theme-primary: #c41e3a;
    --theme-primary-dark: #8b1428;
    --theme-secondary: #6c757d;
    --theme-success: #28a745;
    --theme-danger: #dc3545;
    --theme-warning: #ffc107;
    --theme-info: #0d6efd;
    --theme-light: #f8f9fa;
    --theme-dark: #212529;
    --theme-white: #ffffff;

    /* Sidebar Colors */
    --sidebar-background: #2c3e50;
    --sidebar-text: #ecf0f1;
    --sidebar-active: #c41e3a;
    --sidebar-hover: #34495e;

    /* Navbar Colors */
    --navbar-background: linear-gradient(135deg, #c41e3a 0%, #8b1428 100%);
    --navbar-text: #ffffff;
    --navbar-text-secondary: rgba(255, 255, 255, 0.7);

    /* Container Colors */
    --container-background: #ffffff;
    --container-border: #dee2e6;
    --container-shadow: 0 0.125rem 0.25rem rgba(196, 30, 58, 0.075);
    --container-radius: 0.5rem;

    /* Typography */
    --typography-font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --typography-font-size-base: 1rem;
    --typography-font-weight-light: 300;
    --typography-font-weight-normal: 400;
    --typography-font-weight-medium: 500;
    --typography-font-weight-semibold: 600;
    --typography-font-weight-bold: 700;
    --typography-line-height: 1.6;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-round: 9999px;

    /* Transitions */
    --transition-duration-fast: 150ms;
    --transition-duration-normal: 300ms;
    --transition-duration-slow: 500ms;
    --transition-timing-function: ease-in-out;
}

/* ========================================
   BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: var(--typography-font-family);
    font-size: var(--typography-font-size-base);
    line-height: var(--typography-line-height);
    color: #333;
}

/* ========================================
   TEXT & COLOR UTILITIES
   ======================================== */
.text-primary {
    color: var(--theme-primary) !important;
}

.text-primary-dark {
    color: var(--theme-primary-dark) !important;
}

.text-secondary {
    color: var(--theme-secondary) !important;
}

.text-success {
    color: var(--theme-success) !important;
}

.text-danger {
    color: var(--theme-danger) !important;
}

.text-warning {
    color: var(--theme-warning) !important;
}

.text-info {
    color: var(--theme-info) !important;
}

.text-light {
    color: var(--theme-light) !important;
}

.text-dark {
    color: var(--theme-dark) !important;
}

/* Background Colors */
.bg-primary {
    background-color: var(--theme-primary) !important;
}

.bg-primary-dark {
    background-color: var(--theme-primary-dark) !important;
}

.bg-primary-gradient {
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-dark) 100%) !important;
}

.bg-secondary {
    background-color: var(--theme-secondary) !important;
}

.bg-success {
    background-color: var(--theme-success) !important;
}

.bg-danger {
    background-color: var(--theme-danger) !important;
}

.bg-warning {
    background-color: var(--theme-warning) !important;
}

.bg-info {
    background-color: var(--theme-info) !important;
}

.bg-light {
    background-color: var(--theme-light) !important;
}

.bg-dark {
    background-color: var(--theme-dark) !important;
}

/* Border Colors */
.border-primary {
    border-color: var(--theme-primary) !important;
}

.border-primary-dark {
    border-color: var(--theme-primary-dark) !important;
}

.border-secondary {
    border-color: var(--theme-secondary) !important;
}

/* ========================================
   NAVBAR THEME
   ======================================== */
.navbar-custom {
    background: var(--navbar-background);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.navbar-custom .navbar-brand {
    color: var(--navbar-text) !important;
    font-weight: var(--typography-font-weight-bold);
    font-size: 1.5rem;
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.navbar-custom .navbar-brand:hover {
    transform: scale(1.05);
}

.navbar-custom .navbar-brand img {
    height: 35px;
    margin-right: 0.5rem;
}

.navbar-custom .nav-link {
    color: var(--navbar-text-secondary) !important;
    font-weight: var(--typography-font-weight-medium);
    margin: 0 0.5rem;
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.navbar-custom .nav-link:hover {
    color: var(--navbar-text) !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.navbar-custom .nav-link.active {
    color: var(--navbar-text) !important;
    border-bottom: 2px solid var(--navbar-text);
}

.navbar-custom .dropdown-menu {
    background-color: var(--container-background);
    border: 1px solid var(--container-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.navbar-custom .dropdown-item:hover {
    background-color: var(--theme-light);
    color: var(--theme-primary) !important;
}

/* ========================================
   SIDEBAR THEME
   ======================================== */
.sidebar {
    background-color: var(--sidebar-background);
    color: var(--sidebar-text);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
    min-height: 100vh;
    padding-top: 1rem;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
    display: flex;
    align-items: center;
    font-weight: var(--typography-font-weight-medium);
}

.sidebar .nav-link i {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

.sidebar .nav-link:hover {
    background-color: var(--sidebar-hover);
    color: var(--navbar-text);
    padding-left: 1.25rem;
}

.sidebar .nav-link.active {
    background-color: var(--sidebar-active);
    color: var(--navbar-text);
    border-left: 4px solid var(--navbar-text);
    font-weight: var(--typography-font-weight-bold);
}

.sidebar .nav-section-title {
    color: var(--navbar-text-secondary);
    font-size: 0.75rem;
    font-weight: var(--typography-font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1rem 0.5rem 1rem;
    margin-top: 1rem;
}

.sidebar .nav-section-title:first-child {
    margin-top: 0;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    background-color: var(--theme-primary);
    border: none;
    color: var(--navbar-text);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.sidebar-toggle:hover {
    background-color: var(--theme-primary-dark);
    transform: scale(1.1);
}

/* ========================================
   CARD & CONTAINER THEME
   ======================================== */
.card-themed {
    background-color: var(--container-background);
    border: 1px solid var(--container-border);
    border-radius: var(--container-radius);
    box-shadow: var(--container-shadow);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
    overflow: hidden;
}

.card-themed:hover {
    box-shadow: 0 0.5rem 1rem rgba(196, 30, 58, 0.15);
    transform: translateY(-2px);
}

.card-themed .card-header {
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-dark) 100%);
    color: var(--navbar-text);
    border: none;
    padding: 1rem 1.5rem;
    font-weight: var(--typography-font-weight-semibold);
    font-size: 1.1rem;
}

.card-themed .card-body {
    padding: 1.5rem;
}

.card-themed .card-footer {
    background-color: var(--theme-light);
    border: 1px solid var(--container-border);
    padding: 1rem 1.5rem;
}

/* Stat Cards */
.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-left: 4px solid var(--theme-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(196, 30, 58, 0.15);
    transform: translateY(-4px);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: var(--typography-font-weight-bold);
    color: var(--theme-primary);
}

.stat-card .stat-label {
    font-size: 0.9rem;
    color: var(--theme-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.5rem;
}

/* ========================================
   BUTTON THEME
   ======================================== */
.btn-themed {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
    font-weight: var(--typography-font-weight-semibold);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.95rem;
}

.btn-primary-themed {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--navbar-text);
}

.btn-primary-themed:hover {
    background-color: var(--theme-primary-dark);
    border-color: var(--theme-primary-dark);
    color: var(--navbar-text);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(196, 30, 58, 0.3);
}

.btn-outline-primary-themed {
    color: var(--theme-primary);
    border: 2px solid var(--theme-primary);
    background-color: transparent;
}

.btn-outline-primary-themed:hover {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--navbar-text);
}

.btn-secondary-themed {
    background-color: var(--theme-secondary);
    border-color: var(--theme-secondary);
    color: var(--navbar-text);
}

.btn-secondary-themed:hover {
    background-color: #5a6268;
    border-color: #5a6268;
    color: var(--navbar-text);
}

.btn-success-themed {
    background-color: var(--theme-success);
    border-color: var(--theme-success);
    color: var(--navbar-text);
}

.btn-success-themed:hover {
    background-color: #218838;
    border-color: #218838;
    color: var(--navbar-text);
}

.btn-danger-themed {
    background-color: var(--theme-danger);
    border-color: var(--theme-danger);
    color: var(--navbar-text);
}

.btn-danger-themed:hover {
    background-color: #c82333;
    border-color: #c82333;
    color: var(--navbar-text);
}

/* ========================================
   FORM THEME
   ======================================== */
.form-control-themed {
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--container-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
    font-family: var(--typography-font-family);
}

.form-control-themed:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 0.2rem rgba(196, 30, 58, 0.25);
    outline: none;
}

.form-control-themed::placeholder {
    color: #999;
    opacity: 0.8;
}

.form-label-themed {
    font-weight: var(--typography-font-weight-semibold);
    color: #333;
    margin-bottom: var(--spacing-sm);
    display: block;
}

.form-label-themed.required::after {
    content: ' *';
    color: var(--theme-danger);
}

.form-text-themed {
    font-size: 0.875rem;
    color: var(--theme-secondary);
    margin-top: 0.25rem;
}

.form-feedback-themed {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

.invalid-feedback-themed {
    color: var(--theme-danger);
}

.valid-feedback-themed {
    color: var(--theme-success);
}

/* ========================================
   BADGE THEME
   ======================================== */
.badge-themed {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.75rem;
    border-radius: var(--radius-round);
    font-weight: var(--typography-font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-block;
}

.badge-primary-themed {
    background-color: var(--theme-primary);
    color: var(--navbar-text);
}

.badge-success-themed {
    background-color: var(--theme-success);
    color: var(--navbar-text);
}

.badge-danger-themed {
    background-color: var(--theme-danger);
    color: var(--navbar-text);
}

.badge-warning-themed {
    background-color: var(--theme-warning);
    color: #333;
}

.badge-info-themed {
    background-color: var(--theme-info);
    color: var(--navbar-text);
}

.badge-secondary-themed {
    background-color: var(--theme-secondary);
    color: var(--navbar-text);
}

/* ========================================
   TABLE THEME
   ======================================== */
.table-themed {
    font-size: 0.95rem;
    border-collapse: collapse;
    width: 100%;
}

.table-themed thead {
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-dark) 100%);
    color: var(--navbar-text);
}

.table-themed thead th {
    padding: 1rem 0.75rem;
    font-weight: var(--typography-font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.85rem;
    border: none;
    vertical-align: middle;
}

.table-themed tbody tr {
    border-bottom: 1px solid var(--container-border);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.table-themed tbody tr:hover {
    background-color: rgba(196, 30, 58, 0.05);
}

.table-themed tbody td {
    padding: 0.75rem;
    vertical-align: middle;
}

.table-themed tbody tr:last-child {
    border-bottom: 2px solid var(--theme-primary);
}

/* ========================================
   ALERT THEME
   ======================================== */
.alert-themed {
    border-radius: var(--radius-lg);
    border: none;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.alert-primary-themed {
    background-color: rgba(196, 30, 58, 0.1);
    color: var(--theme-primary);
    border-left: 4px solid var(--theme-primary);
}

.alert-success-themed {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--theme-success);
    border-left: 4px solid var(--theme-success);
}

.alert-danger-themed {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--theme-danger);
    border-left: 4px solid var(--theme-danger);
}

.alert-warning-themed {
    background-color: rgba(255, 193, 7, 0.1);
    color: #856404;
    border-left: 4px solid var(--theme-warning);
}

.alert-info-themed {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--theme-info);
    border-left: 4px solid var(--theme-info);
}

/* ========================================
   BREADCRUMB THEME
   ======================================== */
.breadcrumb-themed {
    background-color: transparent;
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.breadcrumb-themed .breadcrumb-item {
    color: var(--theme-secondary);
}

.breadcrumb-themed .breadcrumb-item.active {
    color: var(--theme-primary);
    font-weight: var(--typography-font-weight-semibold);
}

.breadcrumb-themed .breadcrumb-item a {
    color: var(--theme-primary);
    text-decoration: none;
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.breadcrumb-themed .breadcrumb-item a:hover {
    color: var(--theme-primary-dark);
    text-decoration: underline;
}

/* ========================================
   PAGINATION THEME
   ======================================== */
.pagination-themed {
    gap: 0.25rem;
}

.pagination-themed .page-link {
    color: var(--theme-primary);
    border: 1px solid var(--container-border);
    background-color: var(--container-background);
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.pagination-themed .page-link:hover {
    background-color: var(--theme-primary);
    color: var(--navbar-text);
    border-color: var(--theme-primary);
}

.pagination-themed .page-item.active .page-link {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--navbar-text);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.shadow-themed {
    box-shadow: var(--container-shadow) !important;
}

.shadow-themed-lg {
    box-shadow: 0 1rem 3rem rgba(196, 30, 58, 0.175) !important;
}

.rounded-themed {
    border-radius: var(--container-radius) !important;
}

.transition-all {
    transition: all var(--transition-duration-normal) var(--transition-timing-function);
}

.transition-fast {
    transition: all var(--transition-duration-fast) var(--transition-timing-function);
}

.transition-slow {
    transition: all var(--transition-duration-slow) var(--transition-timing-function);
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 991.98px) {
    /* Navbar adjustments for mobile */
    .navbar-collapse {
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    /* Profile dropdown positioning for mobile */
    .navbar-custom .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
        margin: 0 !important;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15) !important;
    }

    .navbar-custom .dropdown-item {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--container-border);
    }

    .navbar-custom .dropdown-item:last-child {
        border-bottom: none;
    }

    .navbar-nav {
        width: 100%;
    }

    .navbar-nav .nav-item {
        width: 100%;
    }

    .navbar-nav .nav-link {
        padding: 0.5rem 0 !important;
    }
}

@media (max-width: 768px) {
    .navbar-custom .nav-link {
        margin: 0.25rem 0;
    }

    .sidebar {
        position: fixed;
        left: -250px;
        width: 250px;
        height: 100vh;
        z-index: 1040;
        transition: left var(--transition-duration-normal) var(--transition-timing-function);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .sidebar.show {
        left: 0;
    }

    /* Mobile sidebar overlay */
    .sidebar.show::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: -1;
    }

    .card-themed {
        margin-bottom: 1rem;
    }

    .btn-themed {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .stat-card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 576px) {
    .navbar-custom .navbar-brand {
        font-size: 1.25rem;
    }

    /* Ensure dropdown is fully visible and not cut off */
    .navbar-custom .dropdown-menu {
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    .dropdown-item {
        font-size: 0.95rem;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .navbar-custom,
    .sidebar,
    .btn,
    .pagination-themed {
        display: none !important;
    }

    .container-fluid {
        margin: 0;
        padding: 0;
    }

    .card-themed {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .table-themed {
        color: #000;
    }
}
