/* ==========================================================================
   Dark mode
   - Toggle <html data-theme="dark"> (Profile page ka Dark Mode toggle,
     layout ki head script 'pk-theme' localStorage se page load par lagati hai)
   - Primary and secondary colours are SWAPPED in dark mode.
   - Neutral black/grey palette (no blue tint) + all text white.
   - Load this file AFTER site.css and admin2.css.
   ========================================================================== */

/* ---------------------------------------------------------------------- */
/* Sidebar toggle switch (ab layout mein nahi, chahein to delete kar sakte  */
/* hain: sirf .sidebar-footer .theme-toggle aur .theme-switch ke rules)    */
/* ---------------------------------------------------------------------- */

.sidebar-footer .theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.85rem;
    margin: 0 0 0.2rem;
    border-radius: 10px;
    color: rgba(223, 230, 242, 0.7);
    font-size: 0.82rem;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

    .sidebar-footer .theme-toggle:hover {
        background: rgba(255, 255, 255, 0.07);
        color: #ffffff;
    }

    .sidebar-footer .theme-toggle i {
        width: 1.25rem;
        text-align: center;
    }

.theme-switch {
    position: relative;
    width: 38px;
    height: 20px;
    margin-left: auto;
    flex-shrink: 0;
}

    .theme-switch input {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }

    .theme-switch .slider {
        position: absolute;
        inset: 0;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.25);
        transition: background-color 0.2s ease;
    }

        .theme-switch .slider::before {
            content: "";
            position: absolute;
            top: 3px;
            left: 3px;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #ffffff;
            transition: transform 0.2s ease;
        }

    .theme-switch input:checked + .slider {
        background: var(--secondary-color);
    }

        .theme-switch input:checked + .slider::before {
            transform: translateX(18px);
        }

    .theme-switch input:focus-visible + .slider {
        box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.3);
    }

/* ---------------------------------------------------------------------- */
/* Dark palette                                                            */
/* ---------------------------------------------------------------------- */

html[data-theme="dark"] {
    color-scheme: dark;
    /* The swap */
    --primary-color: var(--theme-secondary);
    --secondary-color: var(--theme-primary);
    /* Neutrals: deep black, no blue tint */
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-alt: color-mix(in srgb, var(--surface) 92%, #fff);
    --border: #2a2a2a;
    --text: #ededed;
    --muted: #9a9a9a;
    /* Status backgrounds */
    --success-bg: rgba(31, 157, 85, 0.16);
    --danger-bg: rgba(214, 69, 90, 0.16);
    --warning-bg: rgba(201, 138, 27, 0.16);
    /* Tinted surface (hover rows, chips, avatars) */
    --secondary-light: color-mix(in srgb, var(--primary-color) 10%, var(--surface));
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.8);
    /* admin2.css table / pager variables */
    --tbl-head-bg: var(--surface-alt);
    --tbl-head-color: var(--muted);
    --tbl-border: var(--border);
    --tbl-hover: var(--secondary-light);
    --tbl-text: var(--text);
}

    /* ---------------------------------------------------------------------- */
    /* Sidebar gradient (dark only)                                            */
    /* ---------------------------------------------------------------------- */

    html[data-theme="dark"] .sidebar {
        background: radial-gradient(120% 40% at 0% 0%, rgba(255, 255, 255, 0.12) 0%, transparent 60%), linear-gradient(180deg, var(--primary-color) 0%, color-mix(in srgb, var(--primary-color) 55%, var(--secondary-color)) 55%, var(--secondary-dark) 100%);
    }

    /* ---------------------------------------------------------------------- */
    /* Base                                                                    */
    /* ---------------------------------------------------------------------- */

    html[data-theme="dark"] body {
        background: var(--bg);
        color: var(--text);
    }

    html[data-theme="dark"] .text-muted {
        color: var(--muted) !important;
    }

    html[data-theme="dark"] .bg-white,
    html[data-theme="dark"] .bg-light {
        background-color: var(--surface) !important;
    }

    html[data-theme="dark"] hr {
        border-top-color: var(--border);
    }

    /* ---------------------------------------------------------------------- */
    /* Surfaces                                                                */
    /* ---------------------------------------------------------------------- */

    html[data-theme="dark"] .card,
    html[data-theme="dark"] .modal-content,
    html[data-theme="dark"] .dropdown-menu,
    html[data-theme="dark"] .list-group-item,
    html[data-theme="dark"] .popover {
        background-color: var(--surface);
        border-color: var(--border);
        color: var(--text);
    }

    /* Shiny cards */
    html[data-theme="dark"] .card,
    html[data-theme="dark"] .modal-content,
    html[data-theme="dark"] .dashboard-stat-card,
    html[data-theme="dark"] .permission-module-card {
        background: linear-gradient(180deg, #1a1a1a 0%, #111111 100%);
        border-color: var(--border);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 8px 24px rgba(0, 0, 0, 0.6);
    }

    html[data-theme="dark"] .card-footer {
        background: var(--surface-alt);
    }

    html[data-theme="dark"] .modal-header,
    html[data-theme="dark"] .modal-footer {
        border-color: var(--border);
    }

    html[data-theme="dark"] .close {
        color: var(--text);
        text-shadow: none;
    }

    html[data-theme="dark"] .dropdown-divider {
        border-top-color: var(--border);
    }

    /* ---------------------------------------------------------------------- */
    /* Forms                                                                   */
    /* ---------------------------------------------------------------------- */

    html[data-theme="dark"] .form-control,
    html[data-theme="dark"] .custom-select,
    html[data-theme="dark"] .input-group-text {
        background-color: color-mix(in srgb, var(--surface) 80%, #000);
        border-color: var(--border);
        color: var(--text);
    }

        html[data-theme="dark"] .form-control:focus,
        html[data-theme="dark"] .custom-select:focus {
            background-color: color-mix(in srgb, var(--surface) 80%, #000);
            color: var(--text);
            border-color: rgba(255, 255, 255, 0.5);
        }

        html[data-theme="dark"] .form-control:disabled,
        html[data-theme="dark"] .form-control[readonly] {
            background-color: var(--surface-alt);
            color: var(--muted);
        }

        html[data-theme="dark"] .form-control::placeholder {
            color: var(--muted);
        }

    html[data-theme="dark"] .password-toggle-btn {
        background: var(--surface);
        border-color: var(--border);
        color: var(--muted);
    }

    /* ---------------------------------------------------------------------- */
    /* Buttons                                                                 */
    /* ---------------------------------------------------------------------- */

    html[data-theme="dark"] .btn-primary,
    html[data-theme="dark"] .pagination .page-item.active .page-link,
    html[data-theme="dark"] .pager .page-item.active .page-link {
        border-color: rgba(255, 255, 255, 0.25);
    }

    html[data-theme="dark"] .btn-outline-default {
        background-color: transparent;
        color: #ffffff;
        border-color: #ffffff !important;
    }

        html[data-theme="dark"] .btn-outline-default:hover {
            background-color: #ffffff !important;
            color: #000000 !important;
        }

    /* Dark mode toggle ON state */
    html[data-theme="dark"] .theme-switch input:checked + .slider {
        background: rgba(255, 255, 255, 0.4);
    }

    /* ---------------------------------------------------------------------- */
    /* Tables                                                                  */
    /* ---------------------------------------------------------------------- */

    html[data-theme="dark"] .table {
        color: var(--text);
    }

        html[data-theme="dark"] .table thead th {
            background: var(--surface-alt);
            color: var(--muted);
            border-bottom-color: var(--border);
        }

        html[data-theme="dark"] .table td,
        html[data-theme="dark"] .table th {
            border-color: var(--border);
        }

    html[data-theme="dark"] .table-hover tbody tr:hover {
        color: var(--text);
    }

    /* ---------------------------------------------------------------------- */
    /* Pagination                                                              */
    /* ---------------------------------------------------------------------- */

    html[data-theme="dark"] .pagination .page-link {
        background: var(--surface);
        border-color: var(--border);
        color: var(--text);
    }

    html[data-theme="dark"] .pagination .page-item.disabled .page-link {
        background: var(--surface-alt);
        border-color: var(--border);
        color: var(--muted);
    }

    html[data-theme="dark"] .pager {
        background: var(--surface);
        border-color: var(--border);
    }

        html[data-theme="dark"] .pager .page-item .page-link {
            background: transparent;
        }

        html[data-theme="dark"] .pager .page-item.active .page-link {
            background: var(--pager-active);
            color: #ffffff;
        }

    html[data-theme="dark"] .pager-info,
    html[data-theme="dark"] .pager-size {
        color: var(--muted);
    }

    /* ---------------------------------------------------------------------- */
    /* Badges, progress, alerts                                                */
    /* ---------------------------------------------------------------------- */

    html[data-theme="dark"] .badge-status-inactive,
    html[data-theme="dark"] .dashboard-progress-track {
        background: rgba(255, 255, 255, 0.08);
    }

    html[data-theme="dark"] .alert-success {
        color: #6fd6a0;
    }

    html[data-theme="dark"] .alert-danger {
        color: #f19aa7;
    }

    html[data-theme="dark"] .alert-warning {
        color: #e8c27a;
    }

    /* ---------------------------------------------------------------------- */
    /* Profile page                                                            */
    /* ---------------------------------------------------------------------- */

    /* Labels / chhota text: neela (#6b7490) kaali screen par nazar nahi aata */
    html[data-theme="dark"] .profile-row > label,
    html[data-theme="dark"] .profile-head small,
    html[data-theme="dark"] .profile-theme-row small {
        color: var(--muted);
    }

    /* Read-only inputs: text saaf padha jaye */
    html[data-theme="dark"] .profile-row .form-control[readonly] {
        background-color: var(--surface-alt);
        border-color: var(--border);
        color: var(--text);
    }

    /* Section ki line: theme ka rang kaala ho to gayab na ho */
    html[data-theme="dark"] .profile-section > h3 {
        border-bottom-color: rgba(255, 255, 255, 0.2);
    }

    /* Avatar (photo na ho to icon wala gola) */
    html[data-theme="dark"] .profile-avatar {
        background: var(--surface-alt);
        color: #ffffff;
        box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
    }

    /* Dark mode toggle: OFF = halka grey, ON = hara (kisi bhi theme color par nazar aaye) */
    html[data-theme="dark"] .profile-switch-slider {
        background: rgba(255, 255, 255, 0.25);
    }

    html[data-theme="dark"] .profile-switch input:checked + .profile-switch-slider {
        background: #1f9d55;
    }

    html[data-theme="dark"] .profile-switch input:focus-visible + .profile-switch-slider {
        box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.3);
    }

    /* Save button */
    html[data-theme="dark"] .profile-actions .btn-primary {
        background-color: var(--primary-color);
        border-color: rgba(255, 255, 255, 0.35);
        color: #ffffff;
    }

        html[data-theme="dark"] .profile-actions .btn-primary:hover,
        html[data-theme="dark"] .profile-actions .btn-primary:focus {
            background-color: rgba(255, 255, 255, 0.14);
            border-color: #ffffff;
            color: #ffffff;
        }

    /* ==========================================================================
   Dark mode: sara text safed
   (primary/secondary #000000 bhi ho to text black background par nazar aaye)
   ========================================================================== */

    html[data-theme="dark"] h1,
    html[data-theme="dark"] h2,
    html[data-theme="dark"] h3,
    html[data-theme="dark"] h4,
    html[data-theme="dark"] h5,
    html[data-theme="dark"] h6,
    html[data-theme="dark"] a,
    html[data-theme="dark"] a:hover,
    html[data-theme="dark"] .topbar-title,
    html[data-theme="dark"] .sidebar-toggle,
    html[data-theme="dark"] .card-header,
    html[data-theme="dark"] .avatar,
    html[data-theme="dark"] .btn-outline-secondary,
    html[data-theme="dark"] .btn-outline-secondary:hover,
    html[data-theme="dark"] .btn-outline-secondary:focus,
    html[data-theme="dark"] .dashboard-stat-icon--0,
    html[data-theme="dark"] .dashboard-stat-value,
    html[data-theme="dark"] .dashboard-status-count,
    html[data-theme="dark"] .permission-chip.is-checked,
    html[data-theme="dark"] .section-tabs .nav-link:hover,
    html[data-theme="dark"] .topbar-actions .dropdown-item:hover,
    html[data-theme="dark"] .topbar-actions .dropdown-item:focus,
    html[data-theme="dark"] .topbar-actions .dropdown-item:hover i,
    html[data-theme="dark"] .topbar-actions .nav-link .fa-circle-user {
        color: #ffffff;
    }

    /* Topbar user naam: site.css mein !important hai, isliye yahan bhi chahiye */
    html[data-theme="dark"] .topbar-actions .nav-link,
    html[data-theme="dark"] .topbar-actions .nav-link:hover {
        color: #ffffff !important;
    }
