/* ==========================================================================
   GLOBAL MULTI-THEME SWITCHER STYLESHEET
   12 Professional Themes & Glassmorphic Top-Right Dropdown Selector Widget
   ========================================================================== */

/* --- Top-Right Selector Widget Container --- */
#theme-switcher-widget {
    position: relative;
    z-index: 60;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

/* Fallback if attached directly to body (e.g. login page) */
body > #theme-switcher-widget {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 99999;
}

/* --- Top-Right Pill Trigger Button --- */
#theme-switcher-btn {
    height: 38px;
    padding: 0 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: #0f172a;
    outline: none;
    user-select: none;
    white-space: nowrap;
}

#theme-switcher-btn:hover {
    transform: translateY(-1px);
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 8px 18px -4px rgba(0, 0, 0, 0.1);
}

#theme-switcher-btn.panel-open {
    background: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.tsp-icon-palette {
    width: 16px;
    height: 16px;
    color: #3b82f6;
    transition: transform 0.3s ease;
}

#theme-switcher-btn:hover .tsp-icon-palette {
    transform: rotate(18deg) scale(1.08);
}

.tsp-btn-label {
    font-size: 12.5px;
    font-weight: 600;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.tsp-chevron {
    width: 13px;
    height: 13px;
    color: #64748b;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 1px;
}

#theme-switcher-btn.panel-open .tsp-chevron {
    transform: rotate(180deg);
    color: #3b82f6;
}

/* --- Top-Right Dropdown Panel (Opens Downwards) --- */
#theme-switcher-panel {
    position: absolute;
    top: 48px;
    right: 0;
    width: max-content;
    max-width: calc(100vw - 32px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.18), 0 10px 20px -5px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.96);
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    z-index: 999999;
}

#theme-switcher-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ==========================================================================
   TOP BAR FLEXBOX & RIGHT CONTAINER OVERFLOW FIXES
   ========================================================================== */
.top-bar {
    display: flex !important;
    align-items: center !important;
    padding-right: 1.5rem !important;
    padding-left: 1rem !important;
    position: relative !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

@media (min-width: 640px) {
    .top-bar {
        padding-right: 2.25rem !important;
        padding-left: 1.5rem !important;
    }
}

.top-bar__actions {
    display: flex !important;
    align-items: center !important;
    gap: 0.625rem !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
}

@media (min-width: 640px) {
    .top-bar__actions {
        gap: 0.875rem !important;
    }
}

/* Ensure theme switcher button perfectly matches top bar button heights and alignment */
#theme-switcher-widget {
    position: relative !important;
    z-index: 60 !important;
    display: inline-flex !important;
    align-items: center !important;
    align-self: center !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
}

#theme-switcher-btn {
    height: 36px !important;
    padding: 0 12px !important;
    border-radius: 18px !important;
    font-size: 12px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
}

#theme-switcher-btn .tsp-icon-palette {
    width: 15px !important;
    height: 15px !important;
}

#theme-switcher-btn .tsp-chevron {
    width: 12px !important;
    height: 12px !important;
}

/* Align search input height with buttons */
.top-bar .search .search__input {
    height: 36px !important;
    font-size: 12.5px !important;
    border-radius: 18px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.top-bar .search .search__icon {
    top: 0 !important;
    bottom: 0 !important;
    margin: auto 0 !important;
    height: 18px !important;
    width: 18px !important;
}

/* Reset stray margin-right on notification dropdown inside top-bar */
.top-bar .dropdown.mr-auto {
    margin-right: 0 !important;
}

.top-bar .breadcrumb.mr-auto {
    margin-right: auto !important;
}

/* Ensure dropdown contents stay within viewport limits and visible */
.top-bar .dropdown-menu {
    z-index: 99999 !important;
}

.top-bar .notification-content {
    right: 0 !important;
    left: auto !important;
    max-width: calc(100vw - 32px) !important;
}

/* Fix user account avatar container alignment */
.top-bar .account-dropdown {
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
}

.top-bar .account-dropdown .dropdown-toggle {
    width: 34px !important;
    height: 34px !important;
}

/* Panel Header */
.tsp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.tsp-title {
    font-weight: 700;
    font-size: 12px;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tsp-title svg {
    color: #3b82f6;
}

.tsp-count-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f1f5f9;
    color: #475569;
}

/* Single-Line Horizontal Row Layout for 6 Themes */
.tsp-grid {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    white-space: nowrap;
}

.tsp-grid::-webkit-scrollbar {
    height: 4px;
}
.tsp-grid::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Individual Theme Option Item - Clean, Legible, High-Contrast */
.tsp-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1.5px solid rgba(226, 232, 240, 0.9);
    background: #ffffff;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
    flex-shrink: 0;
}

.tsp-option:hover {
    border-color: #3b82f6;
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
}

.tsp-option.active {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.tsp-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4), 0 2px 5px rgba(0, 0, 0, 0.2);
    position: relative;
    transition: transform 0.2s ease;
}

.tsp-option:hover .tsp-swatch {
    transform: scale(1.12);
}

.tsp-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
}

.tsp-check {
    width: 14px;
    height: 14px;
    color: #2563eb;
    opacity: 0;
    transition: opacity 0.18s ease;
    flex-shrink: 0;
}

.tsp-option.active .tsp-check {
    opacity: 1;
}

/* Dark Mode Adaptation for Widget */
html[data-theme="dark"] #theme-switcher-btn,
html[data-theme="high-contrast"] #theme-switcher-btn,
html[data-theme="funky"] #theme-switcher-btn {
    background: rgba(15, 23, 42, 0.88);
    border-color: rgba(51, 65, 85, 0.8);
    color: #f8fafc;
}

html[data-theme="dark"] .tsp-btn-label,
html[data-theme="high-contrast"] .tsp-btn-label,
html[data-theme="funky"] .tsp-btn-label {
    color: #f8fafc;
}

html[data-theme="dark"] #theme-switcher-panel,
html[data-theme="high-contrast"] #theme-switcher-panel,
html[data-theme="funky"] #theme-switcher-panel {
    background: rgba(15, 23, 42, 0.96);
    border-color: rgba(51, 65, 85, 0.9);
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .tsp-title,
html[data-theme="high-contrast"] .tsp-title,
html[data-theme="funky"] .tsp-title {
    color: #f8fafc;
}

html[data-theme="dark"] .tsp-header,
html[data-theme="high-contrast"] .tsp-header,
html[data-theme="funky"] .tsp-header {
    border-bottom-color: rgba(51, 65, 85, 0.8);
}

html[data-theme="dark"] .tsp-count-badge,
html[data-theme="high-contrast"] .tsp-count-badge,
html[data-theme="funky"] .tsp-count-badge {
    background: #334155;
    color: #94a3b8;
}

html[data-theme="dark"] .tsp-option,
html[data-theme="high-contrast"] .tsp-option,
html[data-theme="funky"] .tsp-option {
    background: #1e293b;
    border-color: rgba(51, 65, 85, 0.8);
}

html[data-theme="dark"] .tsp-option:hover,
html[data-theme="high-contrast"] .tsp-option:hover,
html[data-theme="funky"] .tsp-option:hover {
    background: #334155;
    border-color: #64748b;
}

html[data-theme="dark"] .tsp-name,
html[data-theme="high-contrast"] .tsp-name,
html[data-theme="funky"] .tsp-name {
    color: #f1f5f9;
}

html[data-theme="dark"] .tsp-option.active,
html[data-theme="high-contrast"] .tsp-option.active,
html[data-theme="funky"] .tsp-option.active {
    background: #1e3a8a;
    border-color: #3b82f6;
}

/* ==========================================================================
   12 THEME DEFINITIONS & LOGIN PAGE ADAPTATIONS
   ========================================================================== */

/* --- LOGIN PAGE FIT & ZERO SCROLLING --- */
body.login {
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.main {
    overflow-y: auto !important;
}


body.login .container {
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}

body.login .container > div {
    height: 100vh !important;
    max-height: 100vh !important;
    align-items: center !important;
}

body.login .hidden.xl\:flex,
body.login .xl\:flex {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100vh !important;
}

body.login .h-screen {
    height: auto !important;
    max-height: 100vh !important;
}

body.login .my-10 {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* --- LOGIN BOX ENHANCED CARD & SHADOW --- */
body.login .my-auto.mx-auto {
    background: #ffffff !important;
    padding: 2.5rem !important;
    border-radius: 1.25rem !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 10px 25px -5px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
    width: 100% !important;
    max-width: 440px !important;
    margin-top: auto !important;
    margin-bottom: auto !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* Form Heading */
body.login h2 {
    color: #0f172a !important;
    font-weight: 700 !important;
}

/* Form Inputs */
body.login .login__input,
body.login .form-control {
    background-color: #f8fafc !important;
    border: 1.5px solid #cbd5e1 !important;
    color: #0f172a !important;
    border-radius: 0.6rem !important;
    font-size: 0.95rem !important;
}

body.login .login__input::placeholder,
body.login .form-control::placeholder {
    color: #94a3b8 !important;
}

body.login .login__input:focus,
body.login .form-control:focus {
    background-color: #ffffff !important;
    border-color: var(--theme-primary, #2563eb) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

/* Checkbox & Secondary Text */
body.login label,
body.login .text-gray-700,
body.login .text-gray-600,
body.login .intro-x.mt-10,
body.login .intro-x.mt-2 {
    color: #475569 !important;
}

/* Links */
body.login a[href="javascript:;"],
body.login a.text-theme-1 {
    color: var(--theme-primary, #2563eb) !important;
    font-weight: 600 !important;
}

/* Secondary Button */
body.login .btn-outline-secondary {
    border-color: #cbd5e1 !important;
    color: #334155 !important;
    background: #f8fafc !important;
    font-weight: 600 !important;
}

body.login .btn-outline-secondary:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

/* --- DARK MODE LOGIN CARD ADJUSTMENTS --- */
html[data-theme="dark"] body.login .my-auto.mx-auto,
html[data-theme="high-contrast"] body.login .my-auto.mx-auto,
html[data-theme="funky"] body.login .my-auto.mx-auto {
    background: rgba(26, 34, 52, 0.94) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="dark"] body.login h2,
html[data-theme="high-contrast"] body.login h2,
html[data-theme="funky"] body.login h2 {
    color: #ffffff !important;
}

html[data-theme="dark"] body.login .login__input,
html[data-theme="dark"] body.login .form-control,
html[data-theme="high-contrast"] body.login .login__input,
html[data-theme="high-contrast"] body.login .form-control,
html[data-theme="funky"] body.login .login__input,
html[data-theme="funky"] body.login .form-control {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

html[data-theme="dark"] body.login .login__input::placeholder,
html[data-theme="high-contrast"] body.login .login__input::placeholder,
html[data-theme="funky"] body.login .login__input::placeholder {
    color: #94a3b8 !important;
}

html[data-theme="dark"] body.login label,
html[data-theme="dark"] body.login .text-gray-700,
html[data-theme="dark"] body.login .text-gray-600,
html[data-theme="dark"] body.login .intro-x.mt-10,
html[data-theme="dark"] body.login .intro-x.mt-2,
html[data-theme="high-contrast"] body.login label,
html[data-theme="high-contrast"] body.login .text-gray-700,
html[data-theme="high-contrast"] body.login .text-gray-600,
html[data-theme="high-contrast"] body.login .intro-x.mt-10,
html[data-theme="high-contrast"] body.login .intro-x.mt-2,
html[data-theme="funky"] body.login label,
html[data-theme="funky"] body.login .text-gray-700,
html[data-theme="funky"] body.login .text-gray-600,
html[data-theme="funky"] body.login .intro-x.mt-10,
html[data-theme="funky"] body.login .intro-x.mt-2 {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] body.login a[href="javascript:;"],
html[data-theme="dark"] body.login a.text-theme-1,
html[data-theme="high-contrast"] body.login a[href="javascript:;"],
html[data-theme="high-contrast"] body.login a.text-theme-1,
html[data-theme="funky"] body.login a[href="javascript:;"],
html[data-theme="funky"] body.login a.text-theme-1 {
    color: #38bdf8 !important;
}

html[data-theme="dark"] body.login .btn-outline-secondary,
html[data-theme="high-contrast"] body.login .btn-outline-secondary,
html[data-theme="funky"] body.login .btn-outline-secondary {
    border-color: #475569 !important;
    color: #f8fafc !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="dark"] body.login .btn-outline-secondary:hover,
html[data-theme="high-contrast"] body.login .btn-outline-secondary:hover,
html[data-theme="funky"] body.login .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

/* Smooth transition when changing themes */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *:before,
html.theme-transitioning *:after {
    transition: background-color 0.35s ease, border-color 0.35s ease, color 0.35s ease !important;
}

/* 1. Default (Sapphire Blue) */
html[data-theme="default"] {
    --theme-primary: #1c3faa;
}

/* 2. Slate Dark Theme */
html[data-theme="dark"] body {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] body.login:before {
    filter: brightness(0.4) contrast(1.2);
}
html[data-theme="dark"] .login .btn-primary {
    background-color: #2563eb !important;
    border-color: #2563eb !important;
}

/* 3. Pure Light Theme */
html[data-theme="light"] body {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

/* 4. High Contrast Theme */
html[data-theme="high-contrast"] body {
    background-color: #000000 !important;
    color: #ffffff !important;
}
html[data-theme="high-contrast"] .box,
html[data-theme="high-contrast"] .side-nav,
html[data-theme="high-contrast"] .top-bar {
    background-color: #111111 !important;
    border: 1px solid #ffffff !important;
}
html[data-theme="high-contrast"] .btn-primary {
    background-color: #ffff00 !important;
    color: #000000 !important;
    font-weight: 700 !important;
    border-color: #ffff00 !important;
}

/* 5. Emerald Teal Theme */
html[data-theme="olive-green"] {
    --theme-primary: #059669;
}
html[data-theme="olive-green"] body {
    background-color: #f0fdf4 !important;
}
html[data-theme="olive-green"] .btn-primary,
html[data-theme="olive-green"] .bg-theme-1 {
    background-color: #059669 !important;
    border-color: #059669 !important;
    color: #ffffff !important;
}
html[data-theme="olive-green"] .text-theme-1 {
    color: #059669 !important;
}
html[data-theme="olive-green"] .side-menu--active {
    background-color: #047857 !important;
}

/* 6. Royal Indigo Theme */
html[data-theme="blue"] {
    --theme-primary: #4f46e5;
}
html[data-theme="blue"] body {
    background-color: #eef2ff !important;
}
html[data-theme="blue"] .btn-primary,
html[data-theme="blue"] .bg-theme-1 {
    background-color: #4f46e5 !important;
    border-color: #4f46e5 !important;
    color: #ffffff !important;
}
html[data-theme="blue"] .text-theme-1 {
    color: #4f46e5 !important;
}
html[data-theme="blue"] .side-menu--active {
    background-color: #4338ca !important;
}

/* 7. Luxe Violet Theme */
html[data-theme="purple"] {
    --theme-primary: #7c3aed;
}
html[data-theme="purple"] body {
    background-color: #f5f3ff !important;
}
html[data-theme="purple"] .btn-primary,
html[data-theme="purple"] .bg-theme-1 {
    background-color: #7c3aed !important;
    border-color: #7c3aed !important;
    color: #ffffff !important;
}
html[data-theme="purple"] .text-theme-1 {
    color: #7c3aed !important;
}
html[data-theme="purple"] .side-menu--active {
    background-color: #6d28d9 !important;
}

/* 8. Sunset Amber Theme */
html[data-theme="amber"] {
    --theme-primary: #d97706;
}
html[data-theme="amber"] body {
    background-color: #fffbeb !important;
}
html[data-theme="amber"] .btn-primary,
html[data-theme="amber"] .bg-theme-1 {
    background-color: #d97706 !important;
    border-color: #d97706 !important;
    color: #ffffff !important;
}
html[data-theme="amber"] .text-theme-1 {
    color: #b45309 !important;
}
html[data-theme="amber"] .side-menu--active {
    background-color: #b45309 !important;
    color: #ffffff !important;
}

/* 9. Ocean Cyan Theme */
html[data-theme="colorful"] {
    --theme-primary: #0891b2;
}
html[data-theme="colorful"] body {
    background-color: #ecfeff !important;
}
html[data-theme="colorful"] .btn-primary,
html[data-theme="colorful"] .bg-theme-1 {
    background-color: #0891b2 !important;
    border-color: #0891b2 !important;
    color: #ffffff !important;
}
html[data-theme="colorful"] .text-theme-1 {
    color: #0891b2 !important;
}
html[data-theme="colorful"] .side-menu--active {
    background-color: #0e7490 !important;
}

/* 10. Crimson Velvet Theme */
html[data-theme="red"] {
    --theme-primary: #dc2626;
}
html[data-theme="red"] body {
    background-color: #fef2f2 !important;
}
html[data-theme="red"] .btn-primary,
html[data-theme="red"] .bg-theme-1 {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
}
html[data-theme="red"] .text-theme-1 {
    color: #dc2626 !important;
}
html[data-theme="red"] .side-menu--active {
    background-color: #b91c1c !important;
}

/* 11. Rose Gold Theme */
html[data-theme="pink"] {
    --theme-primary: #e11d48;
}
html[data-theme="pink"] body {
    background-color: #fff1f2 !important;
}
html[data-theme="pink"] .btn-primary,
html[data-theme="pink"] .bg-theme-1 {
    background-color: #e11d48 !important;
    border-color: #e11d48 !important;
    color: #ffffff !important;
}
html[data-theme="pink"] .text-theme-1 {
    color: #e11d48 !important;
}
html[data-theme="pink"] .side-menu--active {
    background-color: #be123c !important;
}

/* 12. Cyber Neon Theme */
html[data-theme="funky"] {
    --theme-primary: #6366f1;
}
html[data-theme="funky"] body {
    background-color: #0b0f19 !important;
    color: #f3e8ff !important;
}
html[data-theme="funky"] .box {
    background-color: #151c2c !important;
    border: 1px solid #2d3748 !important;
}
html[data-theme="funky"] .btn-primary,
html[data-theme="funky"] .bg-theme-1 {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%) !important;
    border-color: transparent !important;
    color: #ffffff !important;
    font-weight: 600 !important;
}
html[data-theme="funky"] .text-theme-1 {
    color: #818cf8 !important;
}
html[data-theme="funky"] .side-menu--active {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
    color: #ffffff !important;
}

