/**
 * Golden Fabric ERP — Theme tokens: dark, high-contrast, auto, skeleton, loader, search, notifications
 */

/* ── Skeleton token overrides (all themes) ── */
:root {
    --lf-skeleton-base: #e2e8f0;
    --lf-skeleton-highlight: #f8fafc;
    --lf-skeleton-shimmer: linear-gradient(
        90deg,
        var(--lf-skeleton-base) 0%,
        var(--lf-skeleton-highlight) 50%,
        var(--lf-skeleton-base) 100%
    );
    --lf-loader-bg: rgba(241, 245, 249, 0.92);
    --lf-overlay-bg: rgba(15, 23, 42, 0.45);
}

/* ============================================================
   DARK MODE
   ============================================================ */
html[data-lf-theme="dark"],
html[data-lf-theme-resolved="dark"]:not([data-lf-theme="high-contrast"]) {
    color-scheme: dark;

    --lf-primary: #3b82f6;
    --lf-primary-hover: #60a5fa;
    --lf-primary-subtle: #1e3a5f;
    --lf-primary-rgb: 59, 130, 246;

    --lf-success: #22c55e;
    --lf-success-hover: #4ade80;
    --lf-success-subtle: #14532d;

    --lf-danger: #ef4444;
    --lf-danger-hover: #f87171;
    --lf-danger-subtle: #450a0a;

    --lf-warning: #f97316;
    --lf-warning-hover: #fb923c;
    --lf-warning-subtle: #431407;

    --lf-info: #38bdf8;
    --lf-info-hover: #7dd3fc;
    --lf-info-subtle: #0c4a6e;

    --lf-secondary: #94a3b8;
    --lf-secondary-hover: #cbd5e1;
    --lf-secondary-subtle: #334155;

    --lf-bg: #0f172a;
    --lf-bg-card: #1e293b;
    --lf-border: #334155;
    --lf-border-strong: #475569;
    --lf-text: #f1f5f9;
    --lf-text-muted: #94a3b8;
    --lf-text-light: #64748b;

    --lf-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --lf-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    --lf-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);

    --lf-skeleton-base: #334155;
    --lf-skeleton-highlight: #475569;
    --lf-loader-bg: rgba(15, 23, 42, 0.94);
    --lf-overlay-bg: rgba(0, 0, 0, 0.55);

    --primary-color: var(--lf-primary);
    --content-bg: var(--lf-bg);
    --border-color: var(--lf-border);
}

html[data-lf-theme="auto"] {
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    html[data-lf-theme="auto"] {
        --lf-primary: #3b82f6;
        --lf-primary-hover: #60a5fa;
        --lf-primary-subtle: #1e3a5f;
        --lf-success: #22c55e;
        --lf-success-subtle: #14532d;
        --lf-danger: #ef4444;
        --lf-danger-subtle: #450a0a;
        --lf-warning: #f97316;
        --lf-warning-subtle: #431407;
        --lf-info: #38bdf8;
        --lf-info-subtle: #0c4a6e;
        --lf-secondary: #94a3b8;
        --lf-secondary-subtle: #334155;
        --lf-bg: #0f172a;
        --lf-bg-card: #1e293b;
        --lf-border: #334155;
        --lf-border-strong: #475569;
        --lf-text: #f1f5f9;
        --lf-text-muted: #94a3b8;
        --lf-text-light: #64748b;
        --lf-skeleton-base: #334155;
        --lf-skeleton-highlight: #475569;
        --lf-loader-bg: rgba(15, 23, 42, 0.94);
    }
}

/* ============================================================
   HIGH CONTRAST ACCESSIBILITY MODE
   ============================================================ */
html[data-lf-theme="high-contrast"] {
    color-scheme: light;

    --lf-primary: #0000ee;
    --lf-primary-hover: #0000cc;
    --lf-primary-subtle: #e8e8ff;
    --lf-success: #006400;
    --lf-success-subtle: #e6ffe6;
    --lf-danger: #cc0000;
    --lf-danger-subtle: #ffe6e6;
    --lf-warning: #8b4513;
    --lf-warning-subtle: #fff3e0;
    --lf-info: #0066cc;
    --lf-info-subtle: #e6f2ff;
    --lf-secondary: #333333;
    --lf-secondary-subtle: #f0f0f0;

    --lf-bg: #ffffff;
    --lf-bg-card: #ffffff;
    --lf-border: #000000;
    --lf-border-strong: #000000;
    --lf-text: #000000;
    --lf-text-muted: #1a1a1a;
    --lf-text-light: #333333;

    --lf-shadow-sm: none;
    --lf-shadow: none;
    --lf-shadow-lg: none;
}

html[data-lf-theme="high-contrast"] .lf-card,
html[data-lf-theme="high-contrast"] .content-card,
html[data-lf-theme="high-contrast"] .lf-kpi-card,
html[data-lf-theme="high-contrast"] .stat-card,
html[data-lf-theme="high-contrast"] .lf-table-wrap,
html[data-lf-theme="high-contrast"] .btn,
html[data-lf-theme="high-contrast"] .form-control,
html[data-lf-theme="high-contrast"] .form-select {
    border-width: 2px !important;
    border-color: #000 !important;
}

html[data-lf-theme="high-contrast"] :focus-visible {
    outline: 3px solid #000 !important;
    outline-offset: 2px !important;
}

html[data-lf-theme="high-contrast"] .lf-status-badge {
    border: 2px solid #000;
    font-weight: 700;
}

/* ============================================================
   GLOBAL PAGE LOADER
   ============================================================ */
.lf-page-loader {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--lf-loader-bg);
    backdrop-filter: blur(4px);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.lf-page-loader.lf-page-loader-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.lf-page-loader-brand {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gf-gold, #C9A227);
    letter-spacing: 0.04em;
}

.lf-page-loader-bar {
    width: min(240px, 60vw);
    height: 4px;
    background: var(--lf-border);
    border-radius: 99px;
    overflow: hidden;
}

.lf-page-loader-bar::after {
    content: "";
    display: block;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, #8B6914, #E8C547);
    border-radius: inherit;
    animation: lfLoaderBar 1s ease-in-out infinite;
}

@keyframes lfLoaderBar {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.lf-nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--lf-primary);
    z-index: 9999;
    transition: width 0.2s ease;
}

.lf-nav-progress.lf-nav-progress-active {
    width: 70%;
    animation: lfNavPulse 1.5s ease infinite;
}

.lf-nav-progress.lf-nav-progress-done {
    width: 100%;
    opacity: 0;
    transition: width 0.15s ease, opacity 0.3s ease 0.1s;
}

@keyframes lfNavPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================================
   THEME SWITCHER
   ============================================================ */
.lf-theme-switcher .dropdown-toggle {
    width: 38px;
    height: 38px;
    border-radius: var(--lf-radius);
    border: 1px solid var(--lf-border);
    background: var(--lf-bg-card);
    color: var(--lf-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.lf-theme-switcher .dropdown-item.active {
    background: var(--lf-primary-subtle);
    color: var(--lf-primary);
    font-weight: 600;
}

.lf-theme-switcher .dropdown-item i {
    width: 1.25rem;
}

/* ============================================================
   GLOBAL SEARCH
   ============================================================ */
.lf-global-search-trigger {
    min-width: 220px;
    max-width: 320px;
    cursor: pointer;
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius);
    background: var(--lf-secondary-subtle);
    color: var(--lf-text-muted);
    padding: 0.45rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--lf-font-small);
}

.lf-global-search-trigger kbd {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: var(--lf-bg-card);
    border: 1px solid var(--lf-border);
    color: var(--lf-text-light);
}

.lf-search-modal .modal-content {
    border: none;
    border-radius: var(--lf-radius-xl);
    overflow: hidden;
    box-shadow: var(--lf-shadow-lg);
}

.lf-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--lf-border);
    background: var(--lf-bg-card);
}

.lf-search-input-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1.05rem;
    color: var(--lf-text);
    outline: none;
}

.lf-search-results {
    max-height: min(360px, 50vh);
    overflow-y: auto;
    padding: 0.5rem;
}

.lf-search-group-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--lf-text-muted);
    padding: 0.5rem 0.75rem 0.25rem;
}

.lf-search-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--lf-radius);
    color: var(--lf-text);
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: inherit;
}

.lf-search-result:hover,
.lf-search-result.lf-search-result-active {
    background: var(--lf-primary-subtle);
    color: var(--lf-primary);
}

.lf-search-empty {
    padding: 2rem;
    text-align: center;
    color: var(--lf-text-muted);
    font-size: var(--lf-font-small);
}

/* ============================================================
   NOTIFICATION CENTER
   ============================================================ */
.lf-notify-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: var(--lf-radius);
    border: 1px solid var(--lf-border);
    background: var(--lf-bg-card);
    color: var(--lf-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.lf-notify-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--lf-danger);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--lf-bg-card);
}

.lf-notify-panel {
    position: fixed;
    top: var(--topnav-height, 64px);
    right: 0;
    width: min(380px, 100vw);
    max-height: calc(100vh - var(--topnav-height, 64px));
    background: var(--lf-bg-card);
    border-left: 1px solid var(--lf-border);
    box-shadow: var(--lf-shadow-lg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.lf-notify-panel.lf-notify-panel-open {
    transform: translateX(0);
}

.lf-notify-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--lf-border);
}

.lf-notify-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.lf-notify-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--lf-radius);
    margin-bottom: 0.35rem;
    cursor: pointer;
}

.lf-notify-item:hover {
    background: var(--lf-secondary-subtle);
}

.lf-notify-item.lf-notify-unread {
    background: var(--lf-primary-subtle);
    border: 1px solid var(--lf-border);
}

.lf-notify-item-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lf-notify-item-icon-success { background: var(--lf-success-subtle); color: var(--lf-success); }
.lf-notify-item-icon-error { background: var(--lf-danger-subtle); color: var(--lf-danger); }
.lf-notify-item-icon-warning { background: var(--lf-warning-subtle); color: var(--lf-warning); }
.lf-notify-item-icon-info { background: var(--lf-info-subtle); color: var(--lf-info); }

.lf-notify-item-title { font-weight: 600; font-size: var(--lf-font-small); }
.lf-notify-item-msg { font-size: 0.75rem; color: var(--lf-text-muted); }
.lf-notify-item-time { font-size: 0.65rem; color: var(--lf-text-light); margin-top: 0.2rem; }

.lf-notify-backdrop {
    position: fixed;
    inset: 0;
    background: var(--lf-overlay-bg);
    z-index: 1045;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lf-notify-backdrop.lf-notify-backdrop-open {
    opacity: 1;
    visibility: visible;
}

.lf-notify-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--lf-text-muted);
}

/* ============================================================
   IMPROVED SKELETONS
   ============================================================ */
.lf-skeleton {
    background: var(--lf-skeleton-shimmer);
    background-size: 200% 100%;
}

.lf-skeleton-circle {
    border-radius: 50%;
    width: 48px;
    height: 48px;
}

.lf-skeleton-kpi {
    height: 100px;
    border-radius: var(--lf-radius-lg);
}

.lf-skeleton-chart {
    height: 220px;
    border-radius: var(--lf-radius-lg);
}

.lf-skeleton-form-group {
    height: 2.625rem;
    margin-bottom: 1rem;
    border-radius: var(--lf-radius);
}

.lf-skeleton-table-header {
    height: 2.5rem;
    margin-bottom: 0.5rem;
}

.lf-skeleton-pulse {
    animation: lfSkeletonPulse 1.5s ease-in-out infinite;
}

@keyframes lfSkeletonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.lf-loading-overlay {
    background: var(--lf-loader-bg);
}

.sidebar-toggle { color: var(--lf-text-muted); }
.user-menu-btn { background: var(--lf-bg-card); color: var(--lf-text); }
.user-role { color: var(--lf-text-muted); }

@media (max-width: 767.98px) {
    .lf-global-search-trigger { min-width: auto; flex: 1; }
    .lf-global-search-trigger kbd { display: none; }
}
