/* Halloween — night orchard: pumpkin orange, grape-purple, candle gold. */

[data-theme="halloween"] {
    --primary-bg: #0c0610;
    --surface-1: rgba(28, 14, 22, 0.78);
    --surface-2: rgba(36, 18, 28, 0.94);
    --card-bg: rgba(28, 14, 22, 0.82);
    --card-bg-elevated: rgba(40, 20, 30, 0.9);

    --text-color: #fff4e8;
    --text-muted: #c9b09a;
    --text-faint: #8a7064;

    --accent-color: #ff7a18;
    --accent-hover: #ff9a3c;
    --accent-strong: #e85d04;
    --accent-color-rgb: 255, 122, 24;
    --accent-soft: #ffc14d;

    --sidebar-bg: #100814;
    --sidebar-text: #c9b09a;
    --sidebar-border: rgba(255, 154, 60, 0.14);
    --sidebar-item-hover: rgba(255, 122, 24, 0.1);
    --sidebar-shadow: 1px 0 0 rgba(255, 154, 60, 0.08), 12px 0 40px rgba(0, 0, 0, 0.55);

    --input-bg: rgba(255, 180, 80, 0.06);
    --input-border: rgba(255, 154, 60, 0.28);
    --input-text: #fff4e8;
    --input-placeholder: #8a7064;

    --hairline: rgba(255, 154, 60, 0.16);
    --hairline-strong: rgba(255, 154, 60, 0.28);
    --accent-border: rgba(255, 122, 24, 0.5);
    --border-color: rgba(255, 154, 60, 0.16);

    --card-shadow:
        inset 0 1px 0 rgba(255, 200, 120, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.45),
        0 16px 48px rgba(80, 20, 0, 0.28);
    --modal-shadow:
        inset 0 1px 0 rgba(255, 200, 120, 0.12),
        0 32px 80px rgba(0, 0, 0, 0.72);

    --table-head-bg: rgba(255, 122, 24, 0.08);
    --table-head-text: #ffc14d;
    --table-hover-bg: rgba(255, 122, 24, 0.08);

    --kurenai-logo-filter: brightness(0) saturate(100%) invert(62%) sepia(86%) saturate(1800%) hue-rotate(345deg) brightness(102%) contrast(104%);

    --topnav-scrollbar-track: rgba(255, 154, 60, 0.12);
    --topnav-scrollbar-thumb: rgba(255, 122, 24, 0.55);
    --topnav-scrollbar-thumb-hover: rgba(255, 193, 77, 0.75);
}

html[data-theme="halloween"] {
    background-color: #0c0610 !important;
}

/* Do not use body::before/position:relative on .app-topnav: body is display:flex,
   and those become a 100% row item — dashboard widgets collapse to the right edge. */
html[data-theme="halloween"] body:not(.login-page) {
    display: block !important;
}

body[data-theme="halloween"],
[data-theme="halloween"] body {
    color: var(--text-color);
    background-color: #0c0610;
    background-image:
        radial-gradient(900px 480px at 88% 8%, rgba(255, 154, 60, 0.16) 0%, transparent 58%),
        radial-gradient(700px 520px at 8% 92%, rgba(123, 44, 191, 0.22) 0%, transparent 62%),
        radial-gradient(500px 360px at 50% 100%, rgba(232, 93, 4, 0.1) 0%, transparent 55%),
        linear-gradient(180deg, #14081a 0%, #0c0610 42%, #160a12 100%);
    background-attachment: fixed;
}

html[data-theme="halloween"]::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle 140px at 88% 10%, rgba(255, 236, 190, 0.22) 0%, rgba(255, 154, 60, 0.08) 36%, transparent 62%),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='280' height='180'><path d='M0 0 C40 30 20 70 55 90 M0 0 C70 20 90 10 120 40 M55 90 C80 70 110 110 140 80' stroke='%23d4a574' stroke-width='1.1' fill='none' opacity='0.35'/></svg>") top left / 280px 180px no-repeat,
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='160'><path d='M240 0 C200 28 220 72 185 92 M240 0 C170 16 150 8 120 42' stroke='%23d4a574' stroke-width='1.1' fill='none' opacity='0.28'/></svg>") top right / 240px 160px no-repeat;
}

body[data-theme="halloween"]::before,
[data-theme="halloween"] body::before,
body[data-theme="halloween"]::after,
[data-theme="halloween"] body::after {
    content: none !important;
}

/* body is display:flex. flex:none + width:100vw still eats the row (basis:auto).
   Zero basis so rain stays a viewport overlay and .main-wrapper keeps the grid. */
#halloween-fx-root,
#halloween-canvas,
.hw-prompt {
    position: fixed !important;
    flex: 0 0 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    margin: 0 !important;
}

#halloween-fx-root {
    top: 0;
    left: 0;
    width: 0 !important;
    height: 0 !important;
    overflow: visible !important;
    pointer-events: none;
    z-index: 0;
}

#halloween-canvas {
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    pointer-events: none;
    z-index: 0;
}

.hw-prompt {
    inset: 0;
    width: auto;
    height: auto;
    z-index: 6000;
}

[data-theme="halloween"] .sidebar,
[data-theme="halloween"] .main-wrapper {
    position: relative;
    z-index: 1;
}

[data-theme="halloween"] .app-topnav {
    position: fixed !important;
    z-index: 999;
}

[data-theme="halloween"] .main-wrapper {
    display: flex;
    flex-direction: column;
    width: 100% !important;
    max-width: none;
    min-width: 0;
}

[data-theme="halloween"] .sidebar,
[data-theme="halloween"] .main-wrapper,
[data-theme="halloween"] .scroll-area,
[data-theme="halloween"] .main-content {
    background: transparent !important;
}

[data-theme="halloween"] .app-topnav,
[data-theme="halloween"] .topbar,
[data-theme="halloween"] .top-header {
    background: rgba(16, 8, 20, 0.88) !important;
    border-bottom: 1px solid var(--hairline) !important;
    box-shadow: 0 1px 0 rgba(255, 200, 120, 0.06), 0 12px 36px rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: saturate(150%) blur(20px);
    -webkit-backdrop-filter: saturate(150%) blur(20px);
    color: #fff4e8 !important;
}

[data-theme="halloween"] .top-header h1,
[data-theme="halloween"] .top-header h2,
[data-theme="halloween"] .top-header h3,
[data-theme="halloween"] .top-header h4,
[data-theme="halloween"] .top-header h5,
[data-theme="halloween"] .top-header h6 {
    color: #fff4e8 !important;
}

[data-theme="halloween"] .nav-trigger,
[data-theme="halloween"] .nav-trigger .nav-caret {
    color: #fff4e8 !important;
}

[data-theme="halloween"] .nav-trigger:hover,
[data-theme="halloween"] .nav-group.open > .nav-trigger {
    background: rgba(255, 122, 24, 0.12) !important;
}

[data-theme="halloween"] .nav-trigger i:not(.nav-caret) {
    color: var(--accent-color) !important;
}

[data-theme="halloween"] .logo-shimmer img.logo-icon {
    filter: var(--kurenai-logo-filter);
}

[data-theme="halloween"] .logo-wordmark .wm-support,
[data-theme="halloween"] .login-wordmark .wm-support {
    color: var(--accent-color) !important;
}

[data-theme="halloween"] .logo-wordmark .wm-hub,
[data-theme="halloween"] .login-wordmark .wm-hub {
    color: #fff4e8 !important;
}

[data-theme="halloween"] .topnav-brand {
    position: relative;
    z-index: 9;
}

[data-theme="halloween"] .logo-wordmark,
[data-theme="halloween"] .login-wordmark {
    align-items: center;
}

[data-theme="halloween"] .logo-wordmark::after,
[data-theme="halloween"] .login-wordmark::after {
    content: "🎃";
    display: inline-block;
    margin-left: 7px;
    font-size: 1.15rem;
    line-height: 1;
    transform-origin: 50% 80%;
    animation: hw-logo-bob 2.6s ease-in-out infinite;
}

@keyframes hw-logo-bob {
    0%, 100% { transform: rotate(-8deg) translateY(0); }
    50% { transform: rotate(8deg) translateY(-2px); }
}

[data-theme="halloween"] .logo-subtitle {
    color: rgba(255, 244, 232, 0.5);
}

[data-theme="halloween"] .logo-tagline-accent {
    color: #ffc14d;
    text-shadow: 0 0 16px rgba(255, 193, 77, 0.45);
}

[data-theme="halloween"] .nav-dropdown-menu,
[data-theme="halloween"] .dropdown-menu,
[data-theme="halloween"] .topnav-notif-panel,
[data-theme="halloween"] .modal-content,
[data-theme="halloween"] .card,
[data-theme="halloween"] .crm-card {
    background: rgba(32, 16, 26, 0.88) !important;
    border: 1px solid var(--hairline) !important;
    color: var(--text-color) !important;
    box-shadow: var(--card-shadow) !important;
}

[data-theme="halloween"] h1,
[data-theme="halloween"] h2,
[data-theme="halloween"] h3,
[data-theme="halloween"] h4,
[data-theme="halloween"] h5,
[data-theme="halloween"] h6 {
    color: #fff4e8;
}

[data-theme="halloween"] .text-muted,
[data-theme="halloween"] .text-dark {
    color: var(--text-muted) !important;
}

[data-theme="halloween"] .text-primary {
    color: var(--accent-soft) !important;
}

[data-theme="halloween"] a {
    color: var(--accent-soft);
}

[data-theme="halloween"] a:hover {
    color: #ffffff;
}

[data-theme="halloween"] .btn-primary,
[data-theme="halloween"] .btn-accent {
    background: linear-gradient(180deg, #ff9a3c 0%, #e85d04 100%) !important;
    border: 1px solid rgba(255, 193, 77, 0.45) !important;
    color: #1a0c08 !important;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 6px 18px rgba(232, 93, 4, 0.35) !important;
}

[data-theme="halloween"] .btn-primary:hover,
[data-theme="halloween"] .btn-accent:hover {
    filter: brightness(1.08);
    color: #1a0c08 !important;
}

[data-theme="halloween"] .btn-outline-primary,
[data-theme="halloween"] .btn-outline-secondary,
[data-theme="halloween"] .btn-secondary {
    background: rgba(255, 122, 24, 0.08) !important;
    border-color: var(--hairline-strong) !important;
    color: var(--text-color) !important;
}

[data-theme="halloween"] .form-control,
[data-theme="halloween"] .form-select,
[data-theme="halloween"] .topnav-theme {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
}

[data-theme="halloween"] .form-control:focus,
[data-theme="halloween"] .form-select:focus {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.22) !important;
}

[data-theme="halloween"] .table thead th {
    background: var(--table-head-bg) !important;
    color: var(--table-head-text) !important;
    border-bottom-color: var(--hairline) !important;
}

[data-theme="halloween"] .table tbody td {
    border-color: var(--hairline) !important;
    color: var(--text-color);
}

[data-theme="halloween"] .table tbody tr:hover > td {
    background: var(--table-hover-bg) !important;
}

[data-theme="halloween"] .badge.bg-primary {
    background: linear-gradient(180deg, #ff9a3c, #e85d04) !important;
    color: #1a0c08 !important;
}

[data-theme="halloween"] .nav-link.active,
[data-theme="halloween"] .nav-item.active {
    background: rgba(255, 122, 24, 0.14) !important;
    color: #fff4e8 !important;
    box-shadow: inset 3px 0 0 var(--accent-color) !important;
}

[data-theme="halloween"] .btn-close {
    filter: invert(1) brightness(1.6) sepia(1) hue-rotate(8deg);
}

[data-theme="halloween"] .bg-light,
[data-theme="halloween"] .bg-white {
    background-color: var(--card-bg-elevated) !important;
    color: var(--text-color) !important;
}

[data-theme="halloween"] .alert {
    background: rgba(255, 122, 24, 0.08) !important;
    border-color: var(--hairline) !important;
    color: var(--text-color) !important;
}

[data-theme="halloween"] .chat-widget-launcher {
    background: linear-gradient(180deg, #ff9a3c, #e85d04) !important;
    box-shadow: 0 8px 24px rgba(232, 93, 4, 0.4) !important;
}

[data-theme="halloween"] .chat-widget-panel,
[data-theme="halloween"] .app-toast {
    background: var(--surface-2) !important;
    border-color: var(--hairline) !important;
}

body.login-page[data-theme="halloween"] {
    background: #0c0610 !important;
    background-image:
        radial-gradient(900px 560px at 50% 8%, rgba(255, 154, 60, 0.16) 0%, transparent 62%),
        radial-gradient(700px 480px at 100% 100%, rgba(123, 44, 191, 0.18) 0%, transparent 60%) !important;
}

[data-theme="halloween"] body.login-page .login-card {
    background: var(--surface-2) !important;
    border: 1px solid var(--hairline);
    color: #fff4e8;
    box-shadow: var(--modal-shadow);
}

[data-theme="halloween"] body.login-page .login-card h4,
[data-theme="halloween"] body.login-page .login-card .text-muted,
[data-theme="halloween"] body.login-page .login-card small {
    color: var(--text-muted) !important;
}

[data-theme="halloween"] body.login-page .login-card h4 {
    color: #fff4e8 !important;
}

[data-theme="halloween"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 122, 24, 0.45);
    border-radius: 999px;
}

/* Full-screen launch prompt */
.hw-prompt {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at 80% 12%, rgba(255, 200, 120, 0.16), transparent 28%),
        radial-gradient(circle at 12% 88%, rgba(123, 44, 191, 0.28), transparent 36%),
        rgba(8, 4, 10, 0.86);
    backdrop-filter: blur(10px);
}

.hw-prompt-card {
    width: min(520px, 100%);
    background: linear-gradient(180deg, rgba(48, 22, 28, 0.98), rgba(18, 8, 16, 0.98));
    border: 1px solid rgba(255, 154, 60, 0.4);
    border-radius: 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 40px rgba(255, 122, 24, 0.12);
    padding: 28px 26px 24px;
    color: #fff4e8;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hw-prompt-card::before {
    content: "🕸️";
    position: absolute;
    top: 8px;
    left: 10px;
    font-size: 1.4rem;
    opacity: 0.55;
}

.hw-prompt-card::after {
    content: "🕸️";
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 1.4rem;
    opacity: 0.55;
    transform: scaleX(-1);
}

.hw-prompt-emoji {
    font-size: 2.6rem;
    letter-spacing: 0.35rem;
    margin-bottom: 8px;
}

.hw-prompt-card h3 {
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0 0 8px;
    color: #fff4e8;
}

.hw-prompt-card p {
    margin: 0 0 20px;
    color: #c9b09a;
    font-size: 0.95rem;
    line-height: 1.45;
}

.hw-prompt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.hw-prompt-actions .btn {
    min-width: 180px;
    border-radius: 999px;
    font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
    body[data-theme="halloween"]::after {
        letter-spacing: 1.2rem;
    }
    #halloween-canvas { display: none !important; }
}
