/* ============================================
   SIPRAS Dark Mode Stylesheet
   Uses [data-theme="dark"] on <html> element
   ============================================ */

/* ---- Transition for smooth mode switch ---- */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ---- Dark Theme Toggle Button ---- */
.dark-mode-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    background: #1e293b;
    color: #fbbf24;
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .dark-mode-toggle {
    background: #f8fafc;
    color: #f59e0b;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* ---- Base Dark Theme ---- */
[data-theme="dark"] body {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
}

/* ---- Sidebar ---- */
[data-theme="dark"] .sidebar {
    background-color: #1e293b !important;
    border-right-color: #334155 !important;
}

[data-theme="dark"] .sidebar-header {
    border-bottom-color: #334155 !important;
}

[data-theme="dark"] .sidebar h5,
[data-theme="dark"] .sidebar .fw-bold {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .nav-link {
    color: #94a3b8 !important;
}

[data-theme="dark"] .nav-link:hover {
    background-color: #334155 !important;
    color: #818cf8 !important;
}

[data-theme="dark"] .nav-link.active {
    background-color: rgba(99, 102, 241, 0.15) !important;
    color: #818cf8 !important;
}

[data-theme="dark"] .menu-label {
    color: #64748b !important;
}

/* ---- Mobile Navbar ---- */
[data-theme="dark"] .mobile-nav {
    background: #1e293b !important;
    border-bottom-color: #334155 !important;
}

[data-theme="dark"] .mobile-nav .fw-bold {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .mobile-nav .btn-light {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* ---- Sidebar Overlay ---- */
[data-theme="dark"] #sidebarOverlay {
    background: rgba(0, 0, 0, 0.7) !important;
}

/* ---- Main Content ---- */
[data-theme="dark"] .main-content {
    background-color: #0f172a !important;
}

/* ---- Cards ---- */
[data-theme="dark"] .card,
[data-theme="dark"] .card-stat {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .card-header {
    background-color: #1e293b !important;
    border-bottom-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .card-footer {
    background-color: #1e293b !important;
    border-top-color: #334155 !important;
}

[data-theme="dark"] .card-body {
    color: #e2e8f0 !important;
}

/* ---- Typography ---- */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .fw-bold,
[data-theme="dark"] .fw-semibold,
[data-theme="dark"] .fw-medium {
    color: #f1f5f9 !important;
}

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

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

[data-theme="dark"] .page-title {
    color: #f1f5f9 !important;
}

[data-theme="dark"] p {
    color: #cbd5e1;
}

[data-theme="dark"] .small,
[data-theme="dark"] small {
    color: #94a3b8;
}

/* ---- Tables ---- */
[data-theme="dark"] .table {
    color: #e2e8f0 !important;
    --bs-table-bg: transparent;
}

[data-theme="dark"] .table thead th {
    background-color: #162032 !important;
    color: #94a3b8 !important;
    border-bottom-color: #334155 !important;
}

[data-theme="dark"] .table tbody td {
    border-bottom-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.05) !important;
    --bs-table-hover-bg: rgba(99, 102, 241, 0.05);
}

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

/* ---- Forms ---- */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #0f172a !important;
    border-color: #818cf8 !important;
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25) !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .form-control::placeholder {
    color: #64748b !important;
}

[data-theme="dark"] .form-label {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .form-text {
    color: #64748b !important;
}

[data-theme="dark"] .form-control.bg-light {
    background-color: #1e293b !important;
}

[data-theme="dark"] .form-check-input {
    background-color: #0f172a !important;
    border-color: #475569 !important;
}

[data-theme="dark"] .form-check-input:checked {
    background-color: #6366f1 !important;
    border-color: #6366f1 !important;
}

[data-theme="dark"] .input-group-text {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}

/* ---- Buttons ---- */
[data-theme="dark"] .btn-light {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .btn-light:hover {
    background-color: #475569 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .btn-outline-secondary {
    border-color: #475569 !important;
    color: #94a3b8 !important;
}

[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #475569 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .btn-outline-primary {
    border-color: #818cf8 !important;
    color: #818cf8 !important;
}

[data-theme="dark"] .btn-outline-primary:hover {
    background-color: rgba(99, 102, 241, 0.15) !important;
    color: #a5b4fc !important;
}

[data-theme="dark"] .btn-outline-success {
    border-color: #34d399 !important;
    color: #34d399 !important;
}

[data-theme="dark"] .btn-outline-success:hover {
    background-color: rgba(52, 211, 153, 0.15) !important;
    color: #6ee7b7 !important;
}

[data-theme="dark"] .btn-outline-warning {
    border-color: #fbbf24 !important;
    color: #fbbf24 !important;
}

[data-theme="dark"] .btn-outline-warning:hover {
    background-color: rgba(251, 191, 36, 0.15) !important;
    color: #fcd34d !important;
}

[data-theme="dark"] .btn-outline-info {
    border-color: #22d3ee !important;
    color: #22d3ee !important;
}

[data-theme="dark"] .btn-outline-info:hover {
    background-color: rgba(34, 211, 238, 0.15) !important;
    color: #67e8f9 !important;
}

/* ---- Alerts ---- */
[data-theme="dark"] .alert-success {
    background-color: rgba(34, 197, 94, 0.1) !important;
    border-color: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

[data-theme="dark"] .alert-danger {
    background-color: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}

[data-theme="dark"] .alert-warning {
    background-color: rgba(251, 191, 36, 0.1) !important;
    border-color: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

[data-theme="dark"] .alert-info {
    background-color: rgba(56, 189, 248, 0.1) !important;
    border-color: rgba(56, 189, 248, 0.2) !important;
    color: #38bdf8 !important;
}

[data-theme="dark"] .alert-light {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}

/* close btn in alerts */
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ---- Badges ---- */
[data-theme="dark"] .badge.bg-white {
    background-color: #1e293b !important;
    color: #818cf8 !important;
    border-color: #475569 !important;
}

[data-theme="dark"] .badge.bg-secondary {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .badge.bg-light {
    background-color: rgba(99, 102, 241, 0.15) !important;
    color: #818cf8 !important;
}

[data-theme="dark"] .badge.bg-info {
    color: #f1f5f9 !important;
}

/* ---- Modals ---- */
[data-theme="dark"] .modal-content {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #334155 !important;
}

[data-theme="dark"] .modal-footer {
    border-top-color: #334155 !important;
}

[data-theme="dark"] .modal-title {
    color: #f1f5f9 !important;
}

/* ---- Bootstrap Utility Overrides ---- */
[data-theme="dark"] .bg-white {
    background-color: #1e293b !important;
}

[data-theme="dark"] .bg-opacity-10 {
    /* Keep the colored bg-opacity translucent bg as-is, they look fine */
}

[data-theme="dark"] .border {
    border-color: #334155 !important;
}

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

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

[data-theme="dark"] .shadow-sm {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
}

/* ---- Login Page Specific ---- */
[data-theme="dark"] .login-card {
    background: rgba(30, 41, 59, 0.95) !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .login-card .app-title {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .login-card .app-subtitle {
    color: #94a3b8 !important;
}

[data-theme="dark"] .login-card .input-group {
    background: #0f172a !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .login-card .input-group:focus-within {
    background: #1e293b !important;
    border-color: #00AEEF !important;
}

[data-theme="dark"] .login-card .input-group-text {
    color: #64748b !important;
}

[data-theme="dark"] .login-card .form-control {
    color: #e2e8f0 !important;
}

[data-theme="dark"] .login-card .form-label {
    color: #94a3b8 !important;
}

[data-theme="dark"] .login-card .footer-text {
    color: #64748b !important;
}

[data-theme="dark"] .login-card .logo-container {
    background: #1e293b !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .login-card .btn-link {
    color: #64748b !important;
}

[data-theme="dark"] .login-card .btn-link:hover {
    color: #00AEEF !important;
}

/* Autofill for dark theme */
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:focus,
[data-theme="dark"] input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #0f172a inset !important;
    -webkit-text-fill-color: #e2e8f0 !important;
}

[data-theme="dark"] .login-card .input-group:focus-within input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px #1e293b inset !important;
}

/* ---- Pagination ---- */
[data-theme="dark"] .pagination .page-link {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}

[data-theme="dark"] .pagination .page-link:hover {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .pagination .active .page-link {
    background-color: #6366f1 !important;
    border-color: #6366f1 !important;
    color: white !important;
}

/* ---- Scrollbar ---- */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ---- Selection ---- */
[data-theme="dark"] ::selection {
    background: rgba(99, 102, 241, 0.3);
    color: #f1f5f9;
}

/* ---- Dropdown ---- */
[data-theme="dark"] .dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .dropdown-item {
    color: #e2e8f0 !important;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
}

/* ---- SweetAlert2 Dark Overrides ---- */
[data-theme="dark"] .swal2-popup {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .swal2-title {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .swal2-html-container {
    color: #94a3b8 !important;
}

/* ---- Print Styles: Always Light ---- */
@media print {
    [data-theme="dark"] body {
        background-color: #fff !important;
        color: #000 !important;
    }
    .dark-mode-toggle {
        display: none !important;
    }
}
