/* ============================================================
   GMS shared light / night mode
   ============================================================ */

:root {
    --gms-scheme-bg: #f7f7f7;
    --gms-scheme-surface: #ffffff;
    --gms-scheme-surface-2: #f8fafc;
    --gms-scheme-text: #2a3f54;
    --gms-scheme-text-muted: #73879c;
    --gms-scheme-border: #e6e9ed;
    --gms-scheme-input-bg: #ffffff;
    --gms-scheme-input-border: #ccc;
    --gms-scheme-shadow: rgba(15, 23, 42, 0.08);
    --gms-toggle-track: #dbeafe;
    --gms-toggle-track-active: #1e293b;
    --gms-toggle-thumb: #ffffff;
    --gms-toggle-icon: #2563eb;
    --gms-toggle-icon-active: #fbbf24;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --gms-scheme-bg: #111827;
    --gms-scheme-surface: #1f2937;
    --gms-scheme-surface-2: #111827;
    --gms-scheme-text: #e5e7eb;
    --gms-scheme-text-muted: #9ca3af;
    --gms-scheme-border: #374151;
    --gms-scheme-input-bg: #111827;
    --gms-scheme-input-border: #4b5563;
    --gms-scheme-shadow: rgba(0, 0, 0, 0.35);
    --gms-toggle-track: #334155;
    --gms-toggle-track-active: #0f172a;
    --gms-toggle-thumb: #f8fafc;
    --gms-toggle-icon: #94a3b8;
    --gms-toggle-icon-active: #fbbf24;
}

/* ---- Toggle control ---- */

.gms-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--gms-scheme-border);
    background: var(--gms-scheme-surface);
    color: var(--gms-scheme-text);
    border-radius: 999px;
    padding: 6px 12px 6px 6px;
    cursor: pointer;
    font-family: 'Roboto Condensed', 'Segoe UI', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.35px;
    line-height: 1;
    box-shadow: 0 4px 14px var(--gms-scheme-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.gms-theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px var(--gms-scheme-shadow);
}

.gms-theme-toggle__track {
    position: relative;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: var(--gms-toggle-track);
    transition: background 0.25s ease;
    flex-shrink: 0;
}

.gms-theme-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gms-toggle-thumb);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.gms-theme-toggle__icon {
    width: 13px;
    height: 13px;
    position: absolute;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.gms-theme-toggle__icon-sun {
    color: var(--gms-toggle-icon);
    opacity: 1;
}

.gms-theme-toggle__icon-moon {
    color: var(--gms-toggle-icon-active);
    opacity: 0;
    transform: scale(0.7);
}

.gms-theme-toggle__text {
    min-width: 34px;
    text-align: left;
}

.gms-theme-toggle__label-dark,
.gms-theme-toggle[data-gms-theme-state="dark"] .gms-theme-toggle__label-light {
    display: none;
}

.gms-theme-toggle[data-gms-theme-state="dark"] .gms-theme-toggle__label-dark {
    display: inline;
}

.gms-theme-toggle[data-gms-theme-state="dark"] .gms-theme-toggle__track {
    background: var(--gms-toggle-track-active);
}

.gms-theme-toggle[data-gms-theme-state="dark"] .gms-theme-toggle__thumb {
    transform: translateX(20px);
}

.gms-theme-toggle[data-gms-theme-state="dark"] .gms-theme-toggle__icon-sun {
    opacity: 0;
    transform: scale(0.7);
}

.gms-theme-toggle[data-gms-theme-state="dark"] .gms-theme-toggle__icon-moon {
    opacity: 1;
    transform: scale(1);
}

.gms-theme-toggle--fixed {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2147483640;
}

.gms-theme-toggle--nav {
    margin: 10px 8px 0 0;
    padding: 5px 10px 5px 5px;
    gap: 8px;
    box-shadow: none;
}

.gms-theme-toggle--nav .gms-theme-toggle__text {
    display: none;
}

.gms-theme-nav-item {
    list-style: none;
    display: inline-block;
    vertical-align: middle;
}

.gms-theme-toggle--inline {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2147483640;
}

html[data-theme="dark"] .gms-theme-toggle--nav {
    background: var(--gms-scheme-surface);
    border-color: var(--gms-scheme-border);
    color: var(--gms-scheme-text);
}

/* ---- Portal (AdminLTE shell) ---- */

html[data-theme="dark"] body.nav-md,
html[data-theme="dark"] body.nav-sm {
    background: var(--gms-scheme-bg);
    color: var(--gms-scheme-text);
}

html[data-theme="dark"] body .container.body .right_col,
html[data-theme="dark"] .right_col {
    background: var(--gms-scheme-bg) !important;
    color: var(--gms-scheme-text);
}

html[data-theme="dark"] .nav_menu {
    background: var(--gms-scheme-surface) !important;
    border-bottom-color: var(--gms-scheme-border) !important;
}

html[data-theme="dark"] .top_nav .nav.navbar-nav > li > a,
html[data-theme="dark"] .nav_menu .school-name {
    color: var(--gms-scheme-text) !important;
}

html[data-theme="dark"] .x_panel,
html[data-theme="dark"] .x_content,
html[data-theme="dark"] .fn_header_global .x_panel {
    background: var(--gms-scheme-surface) !important;
    border-color: var(--gms-scheme-border) !important;
    color: var(--gms-scheme-text);
}

html[data-theme="dark"] .x_title {
    border-bottom-color: var(--gms-scheme-border) !important;
    color: var(--gms-scheme-text);
}

html[data-theme="dark"] .x_title h2,
html[data-theme="dark"] .x_title h2 small,
html[data-theme="dark"] label,
html[data-theme="dark"] .control-label {
    color: var(--gms-scheme-text) !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .select2-container--default .select2-selection--single,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple {
    background: var(--gms-scheme-input-bg) !important;
    border-color: var(--gms-scheme-input-border) !important;
    color: var(--gms-scheme-text) !important;
}

html[data-theme="dark"] .form-control:focus {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25);
}

html[data-theme="dark"] .table,
html[data-theme="dark"] .table > thead > tr > th,
html[data-theme="dark"] .table > tbody > tr > td,
html[data-theme="dark"] .table > tbody > tr > th {
    background: var(--gms-scheme-surface) !important;
    color: var(--gms-scheme-text) !important;
    border-color: var(--gms-scheme-border) !important;
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td,
html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > th {
    background: var(--gms-scheme-surface-2) !important;
}

html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .dropdown-usermenu,
html[data-theme="dark"] .msg_list {
    background: var(--gms-scheme-surface) !important;
    border-color: var(--gms-scheme-border) !important;
}

html[data-theme="dark"] .dropdown-menu > li > a,
html[data-theme="dark"] .dropdown-usermenu > li > a,
html[data-theme="dark"] .msg_list li a {
    color: var(--gms-scheme-text) !important;
}

html[data-theme="dark"] .dropdown-menu > li > a:hover,
html[data-theme="dark"] .dropdown-usermenu > li > a:hover,
html[data-theme="dark"] .msg_list li a:hover {
    background: rgba(148, 163, 184, 0.12) !important;
}

html[data-theme="dark"] footer,
html[data-theme="dark"] .footer {
    background: var(--gms-scheme-surface) !important;
    border-top: 1px solid var(--gms-scheme-border);
    color: var(--gms-scheme-text-muted) !important;
}

html[data-theme="dark"] .modal-content {
    background: var(--gms-scheme-surface);
    color: var(--gms-scheme-text);
    border-color: var(--gms-scheme-border);
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: var(--gms-scheme-border);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .well,
html[data-theme="dark"] .tile,
html[data-theme="dark"] .dashboard-widget,
html[data-theme="dark"] .widget_summary,
html[data-theme="dark"] .search_result {
    background: var(--gms-scheme-surface) !important;
    color: var(--gms-scheme-text) !important;
    border-color: var(--gms-scheme-border) !important;
}

html[data-theme="dark"] .search_result_container {
    background: rgba(15, 23, 42, 0.92) !important;
}

html[data-theme="dark"] .nav.toggle a,
html[data-theme="dark"] .info-number {
    color: var(--gms-scheme-text) !important;
}

html[data-theme="dark"] .dataTables_wrapper .dataTables_length,
html[data-theme="dark"] .dataTables_wrapper .dataTables_filter,
html[data-theme="dark"] .dataTables_wrapper .dataTables_info,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate {
    color: var(--gms-scheme-text-muted) !important;
}

html[data-theme="dark"] .pagination > li > a,
html[data-theme="dark"] .pagination > li > span {
    background: var(--gms-scheme-surface);
    border-color: var(--gms-scheme-border);
    color: var(--gms-scheme-text);
}

html[data-theme="dark"] .nav-tabs {
    border-bottom-color: var(--gms-scheme-border);
}

html[data-theme="dark"] .nav-tabs > li > a {
    color: var(--gms-scheme-text-muted);
}

html[data-theme="dark"] .nav-tabs > li.active > a,
html[data-theme="dark"] .nav-tabs > li.active > a:focus,
html[data-theme="dark"] .nav-tabs > li.active > a:hover {
    background: var(--gms-scheme-surface);
    border-color: var(--gms-scheme-border);
    color: var(--gms-scheme-text);
}

/* ---- Login / forgot password ---- */

html[data-theme="dark"] body.gms-login {
    background: #0b1220;
    color: #e5e7eb;
}

html[data-theme="dark"] .gms-login-bg {
    background-color: #0b1220;
    opacity: 0.35;
    filter: brightness(0.45) saturate(0.8);
}

html[data-theme="dark"] .gms-login-card,
html[data-theme="dark"] .gms-actions {
    background: #1f2937;
    border-color: #374151;
}

html[data-theme="dark"] .gms-login-card h1 {
    color: #5eead4;
}

html[data-theme="dark"] .gms-input {
    background: #111827;
    border-color: #374151;
    color: #e5e7eb;
}

html[data-theme="dark"] .gms-input:focus {
    background: #0f172a;
    border-color: #64748b;
}

html[data-theme="dark"] .gms-actions {
    border-top-color: #374151;
}

html[data-theme="dark"] .gms-btn-link {
    color: #5eead4;
}

html[data-theme="dark"] .gms-login-footer {
    color: #94a3b8;
}

/* ---- Landing (Granny Murray static mirror) ---- */

html[data-theme="dark"] body.font-montserrat {
    background: #0b1220;
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-white.text-left {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .bg-gray-200 {
    background-color: #111827 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .text-cus-darkblue {
    color: #bfdbfe !important;
}

html[data-theme="dark"] .shadow-lg {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45) !important;
}

html[data-theme="dark"] .font-semibold:not(.text-white),
html[data-theme="dark"] .font-bold:not(.text-white),
html[data-theme="dark"] p:not(.text-white),
html[data-theme="dark"] .text-sm:not(.text-white) {
    color: inherit;
}

html[data-theme="dark"] .text-gray-200 {
    color: #475569 !important;
}

html[data-theme="dark"] .gms-theme-toggle--fixed {
    background: rgba(15, 23, 42, 0.88);
    border-color: rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ---- Vema widget dark adjustments ---- */

html[data-theme="dark"] #vema-widget-root {
    --vema-bg: #1f2937;
    --vema-text: #e5e7eb;
    --vema-bot-bg: rgba(51, 65, 85, 0.72);
    --vema-border: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] #vema-chat-toolbar {
    background: linear-gradient(180deg, rgba(31, 41, 55, 0.98) 0%, rgba(17, 24, 39, 0.98) 100%);
}

html[data-theme="dark"] #vema-language-select,
html[data-theme="dark"] .vema-quick-btn,
html[data-theme="dark"] #vema-escalation {
    background: #111827;
    color: #e5e7eb;
}

html[data-theme="dark"] #vema-chat-messages {
    background:
        radial-gradient(circle at top right, rgba(51, 65, 85, 0.55) 0%, transparent 42%),
        #111827;
}

@media (max-width: 768px) {
    .gms-theme-toggle--fixed {
        top: auto;
        bottom: 92px;
        right: 14px;
    }

    body.nav-md .gms-theme-toggle--nav {
        margin-top: 4px;
    }
}

@media (max-width: 480px) {
    .gms-theme-toggle--fixed {
        bottom: 88px;
        padding: 5px 10px 5px 5px;
        gap: 8px;
    }

    .gms-theme-toggle--fixed .gms-theme-toggle__text {
        display: none;
    }
}
