/*
 * PointOS admin theme.
 *
 * Plain CSS on purpose — it is registered as a Filament asset and published to
 * public/css/pointos/core/admin-theme.css by `php artisan filament:assets`, so
 * it needs no Tailwind build step and cannot be broken by a Vite change.
 *
 * Because Filament's own stylesheet lives inside @layer theme/base/components/
 * utilities and this file does not, every rule here beats a Tailwind utility of
 * any specificity. That is deliberate — and it is why the file stays surgical:
 * it restyles chrome (topbar, cards, tables, buttons, stats) and never touches
 * layout maths.
 *
 * Dark mode is Filament's `.dark` class on <html>, not a media query.
 * Every animation is disabled under prefers-reduced-motion at the end of the file.
 */

/* ------------------------------------------------------------------ tokens */

:root {
    --pos-font-display: 'Space Grotesk Variable', 'Inter Variable', ui-sans-serif, system-ui, sans-serif;

    /* An ease that decelerates hard — motion that feels answered, not animated. */
    --pos-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --pos-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --pos-fast: 120ms;
    --pos-base: 200ms;
    --pos-slow: 320ms;

    --pos-radius: 0.875rem;
    --pos-radius-lg: 1.125rem;

    --pos-surface: #ffffff;
    --pos-surface-sunken: #f6f7fb;
    --pos-hairline: rgb(15 23 42 / 0.08);
    --pos-hairline-strong: rgb(15 23 42 / 0.14);

    --pos-shadow-sm: 0 1px 2px rgb(15 23 42 / 0.05);
    --pos-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 8px 24px -12px rgb(15 23 42 / 0.14);
    --pos-shadow-lg: 0 1px 2px rgb(15 23 42 / 0.04), 0 24px 48px -24px rgb(15 23 42 / 0.28);

    --pos-glass: rgb(255 255 255 / 0.82);
    --pos-tint: color-mix(in oklab, var(--primary-500) 8%, transparent);
    --pos-tint-strong: color-mix(in oklab, var(--primary-500) 14%, transparent);
}

.dark {
    --pos-surface: #151a23;
    --pos-surface-sunken: #0d1117;
    --pos-hairline: rgb(255 255 255 / 0.09);
    --pos-hairline-strong: rgb(255 255 255 / 0.16);

    --pos-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --pos-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.6);
    --pos-shadow-lg: 0 1px 2px rgb(0 0 0 / 0.5), 0 24px 48px -24px rgb(0 0 0 / 0.8);

    --pos-glass: rgb(16 20 28 / 0.78);
    --pos-tint: color-mix(in oklab, var(--primary-400) 12%, transparent);
    --pos-tint-strong: color-mix(in oklab, var(--primary-400) 20%, transparent);
}

/* -------------------------------------------------------------- typography */

.fi-body {
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    letter-spacing: -0.006em;
}

.fi-header-heading,
.fi-modal-heading,
.fi-simple-header-heading,
.fi-section-header .fi-section-header-heading {
    font-family: var(--pos-font-display);
    font-weight: 600;
    letter-spacing: -0.021em;
}

/* Numbers that never jitter while a widget polls. */
.fi-wi-stats-overview-stat-value,
.fi-ta-cell [data-numeric],
.pos-numeric {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
}

/* ------------------------------------------------------------------- brand */

.pos-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.pos-brand-mark {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.7rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    box-shadow: 0 4px 12px -4px color-mix(in oklab, var(--primary-600) 60%, transparent);
    transition: transform var(--pos-slow) var(--pos-ease-spring), box-shadow var(--pos-base) var(--pos-ease);
}

.pos-brand-mark svg {
    width: 1.15rem;
    height: 1.15rem;
}

.pos-brand:hover .pos-brand-mark {
    transform: rotate(-8deg) scale(1.06);
    box-shadow: 0 8px 20px -6px color-mix(in oklab, var(--primary-600) 70%, transparent);
}

.pos-brand-name {
    font-family: var(--pos-font-display);
    font-size: 1.075rem;
    font-weight: 600;
    letter-spacing: -0.028em;
    color: var(--gray-950);
}

.dark .pos-brand-name {
    color: var(--gray-50);
}

/* ----------------------------------------------------------------- topbar */

.fi-topbar > nav {
    background: var(--pos-glass);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--pos-hairline);
    box-shadow: none;
    transition: box-shadow var(--pos-base) var(--pos-ease);
}

.fi-topbar-item-btn,
.fi-sidebar-item-btn {
    border-radius: 0.7rem;
    transition:
        background-color var(--pos-fast) var(--pos-ease),
        color var(--pos-fast) var(--pos-ease),
        transform var(--pos-base) var(--pos-ease);
}

.fi-topbar-item-btn:hover,
.fi-sidebar-item-btn:hover {
    background-color: var(--pos-tint);
    transform: translateY(-1px);
}

.fi-topbar-item.fi-active .fi-topbar-item-btn,
.fi-sidebar-item.fi-active .fi-sidebar-item-btn {
    background-color: var(--pos-tint-strong);
}

/* The active nav item earns a mark of its own rather than only a tint. */
.fi-sidebar-item.fi-active .fi-sidebar-item-btn {
    position: relative;
}

.fi-sidebar-item.fi-active .fi-sidebar-item-btn::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    width: 3px;
    height: 1.25rem;
    transform: translateY(-50%);
    border-radius: 999px;
    background: var(--primary-500);
}

.fi-topbar-item-icon,
.fi-sidebar-item-icon {
    transition: transform var(--pos-base) var(--pos-ease-spring);
}

.fi-topbar-item-btn:hover .fi-topbar-item-icon,
.fi-sidebar-item-btn:hover .fi-sidebar-item-icon {
    transform: scale(1.12);
}

/* ------------------------------------------------------------------ cards */

.fi-section,
.fi-wi-widget > .fi-sc,
.fi-ta-ctn {
    border-radius: var(--pos-radius);
    border-color: var(--pos-hairline);
    box-shadow: var(--pos-shadow);
    transition:
        box-shadow var(--pos-base) var(--pos-ease),
        border-color var(--pos-base) var(--pos-ease),
        transform var(--pos-base) var(--pos-ease);
}

.fi-section:hover {
    box-shadow: var(--pos-shadow-lg);
    border-color: var(--pos-hairline-strong);
}

.fi-modal-window,
.fi-dropdown-panel {
    border-radius: var(--pos-radius-lg);
    box-shadow: var(--pos-shadow-lg);
}

.fi-dropdown-list-item {
    border-radius: 0.55rem;
    transition: background-color var(--pos-fast) var(--pos-ease), padding-inline-start var(--pos-fast) var(--pos-ease);
}

.fi-dropdown-list-item:hover {
    padding-inline-start: 0.9rem;
}

/* ---------------------------------------------------------------- widgets */

.fi-wi-stats-overview-stat {
    position: relative;
    overflow: hidden;
    border-radius: var(--pos-radius);
    border-color: var(--pos-hairline);
    box-shadow: var(--pos-shadow);
    transition:
        transform var(--pos-base) var(--pos-ease),
        box-shadow var(--pos-base) var(--pos-ease),
        border-color var(--pos-base) var(--pos-ease);
}

/* A wash that only appears on hover, so a wall of stat cards stays calm at rest. */
.fi-wi-stats-overview-stat::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(120% 140% at 100% 0%, var(--pos-tint), transparent 60%);
    transition: opacity var(--pos-slow) var(--pos-ease);
}

.fi-wi-stats-overview-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--pos-shadow-lg);
    border-color: var(--pos-hairline-strong);
}

.fi-wi-stats-overview-stat:hover::after {
    opacity: 1;
}

.fi-wi-stats-overview-stat-value {
    font-family: var(--pos-font-display);
    font-weight: 600;
    letter-spacing: -0.035em;
}

.fi-wi-stats-overview-stat-label {
    letter-spacing: 0.01em;
}

.fi-wi-stats-overview-stat-description {
    transition: transform var(--pos-base) var(--pos-ease);
}

.fi-wi-stats-overview-stat:hover .fi-wi-stats-overview-stat-description {
    transform: translateX(2px);
}

/* ----------------------------------------------------------------- tables */

.fi-ta-row {
    transition: background-color var(--pos-fast) var(--pos-ease);
}

.fi-ta-row:hover {
    background-color: var(--pos-tint);
}

.fi-ta-header-cell-label {
    letter-spacing: 0.02em;
    text-transform: none;
}

/* ---------------------------------------------------------------- buttons */

.fi-btn,
.fi-icon-btn {
    transition:
        background-color var(--pos-fast) var(--pos-ease),
        color var(--pos-fast) var(--pos-ease),
        box-shadow var(--pos-fast) var(--pos-ease),
        transform var(--pos-fast) var(--pos-ease);
}

.fi-btn:not(:disabled):hover,
.fi-icon-btn:not(:disabled):hover {
    transform: translateY(-1px);
}

/* Press feedback — the single cheapest way to make a UI feel responsive. */
.fi-btn:not(:disabled):active,
.fi-icon-btn:not(:disabled):active {
    transform: translateY(0) scale(0.975);
    transition-duration: 60ms;
}

.fi-badge {
    border-radius: 0.5rem;
    font-weight: 500;
    letter-spacing: 0.005em;
}

/* ------------------------------------------------------------------ input */

.fi-input-wrp {
    border-radius: 0.7rem;
    transition: box-shadow var(--pos-fast) var(--pos-ease), border-color var(--pos-fast) var(--pos-ease);
}

.fi-input-wrp:focus-within {
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary-500) 16%, transparent);
}

/* -------------------------------------------------------------- scrollbar */

.fi-body *::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.fi-body *::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
    background-color: var(--pos-hairline-strong);
}

.fi-body *::-webkit-scrollbar-thumb:hover {
    background-color: color-mix(in oklab, var(--primary-500) 45%, transparent);
}

.fi-body *::-webkit-scrollbar-track {
    background: transparent;
}

/* ------------------------------------------------------- dashboard: hero */

.pos-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--pos-radius-lg);
    padding: 1.65rem 1.75rem;
    color: #fff;
    background:
        radial-gradient(120% 160% at 100% 0%, color-mix(in oklab, var(--primary-300) 55%, transparent), transparent 55%),
        linear-gradient(115deg, var(--primary-700), var(--primary-500) 55%, var(--primary-600));
    box-shadow: var(--pos-shadow-lg);
}

.pos-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgb(255 255 255 / 0.14) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: linear-gradient(120deg, #000, transparent 65%);
    -webkit-mask-image: linear-gradient(120deg, #000, transparent 65%);
}

.pos-hero-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem;
}

.pos-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgb(255 255 255 / 0.78);
}

.pos-hero-eyebrow svg {
    width: 0.95rem;
    height: 0.95rem;
}

.pos-hero-title {
    margin: 0.4rem 0 0;
    font-family: var(--pos-font-display);
    font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.05rem);
    font-weight: 600;
    letter-spacing: -0.032em;
    line-height: 1.15;
}

.pos-hero-subtitle {
    margin: 0.45rem 0 0;
    max-width: 46ch;
    font-size: 0.9rem;
    color: rgb(255 255 255 / 0.8);
}

.pos-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pos-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgb(255 255 255 / 0.22);
    background: rgb(255 255 255 / 0.12);
    backdrop-filter: blur(6px);
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
    transition: background-color var(--pos-fast) var(--pos-ease), transform var(--pos-base) var(--pos-ease);
}

a.pos-chip:hover {
    background: rgb(255 255 255 / 0.22);
    transform: translateY(-1px);
}

.pos-chip svg {
    width: 0.95rem;
    height: 0.95rem;
}

.pos-chip-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 0 0 currentColor;
    animation: pos-pulse 2.4s var(--pos-ease) infinite;
}

@keyframes pos-pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in oklab, currentColor 60%, transparent); }
    70% { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ----------------------------------------------- dashboard: quick actions */

.pos-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
    gap: 0.75rem;
}

.pos-quick {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.85rem 0.95rem;
    border-radius: var(--pos-radius);
    border: 1px solid var(--pos-hairline);
    background: var(--pos-surface);
    box-shadow: var(--pos-shadow-sm);
    text-decoration: none;
    /* animation-delay is set inline per card to stagger the entrance. */
    animation: pos-rise var(--pos-base) var(--pos-ease) both;
    transition:
        transform var(--pos-base) var(--pos-ease),
        box-shadow var(--pos-base) var(--pos-ease),
        border-color var(--pos-base) var(--pos-ease);
}

.dark .pos-quick {
    background: color-mix(in oklab, var(--gray-900) 70%, transparent);
}

.pos-quick:hover {
    transform: translateY(-2px);
    box-shadow: var(--pos-shadow);
    border-color: color-mix(in oklab, var(--primary-500) 40%, var(--pos-hairline));
}

.pos-quick-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.7rem;
    color: var(--primary-600);
    background: var(--pos-tint-strong);
    transition: transform var(--pos-slow) var(--pos-ease-spring);
}

.dark .pos-quick-icon {
    color: var(--primary-300);
}

.pos-quick:hover .pos-quick-icon {
    transform: scale(1.08) rotate(-4deg);
}

.pos-quick-icon svg {
    width: 1.15rem;
    height: 1.15rem;
}

.pos-quick-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-950);
}

.dark .pos-quick-label {
    color: var(--gray-100);
}

.pos-quick-hint {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.pos-quick-arrow {
    margin-inline-start: auto;
    color: var(--gray-400);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity var(--pos-base) var(--pos-ease), transform var(--pos-base) var(--pos-ease);
}

.pos-quick-arrow svg {
    width: 1rem;
    height: 1rem;
}

.pos-quick:hover .pos-quick-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ------------------------------------------------------ dashboard: health */

.pos-health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.6rem;
}

.pos-health {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.8rem;
    border-radius: 0.8rem;
    border: 1px solid var(--pos-hairline);
    background: var(--pos-surface-sunken);
    transition: border-color var(--pos-base) var(--pos-ease), transform var(--pos-base) var(--pos-ease);
}

.dark .pos-health {
    background: color-mix(in oklab, var(--gray-900) 60%, transparent);
}

.pos-health:hover {
    transform: translateY(-1px);
}

.pos-health-dot {
    flex: none;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 999px;
}

.pos-health-ok .pos-health-dot { background: var(--success-500); }
.pos-health-degraded .pos-health-dot { background: var(--warning-500); }
.pos-health-down .pos-health-dot { background: var(--danger-500); }

.pos-health-ok { border-color: color-mix(in oklab, var(--success-500) 28%, var(--pos-hairline)); }
.pos-health-degraded { border-color: color-mix(in oklab, var(--warning-500) 34%, var(--pos-hairline)); }
.pos-health-down { border-color: color-mix(in oklab, var(--danger-500) 38%, var(--pos-hairline)); }

.pos-health-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-800);
}

.dark .pos-health-label {
    color: var(--gray-200);
}

.pos-health-value {
    display: block;
    font-size: 0.72rem;
    color: var(--gray-500);
}

/* ------------------------------------------------------ dashboard: stream */

.pos-stream {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.pos-stream-item {
    display: flex;
    gap: 0.85rem;
    padding: 0.6rem 0.35rem;
    border-radius: 0.7rem;
    transition: background-color var(--pos-fast) var(--pos-ease);
}

.pos-stream-item:hover {
    background: var(--pos-tint);
}

.pos-stream-rail {
    position: relative;
    flex: none;
    width: 1.75rem;
    display: flex;
    justify-content: center;
}

/* The connecting line is drawn by the rail, so no wrapper element is needed. */
.pos-stream-item:not(:last-child) .pos-stream-rail::after {
    content: '';
    position: absolute;
    top: 1.75rem;
    bottom: -0.9rem;
    width: 1px;
    background: var(--pos-hairline-strong);
}

.pos-stream-icon {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    background: var(--pos-surface-sunken);
    border: 1px solid var(--pos-hairline);
    color: var(--gray-500);
}

.dark .pos-stream-icon {
    background: var(--gray-900);
}

.pos-stream-icon svg {
    width: 0.85rem;
    height: 0.85rem;
}

.pos-stream-created .pos-stream-icon { color: var(--success-600); }
.pos-stream-updated .pos-stream-icon { color: var(--info-600); }
.pos-stream-deleted .pos-stream-icon { color: var(--danger-600); }

.pos-stream-body {
    min-width: 0;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.dark .pos-stream-body {
    color: var(--gray-300);
}

.pos-stream-subject {
    font-weight: 500;
    color: var(--gray-950);
}

.dark .pos-stream-subject {
    color: var(--gray-100);
}

.pos-stream-time {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.72rem;
    color: var(--gray-500);
}

.pos-empty {
    padding: 1.5rem 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* --------------------------------------------------------------- entrance */

/* Widgets fade up once on load; staggering is set inline per widget. */
@keyframes pos-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.fi-wi-widget {
    animation: pos-rise var(--pos-slow) var(--pos-ease) both;
}

/* --------------------------------------------------------------- a11y */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .fi-btn:not(:disabled):hover,
    .fi-icon-btn:not(:disabled):hover,
    .fi-wi-stats-overview-stat:hover,
    .pos-quick:hover,
    .fi-topbar-item-btn:hover,
    .fi-sidebar-item-btn:hover {
        transform: none;
    }
}
