/* ============================================
   Dark Theme — activated via [data-theme="dark"]
   NUCLEAR APPROACH: override everything
   ============================================ */

[data-theme="dark"] {
    color-scheme: dark;
}

/* =============================================
   1. GLOBAL TEXT COLOR — force ALL text to light
   ============================================= */

[data-theme="dark"],
[data-theme="dark"] body {
    background: #101018 !important;
    color: #dcdce4 !important;
}

/* Force EVERY element text to light unless it's a colored button/badge */
[data-theme="dark"] *:not(.badge):not([class*="badge-"]):not([class*="btn-"]):not(.btn):not(.alert):not(.header__content__dropdown__header__info-avatar):not(.program-code):not(.filter-btn) {
    color: #dcdce4 !important;
}

/* Colored elements: inherit color from parent (badge/btn/alert) */
[data-theme="dark"] .badge *,
[data-theme="dark"] [class*="badge-"] *,
[data-theme="dark"] .btn *,
[data-theme="dark"] [class*="btn-"] *,
[data-theme="dark"] .alert *,
[data-theme="dark"] .program-code *,
[data-theme="dark"] .filter-btn * {
    color: inherit !important;
}

/* Muted/secondary text — slightly dimmer */
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary,
[data-theme="dark"] small,
[data-theme="dark"] .form-text,
[data-theme="dark"] .help-block,
[data-theme="dark"] figcaption,
[data-theme="dark"] caption {
    color: #8a8a9e !important;
}

/* =============================================
   2. LINKS — purple-ish, readable on dark
   ============================================= */

[data-theme="dark"] a:not([class*="btn"]):not(.bg-primary):not(.alert a):not(.badge) {
    color: #9090ff !important;
}

[data-theme="dark"] a:not([class*="btn"]):hover {
    color: #b0b0ff !important;
}

/* Sidebar links — lighter */
[data-theme="dark"] #sidebar a {
    color: #ccccd8 !important;
}

[data-theme="dark"] #sidebar a.bg-primary,
[data-theme="dark"] #sidebar a.bg-primary * {
    color: #fff !important;
    background: #5858ed !important;
}

/* Header menu items */
[data-theme="dark"] .header__content__menu-item {
    color: #ccccd8 !important;
}

[data-theme="dark"] .header__content__menu-item:hover,
[data-theme="dark"] .header__content__menu-item.active {
    color: #8080ff !important;
}

/* Logout link — keep red */
[data-theme="dark"] a[style*="FF4443"],
[data-theme="dark"] a[style*="ff4443"],
[data-theme="dark"] .text-red,
[data-theme="dark"] a.text-red {
    color: #ff6b6b !important;
}

/* =============================================
   3. BACKGROUNDS — all white/light → dark
   ============================================= */

/* Body & main containers */
[data-theme="dark"] body,
[data-theme="dark"] main,
[data-theme="dark"] .content,
[data-theme="dark"] .page-with-sidebar {
    background-color: #101018 !important;
}

/* Reset generic container backgrounds — but NOT specific raised surfaces */
[data-theme="dark"] section,
[data-theme="dark"] article,
[data-theme="dark"] aside,
[data-theme="dark"] footer,
[data-theme="dark"] figure {
    background-color: transparent !important;
}

/* Specific containers that NEED a slightly raised bg */
[data-theme="dark"] .header__content,
[data-theme="dark"] #sidebar,
[data-theme="dark"] .department-header {
    background-color: #161620 !important;
}

[data-theme="dark"] .header__content__dropdown__content,
[data-theme="dark"] .dropdown-menu {
    background-color: #1e1f2c !important;
}

[data-theme="dark"] .card,
[data-theme="dark"] .card-body,
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer,
[data-theme="dark"] .modal,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-body,
[data-theme="dark"] .modal-footer,
[data-theme="dark"] .modal-form,
[data-theme="dark"] .panel,
[data-theme="dark"] .well,
[data-theme="dark"] .list-group-item,
[data-theme="dark"] .popover,
[data-theme="dark"] .toast {
    background-color: #1c1d28 !important;
}

[data-theme="dark"] .service-section,
[data-theme="dark"] .analytics-section,
[data-theme="dark"] .settings-panel,
[data-theme="dark"] .settings-card,
[data-theme="dark"] .program-form-section,
[data-theme="dark"] .programs-table-section,
[data-theme="dark"] .info-card,
[data-theme="dark"] .structure-canvas,
[data-theme="dark"] .subdepartments-list {
    background-color: #1a1b26 !important;
}

[data-theme="dark"] .service-button,
[data-theme="dark"] .info-panel-button,
[data-theme="dark"] .form-card,
[data-theme="dark"] .form-card-img {
    background-color: #20212e !important;
}

[data-theme="dark"] .checkbox-group,
[data-theme="dark"] .user-profile {
    background-color: #20212e !important;
}

[data-theme="dark"] .bg-primary-100 {
    background-color: #252638 !important;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] [class*="bg-white"],
[data-theme="dark"] .bg-light {
    background-color: #1a1b26 !important;
}

/* =============================================
   4. BORDERS — subtle white
   ============================================= */

[data-theme="dark"] * {
    border-color: rgba(255,255,255,0.07) !important;
}

/* Focused elements */
[data-theme="dark"] *:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: #5858ed !important;
}

/* Colored alerts keep their borders */
[data-theme="dark"] .alert-success { border-color: #28a745 !important; }
[data-theme="dark"] .alert-danger,
[data-theme="dark"] .alert-error { border-color: #dc3545 !important; }
[data-theme="dark"] .alert-warning { border-color: #ffc107 !important; }
[data-theme="dark"] .alert-info { border-color: #17a2b8 !important; }

[data-theme="dark"] hr {
    border-color: rgba(255,255,255,0.07) !important;
    opacity: 1 !important;
}

/* =============================================
   5. FORMS & INPUTS
   ============================================= */

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #1e1f2c !important;
    color: #dcdce4 !important;
    border-color: rgba(255,255,255,0.10) !important;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #262740 !important;
    border-color: #5858ed !important;
    box-shadow: 0 0 0 3px rgba(88,88,237,0.25) !important;
    color: #eeeef4 !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] .form-control::placeholder {
    color: #606078 !important;
}

[data-theme="dark"] input[readonly],
[data-theme="dark"] input:disabled,
[data-theme="dark"] select:disabled,
[data-theme="dark"] textarea:disabled {
    background-color: #161620 !important;
    color: #707088 !important;
}

[data-theme="dark"] option {
    background-color: #1e1f2c !important;
    color: #dcdce4 !important;
}

/* =============================================
   6. TABLES
   ============================================= */

[data-theme="dark"] table,
[data-theme="dark"] .table {
    color: #dcdce4 !important;
    background-color: transparent !important;
}

[data-theme="dark"] thead,
[data-theme="dark"] thead th,
[data-theme="dark"] .table > thead > tr > th {
    background-color: #1a1b26 !important;
    color: #b8b8cc !important;
}

[data-theme="dark"] tbody tr {
    background-color: transparent !important;
}

[data-theme="dark"] tbody tr:nth-child(even) {
    background-color: rgba(255,255,255,0.015) !important;
}

[data-theme="dark"] tbody tr:hover {
    background-color: rgba(88,88,237,0.06) !important;
}

/* =============================================
   7. IMAGES & SVGs
   ============================================= */

[data-theme="dark"] .service-button img,
[data-theme="dark"] .info-panel-button img {
    filter: invert(85%) brightness(1.1) !important;
}

[data-theme="dark"] .form-card-img img,
[data-theme="dark"] .current-profile-photo,
[data-theme="dark"] .login-logo,
[data-theme="dark"] .header__content-logo,
[data-theme="dark"] img[src*="media/"],
[data-theme="dark"] img[src*="upload"] {
    filter: none !important;
}

[data-theme="dark"] #sidebar svg {
    color: #b8b8cc !important;
}

[data-theme="dark"] .header__content__dropdown__header-arrow svg path {
    fill: #b8b8cc !important;
}

[data-theme="dark"] .header__content__dropdown__content__list-item svg path[fill="#5858F6"] {
    fill: #7b7bf7 !important;
}

/* =============================================
   8. SHADOWS
   ============================================= */

[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .service-section,
[data-theme="dark"] .form-card,
[data-theme="dark"] .settings-card,
[data-theme="dark"] .settings-panel,
[data-theme="dark"] .info-card,
[data-theme="dark"] .program-form-section,
[data-theme="dark"] .programs-table-section {
    box-shadow: 0 2px 12px rgba(0,0,0,0.5) !important;
}

[data-theme="dark"] .service-button:hover,
[data-theme="dark"] .info-panel-button:hover,
[data-theme="dark"] .form-card:hover,
[data-theme="dark"] .settings-card:hover,
[data-theme="dark"] .settings-panel:hover {
    box-shadow: 0 6px 24px rgba(88,88,237,0.2) !important;
}

/* =============================================
   9. SCROLLBAR
   ============================================= */

[data-theme="dark"] ::-webkit-scrollbar { width: 8px; height: 8px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #101018; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #383848; border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #484860; }

/* =============================================
   10. DROPDOWN, BREADCRUMB, TABS, PAGINATION
   ============================================= */

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: rgba(88,88,237,0.1) !important;
}

[data-theme="dark"] .nav-tabs {
    border-bottom-color: rgba(255,255,255,0.07) !important;
}

[data-theme="dark"] .nav-tabs .nav-link.active {
    background-color: #1c1d28 !important;
    border-color: rgba(255,255,255,0.07) !important;
}

[data-theme="dark"] .page-link {
    background-color: #1c1d28 !important;
    border-color: rgba(255,255,255,0.07) !important;
}

[data-theme="dark"] .page-item.active .page-link {
    background-color: #5858ed !important;
    border-color: #5858ed !important;
    color: #fff !important;
}

[data-theme="dark"] .tooltip-inner {
    background-color: #2a2b3a !important;
}

/* =============================================
   11. BUTTONS — preserve colored ones
   ============================================= */

[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-primary * { background-color: #5858ed !important; color: #fff !important; }
[data-theme="dark"] .btn-primary:hover { background-color: #4040b8 !important; }
[data-theme="dark"] .btn-danger,
[data-theme="dark"] .btn-danger * { background-color: #dc3545 !important; color: #fff !important; }
[data-theme="dark"] .btn-success,
[data-theme="dark"] .btn-success * { background-color: #28a745 !important; color: #fff !important; }
[data-theme="dark"] .btn-warning,
[data-theme="dark"] .btn-warning * { background-color: #ffc107 !important; color: #333 !important; }
[data-theme="dark"] .btn-info,
[data-theme="dark"] .btn-info * { background-color: #17a2b8 !important; color: #fff !important; }
[data-theme="dark"] .btn-secondary { background-color: #5858ed !important; color: #fff !important; }
[data-theme="dark"] .btn-outline-primary { color: #7b7bf7 !important; border-color: #7b7bf7 !important; background: transparent !important; }
[data-theme="dark"] .btn-outline-primary:hover { background: #5858ed !important; color: #fff !important; }
[data-theme="dark"] .btn-outline-secondary { color: #7b7bf7 !important; border-color: #7b7bf7 !important; background: transparent !important; }
[data-theme="dark"] .btn-outline-secondary:hover { background: #5858ed !important; color: #fff !important; }
[data-theme="dark"] .login-button { color: #fff !important; }

/* Badges */
[data-theme="dark"] .badge { color: #fff !important; }

/* Alerts — keep their colors */
[data-theme="dark"] .alert-success { color: #d4edda !important; background: #155724 !important; }
[data-theme="dark"] .alert-danger,
[data-theme="dark"] .alert-error { color: #f8d7da !important; background: #721c24 !important; }
[data-theme="dark"] .alert-warning { color: #fff3cd !important; background: #856404 !important; }
[data-theme="dark"] .alert-info { color: #d1ecf1 !important; background: #0c5460 !important; }

[data-theme="dark"] .alert * {
    color: inherit !important;
}

/* Avatar circle */
[data-theme="dark"] .header__content__dropdown__header__info-avatar {
    color: #fff !important;
    background: #5858ed !important;
}

/* =============================================
   12. IFRAME
   ============================================= */

[data-theme="dark"] iframe {
    background: #101018 !important;
}

/* =============================================
   13. THEME TOGGLE BUTTON
   ============================================= */

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.07);
    border-radius: 8px;
    background: transparent;
    transition: all 0.2s ease;
    color: inherit;
    flex-shrink: 0;
}

.theme-toggle-btn:hover { opacity: 0.7; }

[data-theme="dark"] .theme-toggle-btn {
    border-color: rgba(255,255,255,0.10) !important;
}

/* =============================================
   14. EDUCATIONAL PROGRAMS PAGE
   ============================================= */

[data-theme="dark"] .educational-programs-page .page-header h1,
[data-theme="dark"] .educational-programs-page .page-header p {
    color: #d0d0e0 !important;
}

[data-theme="dark"] .filters-section,
[data-theme="dark"] .create-program-section,
[data-theme="dark"] .no-programs {
    background: #1c1d28 !important;
}

[data-theme="dark"] .program-card {
    background: #1c1d28 !important;
    border-color: rgba(255,255,255,0.06) !important;
}

[data-theme="dark"] .program-header h3 {
    color: #e0e0ec !important;
}

[data-theme="dark"] .program-code {
    background: #5858ed !important;
    color: #fff !important;
}

/* Badges — keep their colored backgrounds, ensure readable text */
[data-theme="dark"] .badge-qualification {
    background: rgba(25, 118, 210, 0.2) !important;
    color: #64b5f6 !important;
}

[data-theme="dark"] .badge-form {
    background: rgba(123, 31, 162, 0.2) !important;
    color: #ce93d8 !important;
}

[data-theme="dark"] .badge-financing,
[data-theme="dark"] .badge-budget {
    background: rgba(56, 142, 60, 0.2) !important;
    color: #81c784 !important;
}

[data-theme="dark"] .badge-paid {
    background: rgba(245, 124, 0, 0.2) !important;
    color: #ffb74d !important;
}

[data-theme="dark"] .badge-admission {
    background: rgba(46, 125, 50, 0.2) !important;
    color: #81c784 !important;
}

[data-theme="dark"] .badge-active {
    background: rgba(46, 125, 50, 0.2) !important;
    color: #81c784 !important;
}

[data-theme="dark"] .badge-inactive {
    background: rgba(198, 40, 40, 0.2) !important;
    color: #ef9a9a !important;
}

[data-theme="dark"] .badge i {
    color: inherit !important;
}

[data-theme="dark"] .detail-row {
    border-bottom-color: rgba(255,255,255,0.05) !important;
}

[data-theme="dark"] .detail-label {
    color: #9090a8 !important;
}

[data-theme="dark"] .detail-label i {
    color: #7b7bf7 !important;
}

[data-theme="dark"] .detail-value {
    color: #d0d0e0 !important;
}

[data-theme="dark"] .detail-value.price {
    color: #81c784 !important;
}

[data-theme="dark"] .filter-btn {
    background: #22232f !important;
    color: #b0b0c0 !important;
    border-color: rgba(255,255,255,0.08) !important;
}

[data-theme="dark"] .filter-btn:hover {
    border-color: #5858ed !important;
    color: #7b7bf7 !important;
}

[data-theme="dark"] .filter-btn.active {
    background: #5858ed !important;
    color: #fff !important;
    border-color: #5858ed !important;
}

[data-theme="dark"] .form-section {
    background: #1a1b26 !important;
    border-color: rgba(255,255,255,0.06) !important;
}

[data-theme="dark"] .form-section h4 {
    color: #c0c0d0 !important;
}

[data-theme="dark"] .entrance-subject-item {
    background: #22232f !important;
    border-color: rgba(255,255,255,0.06) !important;
}

[data-theme="dark"] .subject-group {
    background: #1a1b26 !important;
    border-color: rgba(255,255,255,0.06) !important;
}

[data-theme="dark"] .group-header {
    border-bottom-color: rgba(255,255,255,0.06) !important;
}

[data-theme="dark"] .group-header h5 {
    color: #d0d0e0 !important;
}

[data-theme="dark"] .create-form-container {
    border-top-color: rgba(255,255,255,0.06) !important;
}

[data-theme="dark"] .section-header h3 {
    color: #d0d0e0 !important;
}

[data-theme="dark"] .form-group label,
[data-theme="dark"] .checkbox-label {
    color: #c0c0d0 !important;
}

[data-theme="dark"] .form-actions {
    border-top-color: rgba(255,255,255,0.06) !important;
}

[data-theme="dark"] .empty-state h3 {
    color: #b0b0c0 !important;
}

[data-theme="dark"] .empty-state p {
    color: #8080a0 !important;
}

[data-theme="dark"] .btn-outline-danger {
    color: #ef5350 !important;
    border-color: #ef5350 !important;
    background: transparent !important;
}

[data-theme="dark"] .btn-outline-danger:hover {
    background: #dc3545 !important;
    color: #fff !important;
}

/* =============================================
   15. GENERIC INLINE STYLE OVERRIDES
   ============================================= */

/* Catch common inline color patterns from templates */
[data-theme="dark"] [style*="color: #333"],
[data-theme="dark"] [style*="color:#333"],
[data-theme="dark"] [style*="color: #222"],
[data-theme="dark"] [style*="color:#222"],
[data-theme="dark"] [style*="color: #000"],
[data-theme="dark"] [style*="color:#000"],
[data-theme="dark"] [style*="color: #444"],
[data-theme="dark"] [style*="color:#444"],
[data-theme="dark"] [style*="color: #555"],
[data-theme="dark"] [style*="color:#555"],
[data-theme="dark"] [style*="color: #666"],
[data-theme="dark"] [style*="color:#666"],
[data-theme="dark"] [style*="color: #888"],
[data-theme="dark"] [style*="color:#888"],
[data-theme="dark"] [style*="color: #999"],
[data-theme="dark"] [style*="color:#999"],
[data-theme="dark"] [style*="color: #323130"],
[data-theme="dark"] [style*="color: #303030"],
[data-theme="dark"] [style*="color: #495057"],
[data-theme="dark"] [style*="color: #6c757d"],
[data-theme="dark"] [style*="color:#6c757d"],
[data-theme="dark"] [style*="color: #856404"],
[data-theme="dark"] [style*="color:#856404"],
[data-theme="dark"] [style*="color: black"],
[data-theme="dark"] [style*="color:black"] {
    color: #d0d0e0 !important;
}

[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background-color: #fff"],
[data-theme="dark"] [style*="background-color:#fff"],
[data-theme="dark"] [style*="background-color: white"],
[data-theme="dark"] [style*="background-color:white"],
[data-theme="dark"] [style*="background: #f5f7fa"],
[data-theme="dark"] [style*="background: #f5f5f5"],
[data-theme="dark"] [style*="background: #f8f9fa"],
[data-theme="dark"] [style*="background-color: #f8f9fa"],
[data-theme="dark"] [style*="background-color: #f5f7fa"],
[data-theme="dark"] [style*="background-color: #f5f5f5"],
[data-theme="dark"] [style*="background-color: #f8f8f8"],
[data-theme="dark"] [style*="background: #f7fafc"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background-color: #ffffff"],
[data-theme="dark"] [style*="background-color: #fefefe"],
[data-theme="dark"] [style*="background-color: #fff3cd"] {
    background-color: #1c1d28 !important;
}

/* =============================================
   16. TRANSITION
   ============================================= */

html[data-theme] body,
html[data-theme] .header__content,
html[data-theme] #sidebar,
html[data-theme] main {
    transition: background-color 0.25s ease, color 0.25s ease;
}
