/* ==========================================================
   PackForge Theme
   Public site keeps its existing dark visual language.
   Dashboard/Admin support light/dark themes.
========================================================== */

html { color-scheme: light; }
html[data-bs-theme="dark"] { color-scheme: dark; }
html[lang="en"] { color-scheme: dark; }

/* ----------------------------------------------------------
   Panel theme switch
---------------------------------------------------------- */
.pf-theme-switch-item {
    margin-inline: .45rem;
}

.pf-theme-switch {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 42px;
    padding-inline: .35rem;
    color: #64748b;
    user-select: none;
    white-space: nowrap;
}

.pf-theme-switch__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    font-size: .9rem;
    line-height: 1;
    opacity: .85;
}

.pf-theme-switch__text {
    min-width: 34px;
    font-size: .74rem;
    font-weight: 700;
    text-align: center;
}

.pf-theme-switch__control {
    position: relative;
    display: inline-flex;
    margin: 0;
    cursor: pointer;
}

.pf-theme-switch__control input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.pf-theme-switch__track {
    position: relative;
    display: block;
    width: 44px;
    height: 24px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #e2e8f0;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.pf-theme-switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .28);
    transition: transform .2s ease;
}

.pf-theme-switch__control input:checked + .pf-theme-switch__track {
    border-color: #3b82f6;
    background: #2563eb;
}

.pf-theme-switch__control input:checked + .pf-theme-switch__track .pf-theme-switch__thumb {
    transform: translateX(20px);
}

.pf-theme-switch__control input:focus-visible + .pf-theme-switch__track {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, .18);
}

html[lang="fa"][data-bs-theme="dark"] .pf-theme-switch {
    color: #cbd5e1;
}

html[lang="fa"][data-bs-theme="dark"] .pf-theme-switch__track {
    border-color: #475569;
    background: #334155;
}

/* ----------------------------------------------------------
   Dashboard/Admin dark palette
   IMPORTANT: html[data-bs-theme] is the source of truth.
   Do not depend on body.dark because the legacy template may
   mutate body classes when toggling/collapsing the sidebar.
---------------------------------------------------------- */
html[lang="fa"][data-bs-theme="dark"] {
    --pf-panel-bg: #0b1120;
    --pf-panel-nav: #0f172a;
    --pf-panel-surface: #111827;
    --pf-panel-surface-raised: #182235;
    --pf-panel-input: #162033;
    --pf-panel-input-focus: #1b2940;
    --pf-panel-border: #2a3a51;
    --pf-panel-text: #e2e8f0;
    --pf-panel-text-strong: #f8fafc;
    --pf-panel-muted: #94a3b8;
    --pf-panel-muted-2: #64748b;
    --pf-panel-primary: #3b82f6;
}

html[lang="fa"][data-bs-theme="dark"] body,
html[lang="fa"][data-bs-theme="dark"] body .main-wrapper,
html[lang="fa"][data-bs-theme="dark"] body .main-content,
html[lang="fa"][data-bs-theme="dark"] body .section,
html[lang="fa"][data-bs-theme="dark"] body .section-body {
    background-color: var(--pf-panel-bg) !important;
    color: var(--pf-panel-text) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-footer {
    border-top-color: var(--pf-panel-border) !important;
    background: var(--pf-panel-bg) !important;
    color: var(--pf-panel-muted) !important;
}

/* Top navbar */
html[lang="fa"][data-bs-theme="dark"] body .navbar-bg,
html[lang="fa"][data-bs-theme="dark"] body .main-navbar {
    background: var(--pf-panel-nav) !important;
    background-color: var(--pf-panel-nav) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-navbar {
    border-bottom: 1px solid var(--pf-panel-border) !important;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .18) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-navbar .nav-link,
html[lang="fa"][data-bs-theme="dark"] body .main-navbar .collapse-btn,
html[lang="fa"][data-bs-theme="dark"] body .main-navbar .nav-link-user,
html[lang="fa"][data-bs-theme="dark"] body .main-navbar svg,
html[lang="fa"][data-bs-theme="dark"] body .main-navbar i {
    color: #dbe7f5 !important;
    stroke: currentColor !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-navbar .nav-link:hover,
html[lang="fa"][data-bs-theme="dark"] body .main-navbar .nav-link:focus {
    color: #fff !important;
    background: rgba(255, 255, 255, .07) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-navbar .dropdown-menu {
    border: 1px solid var(--pf-panel-border) !important;
    background: var(--pf-panel-surface-raised) !important;
    color: var(--pf-panel-text) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .30) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-navbar .dropdown-title,
html[lang="fa"][data-bs-theme="dark"] body .main-navbar .dropdown-item {
    color: var(--pf-panel-text) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-navbar .dropdown-item:hover,
html[lang="fa"][data-bs-theme="dark"] body .main-navbar .dropdown-item:focus {
    background: rgba(59, 130, 246, .12) !important;
    color: #fff !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-navbar .dropdown-divider {
    border-top-color: var(--pf-panel-border) !important;
}

/* Sidebar including mini/collapsed mode */
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar.sidebar-style-2,
html[lang="fa"][data-bs-theme="dark"] body.sidebar-mini .main-sidebar,
html[lang="fa"][data-bs-theme="dark"] body.sidebar-gone .main-sidebar,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar #sidebar-wrapper,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-brand,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-user {
    background: var(--pf-panel-nav) !important;
    background-color: var(--pf-panel-nav) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-sidebar {
    border-inline-end: 1px solid var(--pf-panel-border) !important;
    box-shadow: none !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-brand a,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .logo-name,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .user-name {
    color: var(--pf-panel-text-strong) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .user-role,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .user-role span {
    color: var(--pf-panel-muted) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu > li > a,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu > li > a span,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu > li > a svg,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu > li > a i {
    color: #b8c6d9 !important;
    stroke: currentColor !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu > li > a:hover,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu > li.active > a {
    background: rgba(59, 130, 246, .13) !important;
    color: #fff !important;
}

/* Sidebar submenus */
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu li.dropdown > ul.dropdown-menu,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu li > ul.dropdown-menu,
html[lang="fa"][data-bs-theme="dark"] body.sidebar-mini .main-sidebar .sidebar-menu > li > ul.dropdown-menu {
    border: 0 !important;
    background: var(--pf-panel-surface) !important;
    background-color: var(--pf-panel-surface) !important;
    box-shadow: none !important;
}

html[lang="fa"][data-bs-theme="dark"] body.sidebar-mini .main-sidebar .sidebar-menu > li > ul.dropdown-menu {
    border: 1px solid var(--pf-panel-border) !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .30) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu li ul.dropdown-menu li,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu li ul.dropdown-menu li a,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu li ul.dropdown-menu li a span {
    background: transparent !important;
    color: #b8c6d9 !important;
}

html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu li ul.dropdown-menu li a:hover,
html[lang="fa"][data-bs-theme="dark"] body .main-sidebar .sidebar-menu li ul.dropdown-menu li.active > a {
    background: rgba(59, 130, 246, .12) !important;
    color: #fff !important;
}

/* Generic cards/surfaces */
html[lang="fa"][data-bs-theme="dark"] body .card,
html[lang="fa"][data-bs-theme="dark"] body .modal-content,
html[lang="fa"][data-bs-theme="dark"] body .list-group-item {
    border-color: var(--pf-panel-border) !important;
    background-color: var(--pf-panel-surface) !important;
    color: var(--pf-panel-text) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .card {
    border: 1px solid var(--pf-panel-border) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .card-header,
html[lang="fa"][data-bs-theme="dark"] body .card-footer {
    border-color: var(--pf-panel-border) !important;
    background-color: var(--pf-panel-surface-raised) !important;
    color: var(--pf-panel-text) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .card-body {
    background-color: var(--pf-panel-surface) !important;
    color: var(--pf-panel-text) !important;
}

/* Typography and old template utility classes */
html[lang="fa"][data-bs-theme="dark"] body h1,
html[lang="fa"][data-bs-theme="dark"] body h2,
html[lang="fa"][data-bs-theme="dark"] body h3,
html[lang="fa"][data-bs-theme="dark"] body h4,
html[lang="fa"][data-bs-theme="dark"] body h5,
html[lang="fa"][data-bs-theme="dark"] body h6,
html[lang="fa"][data-bs-theme="dark"] body .card-title,
html[lang="fa"][data-bs-theme="dark"] body .section-title,
html[lang="fa"][data-bs-theme="dark"] body .block-header h2,
html[lang="fa"][data-bs-theme="dark"] body label,
html[lang="fa"][data-bs-theme="dark"] body .form-label,
html[lang="fa"][data-bs-theme="dark"] body .text-black,
html[lang="fa"][data-bs-theme="dark"] body .text-gray-800,
html[lang="fa"][data-bs-theme="dark"] body .text-dark {
    color: var(--pf-panel-text-strong) !important;
}

html[lang="fa"][data-bs-theme="dark"] body p,
html[lang="fa"][data-bs-theme="dark"] body .form-text,
html[lang="fa"][data-bs-theme="dark"] body small,
html[lang="fa"][data-bs-theme="dark"] body .text-muted,
html[lang="fa"][data-bs-theme="dark"] body .text-gray-600,
html[lang="fa"][data-bs-theme="dark"] body .text-gray-500,
html[lang="fa"][data-bs-theme="dark"] body .text-gray-400,
html[lang="fa"][data-bs-theme="dark"] body .text-gray-300 {
    color: var(--pf-panel-muted) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .bg-light {
    background-color: var(--pf-panel-surface-raised) !important;
}

/* Forms: separate surface, not flat gray */
html[lang="fa"][data-bs-theme="dark"] body .form-control,
html[lang="fa"][data-bs-theme="dark"] body .form-select,
html[lang="fa"][data-bs-theme="dark"] body textarea.form-control,
html[lang="fa"][data-bs-theme="dark"] body .input-group-text {
    border: 1px solid #31435d !important;
    background-color: var(--pf-panel-input) !important;
    color: #eef4fb !important;
}

html[lang="fa"][data-bs-theme="dark"] body .form-control::placeholder,
html[lang="fa"][data-bs-theme="dark"] body textarea.form-control::placeholder {
    color: #7f91a8 !important;
    opacity: 1;
}

html[lang="fa"][data-bs-theme="dark"] body .form-control:focus,
html[lang="fa"][data-bs-theme="dark"] body .form-select:focus,
html[lang="fa"][data-bs-theme="dark"] body textarea.form-control:focus {
    border-color: var(--pf-panel-primary) !important;
    background-color: var(--pf-panel-input-focus) !important;
    color: #fff !important;
    box-shadow: 0 0 0 .2rem rgba(59, 130, 246, .14) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .form-control:disabled,
html[lang="fa"][data-bs-theme="dark"] body .form-control[readonly] {
    border-color: #27364b !important;
    background-color: #101a2a !important;
    color: #9aabc0 !important;
    opacity: 1;
}

html[lang="fa"][data-bs-theme="dark"] body .input-validation-error {
    border-color: #ef4444 !important;
    background-color: rgba(127, 29, 29, .18) !important;
}

/* Tables */
html[lang="fa"][data-bs-theme="dark"] body .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--pf-panel-text);
    --bs-table-border-color: var(--pf-panel-border);
    color: var(--pf-panel-text) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .table thead th {
    border-color: var(--pf-panel-border) !important;
    background: var(--pf-panel-surface-raised) !important;
    color: var(--pf-panel-text-strong) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .table tbody td {
    border-color: var(--pf-panel-border) !important;
    color: var(--pf-panel-text) !important;
}

/* Admin profile custom cards */
html[lang="fa"][data-bs-theme="dark"] body .mh-page-header {
    border-bottom-color: var(--pf-panel-border) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-page-header__title,
html[lang="fa"][data-bs-theme="dark"] body .mh-profile-card__title,
html[lang="fa"][data-bs-theme="dark"] body .mh-profile-item__value,
html[lang="fa"][data-bs-theme="dark"] body .mh-stat-card__value {
    color: var(--pf-panel-text-strong) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-page-header__subtitle,
html[lang="fa"][data-bs-theme="dark"] body .mh-profile-card__subtitle,
html[lang="fa"][data-bs-theme="dark"] body .mh-profile-item__label,
html[lang="fa"][data-bs-theme="dark"] body .mh-profile-item__label i,
html[lang="fa"][data-bs-theme="dark"] body .mh-stat-card__label {
    color: var(--pf-panel-muted) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-profile-card,
html[lang="fa"][data-bs-theme="dark"] body .mh-stat-card {
    border-color: var(--pf-panel-border) !important;
    background: var(--pf-panel-surface) !important;
    color: var(--pf-panel-text) !important;
    box-shadow: 0 8px 26px rgba(0, 0, 0, .16) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-profile-card:hover,
html[lang="fa"][data-bs-theme="dark"] body .mh-stat-card:hover {
    border-color: #3a4c66 !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .22) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-profile-card__header {
    border-bottom-color: var(--pf-panel-border) !important;
    background: var(--pf-panel-surface-raised) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-profile-item {
    border-bottom-color: var(--pf-panel-border) !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-code {
    background: #1d293b !important;
    color: #cbd5e1 !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-btn-outline {
    border-color: #64748b !important;
    background: #64748b !important;
    color: #fff !important;
}

html[lang="fa"][data-bs-theme="dark"] body .mh-btn-outline:hover {
    border-color: #475569 !important;
    background: #475569 !important;
    color: #fff !important;
}

/* Semantic buttons: keep meaning consistent across themes */
body .btn-primary { background-color: #2563eb; border-color: #2563eb; color: #fff; }
body .btn-primary:hover { background-color: #1d4ed8; border-color: #1d4ed8; color: #fff; }
body .btn-success { background-color: #16a34a; border-color: #16a34a; color: #fff; }
body .btn-success:hover { background-color: #15803d; border-color: #15803d; color: #fff; }
body .btn-danger { background-color: #dc2626; border-color: #dc2626; color: #fff; }
body .btn-danger:hover { background-color: #b91c1c; border-color: #b91c1c; color: #fff; }
body .btn-warning { background-color: #d97706; border-color: #d97706; color: #fff; }
body .btn-warning:hover { background-color: #b45309; border-color: #b45309; color: #fff; }
body .btn-secondary,
body .btn-outline-secondary {
    border-color: #64748b;
    background-color: #64748b;
    color: #fff;
}
body .btn-secondary:hover,
body .btn-outline-secondary:hover {
    border-color: #475569;
    background-color: #475569;
    color: #fff;
}

/* ----------------------------------------------------------
   Public site
---------------------------------------------------------- */
html[lang="en"] .mh-section .row.justify-content-center > .col-xl-7,
html[lang="en"] .mh-section .row.justify-content-center > .col-lg-8 {
    float: none;
    margin-inline: auto;
}

@media (prefers-reduced-motion: reduce) {
    .pf-theme-switch__track,
    .pf-theme-switch__thumb {
        transition: none;
    }
}
