/* ============================================
   ADMIN THEME — Clean, minimal design
   Replaces glassmorphism.css
   ============================================ */

/* ============================================
   CSS VARIABLES — DARK THEME
   ============================================ */
.mud-theme-dark {
    --surface-bg: #141419;
    --surface-border: #1e1e28;
    --surface-border-hover: #2a2a38;
    --surface-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --surface-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
    --sidebar-bg: #0f0f14;
    --appbar-bg: #0f0f14;
    --input-bg: rgba(255, 255, 255, 0.03);
    --input-hover-bg: rgba(255, 255, 255, 0.05);
    --input-focus-bg: rgba(59, 130, 246, 0.06);
    --table-head-bg: rgba(255, 255, 255, 0.02);
    --table-row-hover: rgba(255, 255, 255, 0.03);
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(255, 255, 255, 0.1);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.2);
    --skeleton-base: #1e1e28;
    --skeleton-shine: #2a2a38;
    --diff-old-bg: rgba(239, 68, 68, 0.08);
    --diff-new-bg: rgba(16, 185, 129, 0.08);
}

/* ============================================
   CSS VARIABLES — LIGHT THEME
   ============================================ */
.mud-theme-light {
    --surface-bg: #ffffff;
    --surface-border: #e5e7eb;
    --surface-border-hover: #d1d5db;
    --surface-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    --surface-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
    --sidebar-bg: #ffffff;
    --appbar-bg: #ffffff;
    --input-bg: rgba(0, 0, 0, 0.02);
    --input-hover-bg: rgba(0, 0, 0, 0.04);
    --input-focus-bg: rgba(59, 130, 246, 0.04);
    --table-head-bg: rgba(0, 0, 0, 0.02);
    --table-row-hover: rgba(0, 0, 0, 0.02);
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(0, 0, 0, 0.1);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.2);
    --skeleton-base: #f3f4f6;
    --skeleton-shine: #e5e7eb;
    --diff-old-bg: rgba(239, 68, 68, 0.06);
    --diff-new-bg: rgba(16, 185, 129, 0.06);
}

/* ============================================
   CARDS — Clean with border, minimal shadow
   ============================================ */
.mud-paper {
    border: 1px solid var(--surface-border);
    box-shadow: var(--surface-shadow);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.mud-grid-item > .mud-paper:hover {
    border-color: var(--surface-border-hover);
}

/* ============================================
   SIDEBAR
   ============================================ */
.admin-sidebar {
    background: var(--sidebar-bg) !important;
    border-right: 1px solid var(--surface-border) !important;
}

.admin-sidebar .mud-drawer-content {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: 100% !important;
}

.admin-sidebar .mud-nav-link {
    border-radius: var(--admin-radius, 8px);
    margin: 2px 8px;
    transition: background 0.15s ease;
}

.admin-sidebar .mud-nav-link:hover {
    background: var(--table-row-hover) !important;
}

.admin-sidebar .mud-nav-link.active {
    background: rgba(var(--mud-palette-primary-rgb, 59, 130, 246), 0.1) !important;
}

/* Section headers */
.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 4px 16px;
    margin-top: 12px;
    margin-bottom: 4px;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.nav-section-header:hover {
    opacity: 0.9;
}

.nav-section-chevron {
    transition: transform 0.2s ease;
    font-size: 16px;
}

.nav-section-chevron.collapsed {
    transform: rotate(-90deg);
}

.nav-section-items {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    max-height: 500px;
    opacity: 1;
}

.nav-section-items.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Favorite pin button */
.nav-link-wrapper {
    position: relative;
}

.nav-pin-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.15s ease;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    color: inherit;
    font-size: 14px;
}

.nav-link-wrapper:hover .nav-pin-btn {
    opacity: 0.6;
}

.nav-pin-btn:hover {
    opacity: 1 !important;
}

.nav-pin-btn.pinned {
    opacity: 0.8;
    color: var(--mud-palette-primary);
}

/* ============================================
   APPBAR
   ============================================ */
.admin-appbar {
    background: var(--appbar-bg) !important;
    border-bottom: 1px solid var(--surface-border);
}

/* ============================================
   INPUTS
   ============================================ */
.mud-input-outlined .mud-input-slot {
    background: var(--input-bg) !important;
}

.mud-input-outlined:hover .mud-input-slot {
    background: var(--input-hover-bg) !important;
}

.mud-input-outlined.mud-input-focused .mud-input-slot {
    background: var(--input-focus-bg) !important;
}

/* ============================================
   TABLES
   ============================================ */
.mud-table .mud-table-head {
    background: var(--table-head-bg) !important;
}

.mud-table .mud-table-row:hover {
    background: var(--table-row-hover) !important;
}

/* ============================================
   DIALOGS
   ============================================ */
.mud-dialog {
    border: 1px solid var(--surface-border) !important;
    border-radius: var(--admin-radius, 8px) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-enter {
    animation: fadeIn 0.25s ease-out;
}

/* ============================================
   SKELETON LOADING
   ============================================ */
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-shine) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.8s ease-in-out infinite;
    border-radius: var(--admin-radius, 8px);
}

.skeleton-text {
    height: 14px;
    border-radius: 4px;
}

.skeleton-heading {
    height: 28px;
    border-radius: 6px;
}

.skeleton-circle {
    border-radius: 50%;
}

/* ============================================
   DENSITY
   ============================================ */
[data-density="compact"] {
    --admin-spacing: 8px;
}

[data-density="compact"] .mud-table-cell {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

[data-density="compact"] .mud-card-content {
    padding: 12px !important;
}

[data-density="default"] {
    --admin-spacing: 16px;
}

[data-density="comfortable"] {
    --admin-spacing: 24px;
}

[data-density="comfortable"] .mud-table-cell {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

[data-density="comfortable"] .mud-card-content {
    padding: 24px !important;
}

/* ============================================
   BORDER RADIUS
   ============================================ */
[data-radius="sharp"] {
    --admin-radius: 4px;
}

[data-radius="sharp"] .mud-paper,
[data-radius="sharp"] .mud-dialog,
[data-radius="sharp"] .mud-chip,
[data-radius="sharp"] .mud-button {
    border-radius: 4px !important;
}

[data-radius="default"] {
    --admin-radius: 8px;
}

[data-radius="default"] .mud-paper,
[data-radius="default"] .mud-dialog {
    border-radius: 8px !important;
}

[data-radius="rounded"] {
    --admin-radius: 16px;
}

[data-radius="rounded"] .mud-paper,
[data-radius="rounded"] .mud-dialog {
    border-radius: 16px !important;
}

[data-radius="rounded"] .mud-chip,
[data-radius="rounded"] .mud-button {
    border-radius: 12px !important;
}

/* ============================================
   COMMAND PALETTE
   ============================================ */
.command-palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.command-palette {
    width: 560px;
    max-height: 70vh;
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: var(--admin-radius, 8px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.command-palette-input {
    padding: 16px;
    border-bottom: 1px solid var(--surface-border);
}

.command-palette-input input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    color: inherit;
    font-family: inherit;
}

.command-palette-results {
    overflow-y: auto;
    max-height: 50vh;
    padding: 8px;
}

.command-palette-section {
    padding: 4px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.5;
    font-weight: 600;
}

.command-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--admin-radius, 8px);
    cursor: pointer;
    transition: background 0.1s ease;
}

.command-palette-item:hover,
.command-palette-item.selected {
    background: var(--table-row-hover);
}

.command-palette-item .item-icon {
    opacity: 0.6;
    flex-shrink: 0;
}

.command-palette-item .item-label {
    flex: 1;
    font-size: 14px;
}

.command-palette-item .item-shortcut {
    font-size: 12px;
    opacity: 0.4;
    font-family: monospace;
}


/* ============================================
   THEME CUSTOMIZER
   ============================================ */
/* Transitions (not keyframes) so cancel-mid-animation interpolates from the
   current rendered state instead of snapping. The .razor component mounts
   the panel without --active, yields one frame so the browser paints the
   off-screen state, then adds --active so the transition runs. */
.theme-customizer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1400;
    display: flex;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.theme-customizer-overlay--active {
    opacity: 1;
}

.theme-customizer-panel {
    width: min(320px, 100%);
    height: 100%;
    background: var(--surface-bg);
    border-left: 1px solid var(--surface-border);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    padding: 24px;
    outline: none;
    box-sizing: border-box;
    transform: translateX(100%);
    transition: transform 0.22s ease;
}

.theme-customizer-panel--active {
    transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
    .theme-customizer-overlay,
    .theme-customizer-panel {
        transition: none;
    }
}

/* Lift MudBlazor popovers (MudSelect dropdown, etc.) above the customizer
   overlay so children of the panel remain interactive. MudPopoverProvider
   renders popovers in a portal at default z-index ~1201, which our 1400
   overlay would otherwise cover, causing clicks to fall through to the
   close-on-overlay handler. Scoped with :has() so it only applies while
   the customizer is mounted. */
body:has(.theme-customizer-overlay) .mud-popover-open {
    z-index: 1410;
}


/* ============================================
   DIFF DISPLAY
   ============================================ */
.diff-old {
    background-color: var(--diff-old-bg);
}

.diff-new {
    background-color: var(--diff-new-bg);
}

/* ============================================
   LOGIN
   ============================================ */
.login-background-clean {
    position: fixed;
    inset: 0;
    z-index: -1;
}

.mud-theme-dark .login-background-clean {
    background: #0a0a0f;
}

.mud-theme-light .login-background-clean {
    background: #fafafa;
}

.login-page-clean {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-card-clean {
    width: 100%;
    max-width: 420px;
    padding: 40px 32px;
    margin: auto;
}

.login-card-clean .mud-input-outlined {
    width: 100% !important;
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center {
    text-align: center;
}

.funnel-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.funnel-stage {
    width: var(--stage-width);
    transition: width 0.5s ease;
}

.funnel-bar {
    border-radius: var(--admin-radius, 8px);
    padding: 16px 24px;
    box-shadow: var(--surface-shadow);
}

.funnel-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.funnel-text {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.funnel-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

.funnel-value {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
}

.funnel-percent {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
}

.funnel-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
}

/* ============================================
   HEATMAP
   ============================================ */
.heatmap-cell {
    width: 100%;
    min-width: 30px;
    height: 24px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
}
