/**
 * BilYan Theme System
 * Comprehensive Dark/Light Theme Support
 * Version 3.0
 */

/* =====================================================
   ROOT VARIABLES - Light Theme (Default)
   ===================================================== */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-sidebar: #1e293b;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-heading: #0f172a;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* =====================================================
   DARK THEME - Using body.dark-theme
   ===================================================== */
body.dark-theme {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --bg-sidebar: #020617;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-heading: #ffffff;
    
    --border-color: #334155;
    --border-light: #475569;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

/* =====================================================
   BASE STYLES - Dark Theme
   ===================================================== */
body.dark-theme {
    background-color: #0f172a !important;
    color: #f1f5f9 !important;
}

html.dark-theme {
    background-color: #0f172a !important;
}

/* Main Content Areas */
body.dark-theme .main-content,
body.dark-theme .main-container,
body.dark-theme .content,
body.dark-theme .content-wrapper,
body.dark-theme .container,
body.dark-theme .container-fluid {
    background-color: #0f172a !important;
}

/* =====================================================
   CARDS & PANELS
   ===================================================== */
body.dark-theme .card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: var(--shadow-md) !important;
}

body.dark-theme .card-header {
    background-color: #1e293b !important;
    border-bottom-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .card-body {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

body.dark-theme .card-footer {
    background-color: #1e293b !important;
    border-top-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .card-title,
body.dark-theme .card-header h1,
body.dark-theme .card-header h2,
body.dark-theme .card-header h3,
body.dark-theme .card-header h4,
body.dark-theme .card-header h5,
body.dark-theme .card-header h6 {
    color: #ffffff !important;
}

/* =====================================================
   TABLES
   ===================================================== */
body.dark-theme table,
body.dark-theme .table {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

body.dark-theme .table thead th,
body.dark-theme thead th {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
    font-weight: 600 !important;
}

body.dark-theme .table tbody tr,
body.dark-theme tbody tr {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .table tbody td,
body.dark-theme tbody td {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme .table-striped tbody tr:nth-of-type(odd) {
    background-color: #1a2744 !important;
}

body.dark-theme .table-hover tbody tr:hover {
    background-color: #334155 !important;
}

body.dark-theme .table-bordered,
body.dark-theme .table-bordered td,
body.dark-theme .table-bordered th {
    border-color: #334155 !important;
}

/* =====================================================
   FORMS
   ===================================================== */
body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea,
body.dark-theme .form-control,
body.dark-theme .form-select {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

body.dark-theme input::placeholder,
body.dark-theme textarea::placeholder,
body.dark-theme .form-control::placeholder {
    color: #94a3b8 !important;
}

body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus,
body.dark-theme .form-control:focus,
body.dark-theme .form-select:focus {
    background-color: #3d4f6a !important;
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2) !important;
    color: #ffffff !important;
}

body.dark-theme label,
body.dark-theme .form-label {
    color: #cbd5e1 !important;
}

body.dark-theme .input-group-text {
    background-color: #475569 !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .form-check-input {
    background-color: #334155 !important;
    border-color: #475569 !important;
}

body.dark-theme .form-check-input:checked {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

/* =====================================================
   TYPOGRAPHY
   ===================================================== */
body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme h5,
body.dark-theme h6,
body.dark-theme .h1,
body.dark-theme .h2,
body.dark-theme .h3,
body.dark-theme .h4,
body.dark-theme .h5,
body.dark-theme .h6 {
    color: #ffffff !important;
}

body.dark-theme p {
    color: #cbd5e1 !important;
}

body.dark-theme small,
body.dark-theme .small,
body.dark-theme .text-muted {
    color: #94a3b8 !important;
}

body.dark-theme a:not(.btn):not(.nav-link):not(.dropdown-item) {
    color: #60a5fa !important;
}

body.dark-theme a:not(.btn):not(.nav-link):not(.dropdown-item):hover {
    color: #93c5fd !important;
}

body.dark-theme strong,
body.dark-theme b {
    color: #f1f5f9 !important;
}

/* =====================================================
   BUTTONS
   ===================================================== */
body.dark-theme .btn-light {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .btn-light:hover {
    background-color: #475569 !important;
    color: #ffffff !important;
}

body.dark-theme .btn-outline-secondary {
    border-color: #475569 !important;
    color: #cbd5e1 !important;
}

body.dark-theme .btn-outline-secondary:hover {
    background-color: #475569 !important;
    color: #ffffff !important;
}

body.dark-theme .btn-secondary {
    background-color: #475569 !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-close {
    filter: invert(1) !important;
}

/* =====================================================
   DROPDOWNS
   ===================================================== */
body.dark-theme .dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: var(--shadow-lg) !important;
}

body.dark-theme .dropdown-item {
    color: #f1f5f9 !important;
}

body.dark-theme .dropdown-item:hover,
body.dark-theme .dropdown-item:focus {
    background-color: #334155 !important;
    color: #ffffff !important;
}

body.dark-theme .dropdown-divider {
    border-top-color: #334155 !important;
}

body.dark-theme .dropdown-header {
    color: #94a3b8 !important;
}

/* =====================================================
   MODALS
   ===================================================== */
body.dark-theme .modal-content {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .modal-header {
    background-color: #1e293b !important;
    border-bottom-color: #334155 !important;
}

body.dark-theme .modal-title {
    color: #ffffff !important;
}

body.dark-theme .modal-body {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

body.dark-theme .modal-footer {
    background-color: #1e293b !important;
    border-top-color: #334155 !important;
}

body.dark-theme .modal-backdrop {
    background-color: #000000 !important;
}

/* =====================================================
   ALERTS
   ===================================================== */
body.dark-theme .alert {
    border-width: 1px !important;
}

body.dark-theme .alert-primary {
    background-color: rgba(59, 130, 246, 0.15) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
    color: #93c5fd !important;
}

body.dark-theme .alert-secondary {
    background-color: rgba(100, 116, 139, 0.15) !important;
    border-color: rgba(100, 116, 139, 0.3) !important;
    color: #cbd5e1 !important;
}

body.dark-theme .alert-success {
    background-color: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
    color: #6ee7b7 !important;
}

body.dark-theme .alert-danger {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #fca5a5 !important;
}

body.dark-theme .alert-warning {
    background-color: rgba(245, 158, 11, 0.15) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
    color: #fcd34d !important;
}

body.dark-theme .alert-info {
    background-color: rgba(6, 182, 212, 0.15) !important;
    border-color: rgba(6, 182, 212, 0.3) !important;
    color: #67e8f9 !important;
}

/* =====================================================
   BADGES
   ===================================================== */
body.dark-theme .badge.bg-light {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .badge.bg-secondary {
    background-color: #475569 !important;
}

/* =====================================================
   PAGINATION
   ===================================================== */
body.dark-theme .pagination .page-link {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .pagination .page-link:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
}

body.dark-theme .pagination .page-item.active .page-link {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

body.dark-theme .pagination .page-item.disabled .page-link {
    background-color: #0f172a !important;
    color: #64748b !important;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
body.dark-theme .sidebar,
body.dark-theme .app-sidebar {
    background-color: #020617 !important;
    border-right-color: #1e293b !important;
}

body.dark-theme .sidebar .nav-link,
body.dark-theme .sidebar a {
    color: #94a3b8 !important;
}

body.dark-theme .sidebar .nav-link:hover,
body.dark-theme .sidebar a:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

body.dark-theme .sidebar .nav-link.active {
    color: #ffffff !important;
    background-color: rgba(59, 130, 246, 0.2) !important;
}

/* =====================================================
   NAVBAR / HEADER
   ===================================================== */
body.dark-theme .navbar,
body.dark-theme .top-header,
body.dark-theme header {
    background-color: #1e293b !important;
    border-bottom-color: #334155 !important;
}

body.dark-theme .navbar-brand,
body.dark-theme .navbar-text {
    color: #f1f5f9 !important;
}

/* =====================================================
   BORDERS & DIVIDERS
   ===================================================== */
body.dark-theme hr {
    border-color: #334155 !important;
    opacity: 1 !important;
}

body.dark-theme .border {
    border-color: #334155 !important;
}

body.dark-theme .border-top,
body.dark-theme .border-bottom,
body.dark-theme .border-start,
body.dark-theme .border-end {
    border-color: #334155 !important;
}

/* =====================================================
   LIST GROUPS
   ===================================================== */
body.dark-theme .list-group-item {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .list-group-item:hover {
    background-color: #334155 !important;
}

body.dark-theme .list-group-item.active {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

/* =====================================================
   BREADCRUMBS
   ===================================================== */
body.dark-theme .breadcrumb {
    background-color: transparent !important;
}

body.dark-theme .breadcrumb-item a {
    color: #60a5fa !important;
}

body.dark-theme .breadcrumb-item.active {
    color: #94a3b8 !important;
}

body.dark-theme .breadcrumb-item + .breadcrumb-item::before {
    color: #64748b !important;
}

/* =====================================================
   PROGRESS BARS
   ===================================================== */
body.dark-theme .progress {
    background-color: #334155 !important;
}

/* =====================================================
   TOOLTIPS & POPOVERS
   ===================================================== */
body.dark-theme .tooltip-inner {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

body.dark-theme .popover {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .popover-header {
    background-color: #0f172a !important;
    border-bottom-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .popover-body {
    color: #f1f5f9 !important;
}

/* =====================================================
   NAV TABS
   ===================================================== */
body.dark-theme .nav-tabs {
    border-bottom-color: #334155 !important;
}

body.dark-theme .nav-tabs .nav-link {
    color: #94a3b8 !important;
}

body.dark-theme .nav-tabs .nav-link:hover {
    border-color: #334155 #334155 transparent !important;
    color: #f1f5f9 !important;
}

body.dark-theme .nav-tabs .nav-link.active {
    background-color: #1e293b !important;
    border-color: #334155 #334155 #1e293b !important;
    color: #f1f5f9 !important;
}

/* =====================================================
   CUSTOM SCROLLBAR
   ===================================================== */
body.dark-theme ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body.dark-theme ::-webkit-scrollbar-track {
    background: #1e293b;
}

body.dark-theme ::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

body.dark-theme ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* =====================================================
   STATS CARDS & DASHBOARD
   ===================================================== */
body.dark-theme .stat-card,
body.dark-theme .stats-card,
body.dark-theme .dashboard-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .stat-value,
body.dark-theme .stat-number {
    color: #ffffff !important;
}

body.dark-theme .stat-label {
    color: #94a3b8 !important;
}

/* =====================================================
   MODERN CARDS & STATS - Dark Theme
   ===================================================== */
body.dark-theme .modern-card,
body.dark-theme .stat-card-modern,
body.dark-theme .stat-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .table-modern {
    background: #1e293b !important;
}

body.dark-theme .table-modern thead {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
}

body.dark-theme .table-modern tbody tr {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .table-modern tbody tr:hover {
    background-color: #334155 !important;
}

body.dark-theme .table-modern td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* =====================================================
   SPECIFIC BILYAN STYLES
   ===================================================== */
body.dark-theme .page-header {
    background-color: #1e293b !important;
    border-bottom-color: #334155 !important;
}

body.dark-theme .filter-section,
body.dark-theme .search-section {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .empty-state {
    color: #94a3b8 !important;
}

body.dark-theme .empty-state i {
    color: #475569 !important;
}

/* =====================================================
   THEME TOGGLE BUTTON
   ===================================================== */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    width: 100%;
    text-align: left;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.theme-toggle-btn i {
    width: 20px;
    text-align: center;
}

/* Sun/Moon icon switching */
.theme-toggle-btn .fa-sun {
    display: none;
}

.theme-toggle-btn .fa-moon {
    display: inline-block;
}

body.dark-theme .theme-toggle-btn .fa-sun {
    display: inline-block;
}

body.dark-theme .theme-toggle-btn .fa-moon {
    display: none;
}

/* =====================================================
   TRANSITION FOR SMOOTH THEME CHANGE
   ===================================================== */
body,
body *,
body *::before,
body *::after {
    transition: background-color 0.2s ease, 
                border-color 0.2s ease,
                color 0.2s ease,
                box-shadow 0.2s ease;
}

/* Disable transitions on page load */
body.no-transitions,
body.no-transitions *,
body.no-transitions *::before,
body.no-transitions *::after {
    transition: none !important;
}

/* =====================================================
   LOGIN PAGE - Dark Theme
   ===================================================== */
body.dark-theme.login-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%) !important;
}

body.dark-theme .login-container {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}

body.dark-theme .login-logo p,
body.dark-theme .login-container p {
    color: #94a3b8 !important;
}

body.dark-theme .login-title {
    color: #f1f5f9 !important;
}

body.dark-theme .login-form .form-label {
    color: #cbd5e1 !important;
}

body.dark-theme .login-form .form-control {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .login-form .form-control::placeholder {
    color: #64748b !important;
}

body.dark-theme .login-form .form-control:focus {
    background-color: #3d4f6a !important;
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2) !important;
}

body.dark-theme .login-form .text-muted {
    color: #64748b !important;
}

/* Login Theme Toggle Button */
.login-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    padding: 0;
}

.login-theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.login-theme-toggle i {
    font-size: 18px;
}

.login-theme-toggle .fa-sun {
    display: none;
    color: #fbbf24;
}

.login-theme-toggle .fa-moon {
    display: inline-block;
    color: #94a3b8;
}

body.dark-theme .login-theme-toggle {
    background-color: rgba(30, 41, 59, 0.8);
    border-color: #475569;
}

body.dark-theme .login-theme-toggle .fa-sun {
    display: inline-block;
}

body.dark-theme .login-theme-toggle .fa-moon {
    display: none;
}

body.dark-theme .login-theme-toggle:hover {
    background-color: rgba(51, 65, 85, 0.9);
}
