/* ══════════════════════════════════════════════════════════════════
   MAHA ASM — Premium Design System
   A billion-dollar attack surface management platform aesthetic
   ══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
    /* Surfaces — layered depth */
    --bg-base:      #000000;
    --bg-raised:    #080808;
    --bg-card:      #0a0a0a;
    --bg-elevated:  #111111;
    --bg-hover:     #141414;
    --bg-input:     #080808;

    /* Borders — visible but refined */
    --border-subtle:  #161616;
    --border-default: #1e1e1e;
    --border-strong:  #2a2a2a;
    --border-focus:   #444444;

    /* Text — high contrast hierarchy */
    --text-primary:   #ededed;
    --text-secondary: #a1a1a1;
    --text-tertiary:  #888888;
    --text-muted:     #666666;
    --text-ghost:     #3a3a3a;

    /* Accent palette */
    --accent:       #34d399;
    --accent-dim:   rgba(52, 211, 153, 0.08);
    --accent-glow:  rgba(52, 211, 153, 0.15);
    --red:          #f87171;
    --red-dim:      rgba(248, 113, 113, 0.10);
    --yellow:       #facc15;
    --yellow-dim:   rgba(250, 204, 21, 0.10);
    --blue:         #60a5fa;
    --blue-dim:     rgba(96, 165, 250, 0.10);
    --orange:       #fb923c;
    --orange-dim:   rgba(251, 146, 60, 0.10);
    --violet:       #a78bfa;
    --violet-dim:   rgba(167, 139, 250, 0.10);
    --cyan:         #22d3ee;
    --cyan-dim:     rgba(34, 211, 238, 0.10);

    /* Radii */
    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows — subtle depth */
    --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.02);
    --shadow-elevated: 0 4px 12px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.03);
    --shadow-glow: none;
}

/* ── Global Reset Enhancements ───────────────────────────────── */
*, *::before, *::after {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ── Custom Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12);
}
::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.06) transparent;
}

/* ── Noise texture removed for clean Vercel look ─────────────── */

/* ── Icons ────────────────────────────────────────────────────── */
[data-lucide] { display: inline-block; vertical-align: middle; }

/* ── Glass Cards ─────────────────────────────────────────────── */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden;
}
.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
}
.glass-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-elevated);
}

.glass-table {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}
.glass-table::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    z-index: 1;
}
.glass-table:hover {
    border-color: var(--border-strong);
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
}
.stat-card:hover {
    border-color: var(--border-strong);
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
}
.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
    margin-bottom: 8px;
}
.stat-card .stat-sub {
    font-size: 11px;
    color: var(--text-ghost);
    margin-top: 8px;
}

/* ── List rows ──────────────────────────────────────────────── */
.list-container {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}
.list-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    z-index: 1;
}
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    transition: background 0.15s ease;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border-subtle);
}
.list-row:last-child {
    border-bottom: none;
}
.list-row:hover {
    background: var(--bg-hover);
}

/* ── Staggered Entrance Animations ───────────────────────────── */
@keyframes fade-slide-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-in {
    opacity: 0;
    animation: fade-slide-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: calc(var(--stagger, 0) * 60ms + 80ms);
}

@keyframes row-slide-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
.animate-row {
    opacity: 0;
    animation: row-slide-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: calc(var(--stagger, 0) * 30ms + 120ms);
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.animate-fade {
    opacity: 0;
    animation: fade-in 0.35s ease-out 0.1s forwards;
}

/* ── Status Indicators ───────────────────────────────────────── */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}
.status-running .status-dot { animation: pulse-dot 2s ease-in-out infinite; }

/* ── Glow Effects ────────────────────────────────────────────── */
.glow-critical {
    box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.12), 0 0 20px rgba(248, 113, 113, 0.04);
}
.glow-high {
    box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.12), 0 0 20px rgba(251, 146, 60, 0.04);
}
.glow-amber {
    box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.12), 0 0 20px rgba(250, 204, 21, 0.04);
}
.glow-emerald {
    box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.12), 0 0 20px rgba(52, 211, 153, 0.04);
}

.animate-in.glow-critical,
.animate-in.glow-high,
.animate-in.glow-amber,
.animate-in.glow-emerald {
    opacity: 0;
    animation: fade-slide-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: calc(var(--stagger, 0) * 60ms + 80ms);
}

/* ── HTMX Swap ───────────────────────────────────────────────── */
tr.htmx-swapping { opacity: 0; transition: opacity 0.2s ease-out; }

/* ── Sidebar ─────────────────────────────────────────────────── */
#sidebar {
    border-right: 1px solid var(--border-default);
    background: var(--bg-raised);
}

/* Brand area top shine */
.brand-section {
    position: relative;
}
.brand-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-default), transparent);
}

#sidebar ul a {
    transition: all 0.15s ease;
    border-radius: var(--radius);
}
#sidebar ul a:hover {
    background: rgba(255, 255, 255, 0.04);
}

.nav-active {
    background: rgba(52, 211, 153, 0.06) !important;
    border: 1px solid rgba(52, 211, 153, 0.08) !important;
}
.nav-active::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 18px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.3);
}

.brand-glow {
    text-shadow: 0 0 24px rgba(52, 211, 153, 0.25), 0 0 80px rgba(52, 211, 153, 0.08);
}

/* Mobile sidebar */
#sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.6);
}
#sidebarBackdrop.visible {
    display: block !important;
    opacity: 1;
}

/* ── Toast Notifications ─────────────────────────────────────── */
@keyframes toast-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes toast-slide-out {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    font-size: 13px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-elevated);
    animation: toast-slide-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    max-width: 380px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.toast.dismissing {
    animation: toast-slide-out 0.25s ease-in forwards;
}
.toast-error {
    border-color: rgba(248, 113, 113, 0.15);
    background: linear-gradient(135deg, var(--bg-elevated), rgba(248, 113, 113, 0.03));
}

/* ── Severity Donut Chart ────────────────────────────────────── */
.donut-segment {
    fill: none;
    stroke-linecap: round;
    transform-origin: center;
}
@keyframes donut-draw {
    from { stroke-dashoffset: var(--circ); }
    to   { stroke-dashoffset: var(--target); }
}
.donut-segment.animate {
    stroke-dashoffset: var(--circ);
    animation: donut-draw 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: var(--delay, 0s);
}
.donut-center-text {
    font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    font-size: 28px;
    font-weight: 700;
    fill: var(--text-primary);
}
.donut-center-label {
    font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    font-size: 10px;
    fill: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ── Scan Pipeline Visualizer ────────────────────────────────── */
.pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 20px 0 8px;
}
.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 72px;
    position: relative;
}
.pipeline-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}
.pipeline-step.completed .pipeline-icon {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.15);
}
.pipeline-step.active .pipeline-icon {
    border-color: var(--yellow);
    background: var(--yellow-dim);
    color: var(--yellow);
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.15);
}
.pipeline-step.failed .pipeline-icon {
    border-color: var(--red);
    background: var(--red-dim);
    color: var(--red);
    box-shadow: 0 0 12px rgba(248, 113, 113, 0.15);
}
.pipeline-step.pending .pipeline-icon {
    border-color: var(--border-default);
    color: var(--text-ghost);
}

.pipeline-line {
    flex: 1;
    height: 1px;
    background: var(--border-default);
    min-width: 28px;
}
.pipeline-line.completed {
    background: var(--accent);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.2);
}
.pipeline-line.active {
    background: linear-gradient(90deg, var(--accent), var(--yellow));
}

.pipeline-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}
.pipeline-step.completed .pipeline-label { color: var(--accent); }
.pipeline-step.active .pipeline-label    { color: var(--yellow); }
.pipeline-step.failed .pipeline-label    { color: var(--red); }

/* ── Activity Feed ───────────────────────────────────────────── */
@keyframes feed-item-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.feed-item {
    opacity: 0;
    animation: feed-item-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: calc(var(--stagger, 0) * 40ms + 100ms);
}

/* ── Premium Button Styles ───────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    cursor: pointer;
    border: none;
    background-color: #34d399;
    color: #050506;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}
.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.btn-primary:hover::before {
    opacity: 1;
}
.btn-primary:hover {
    box-shadow: 0 4px 24px rgba(52, 211, 153, 0.15);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
}

/* ── Button variants ──────────────────────────────────────── */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #a1a1aa;
    transition: all 0.15s ease;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
    color: #d4d4d8;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    cursor: pointer;
    border: 1px solid rgba(248,113,113,0.15);
    background: rgba(248,113,113,0.06);
    color: #f87171;
    transition: all 0.15s ease;
}
.btn-danger:hover {
    background: rgba(248,113,113,0.12);
    border-color: rgba(248,113,113,0.25);
}

/* ── Form inputs ──────────────────────────────────────────── */
.form-input {
    width: 100%;
    background-color: #0a0a0c;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 0.75rem;
    padding: 0.625rem 1rem;
    font-size: 13px;
    color: #ececef;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.form-input::placeholder {
    color: #3f3f46;
}
.form-input:focus {
    border-color: rgba(52, 211, 153, 0.2);
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.05);
    background-color: #0c0c0f;
}

/* ── Alert/message boxes ──────────────────────────────────── */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 13px;
    font-weight: 500;
}
.alert-success {
    background: rgba(52, 211, 153, 0.06);
    border: 1px solid rgba(52, 211, 153, 0.12);
    color: #34d399;
}
.alert-error {
    background: rgba(248, 113, 113, 0.06);
    border: 1px solid rgba(248, 113, 113, 0.12);
    color: #f87171;
}
.alert-warning {
    background: rgba(251, 191, 36, 0.06);
    border: 1px solid rgba(251, 191, 36, 0.12);
    color: #fbbf24;
}

/* ── Ambient Background Glow (main content) ──────────────────── */
.ambient-corner {
    position: fixed;
    border-radius: 50%;
    filter: blur(150px);
    pointer-events: none;
    z-index: 0;
}
.ambient-corner-1 {
    width: 500px;
    height: 500px;
    background: rgba(52, 211, 153, 0.02);
    top: -200px;
    right: -100px;
}
.ambient-corner-2 {
    width: 400px;
    height: 400px;
    background: rgba(96, 165, 250, 0.015);
    bottom: -150px;
    left: 100px;
}

/* ── Accessibility: Reduced Motion ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .animate-in, .animate-row, .animate-fade,
    .donut-segment.animate, .feed-item,
    .btn-primary {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .glow-critical, .glow-high, .glow-amber, .glow-emerald {
        animation: none !important;
    }
    .status-running .status-dot { animation: none; }
    .btn-primary:hover { transform: none; }
}
