/* ═══════════════════════════════════════════════════════════════
   0x12DarkSandbox — Design System
   Dark theme with orange accent, ported from legacy sandbox.php
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & Custom Properties ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Core palette */
    --bg:            #0a0a0f;
    --bg2:           #0f0f1a;
    --bg3:           #13131f;
    --bg-elevated:   #16162a;
    --border:        rgba(255, 255, 255, 0.07);
    --border-hover:  rgba(255, 255, 255, 0.14);

    /* Accent */
    --orange:        #ff6b1a;
    --orange-light:  #ff8a47;
    --orange-glow:   rgba(255, 107, 26, 0.3);
    --orange-dim:    rgba(255, 107, 26, 0.12);
    --orange-subtle: rgba(255, 107, 26, 0.06);

    /* Text */
    --white:         #f0ede8;
    --text-secondary:#9a9ab0;
    --muted:         #5a5a72;

    /* Status */
    --success:       #22c55e;
    --success-dim:   rgba(34, 197, 94, 0.12);
    --warning:       #f59e0b;
    --warning-dim:   rgba(245, 158, 11, 0.12);
    --danger:        #ef4444;
    --danger-dim:    rgba(239, 68, 68, 0.12);
    --info:          #3b82f6;
    --info-dim:      rgba(59, 130, 246, 0.12);

    /* Typography */
    --mono:    'Share Tech Mono', monospace;
    --display: 'Bebas Neue', sans-serif;
    --body:    'DM Sans', sans-serif;

    /* Spacing */
    --gap-xs: 0.25rem;
    --gap-sm: 0.5rem;
    --gap-md: 1rem;
    --gap-lg: 1.5rem;
    --gap-xl: 2.5rem;

    /* Radius */
    --radius: 2px;
    --radius-md: 6px;
}

/* ── Base ── */
html { scroll-behavior: smooth; font-size: 17px; }

body {
    background: var(--bg);
    color: var(--white);
    font-family: var(--body);
    font-size: 1rem;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 107, 26, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 107, 26, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* Radial glow */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse, rgba(255, 107, 26, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

a { color: var(--orange); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--orange-light); }

/* ── Layout ── */
.page {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--gap-xl) var(--gap-lg);
}

/* ── Navbar ── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--gap-md) var(--gap-lg);
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.navbar-brand .logo-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 0 12px var(--orange-glow);
    animation: pulse 2s ease-in-out infinite;
}

.navbar-brand .logo-text {
    font-family: var(--display);
    font-size: 1.4rem;
    letter-spacing: 0.06em;
    color: var(--white);
}

.navbar-brand .logo-text span {
    color: var(--orange);
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: var(--gap-lg);
}

.navbar-links a {
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    transition: color 0.2s;
}

.navbar-links a:hover,
.navbar-links a.active {
    color: var(--orange);
}

.navbar-links a.btn-login {
    border: 1px solid var(--orange);
    padding: 0.3rem 0.9rem;
    border-radius: var(--radius);
    color: var(--orange);
}

.navbar-links a.btn-login:hover {
    background: var(--orange);
    color: var(--bg);
}

.nav-username-badge {
    font-family: var(--body);
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    color: var(--white);
}

.nav-credits {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--orange);
    background: var(--orange-dim);
    border: 1px solid var(--orange-dim);
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius);
    display: none;
    text-decoration: none;
}

.nav-credits:hover { background: var(--orange-subtle); }

.btn-nav-logout {
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    color: var(--danger);
    background: transparent;
    border: 1px solid var(--danger);
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.btn-nav-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ── Header ── */
.header {
    margin-bottom: var(--gap-xl);
    animation: fadeDown 0.6s ease both;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: var(--gap-sm);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 0 10px var(--orange);
    animation: pulse 2s ease-in-out infinite;
}

.label {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--orange);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

h1 {
    font-family: var(--display);
    font-size: clamp(2.5rem, 6vw, 4rem);
    line-height: 0.95;
    letter-spacing: 0.02em;
    color: var(--white);
}

h1 span { color: var(--orange); }

.subtitle {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted);
    font-weight: 300;
    letter-spacing: 0.02em;
}

/* ── Cards ── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--gap-lg);
    position: relative;
    animation: fadeUp 0.6s ease both;
    transition: border-color 0.3s;
}

.card:hover {
    border-color: var(--border-hover);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--orange), transparent);
}

.card::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-bottom: 2px solid var(--orange);
    border-right: 2px solid var(--orange);
}

.card-success::before { background: linear-gradient(90deg, var(--success), transparent); }
.card-danger::before  { background: linear-gradient(90deg, var(--danger), transparent); }
.card-info::before    { background: linear-gradient(90deg, var(--info), transparent); }

/* ── Drop Zone ── */
.drop-zone {
    border: 1px dashed rgba(255, 107, 26, 0.3);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg3);
    position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--orange);
    background: var(--orange-dim);
    box-shadow: inset 0 0 40px var(--orange-dim), 0 0 20px rgba(255, 107, 26, 0.15);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-icon { width: 56px; height: 56px; margin: 0 auto 1rem; }
.drop-icon svg { width: 100%; height: 100%; stroke: var(--orange); filter: drop-shadow(0 0 8px var(--orange-glow)); }
.drop-title { font-family: var(--mono); font-size: 0.8rem; color: var(--white); letter-spacing: 0.1em; margin-bottom: 0.35rem; }
.drop-sub { font-size: 0.75rem; color: var(--muted); }
.drop-sub span { color: var(--orange); }

/* ── File Selected ── */
.file-selected {
    display: none;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--orange-dim);
    border: 1px solid rgba(255, 107, 26, 0.4);
    border-radius: var(--radius);
    margin-top: 1.25rem;
}

.file-selected.visible { display: flex; }

.file-icon {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--orange);
    background: rgba(255, 107, 26, 0.1);
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--orange);
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.file-name {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--white);
    word-break: break-all;
}

/* ── VM Badges ── */
.vm-targets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.vm-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

.vm-badge:hover { border-color: var(--border-hover); }

.vm-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    flex-shrink: 0;
}

.vm-dot.pending { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.vm-dot.failed  { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.vm-dot.running { animation: pulse 1s ease-in-out infinite; }

.vm-name { font-family: var(--mono); font-size: 0.7rem; color: var(--white); letter-spacing: 0.08em; }
.vm-desc { font-size: 0.65rem; color: var(--muted); margin-top: 0.15rem; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.9rem 1.8rem;
    background: var(--orange);
    border: none;
    border-radius: var(--radius);
    color: #0a0a0f;
    font-family: var(--display);
    font-size: 1.3rem;
    letter-spacing: 0.12em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.btn:hover {
    background: var(--orange-light);
    box-shadow: 0 0 30px var(--orange-glow);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-full { width: 100%; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--orange);
    color: var(--orange);
}

.btn-outline:hover {
    background: var(--orange-dim);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    letter-spacing: 0.08em;
}

/* ── Form inputs (shared across tickets, admin, etc.) ── */
.input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-family: var(--mono);
    font-size: 0.82rem;
    padding: 0.55rem 0.75rem;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
    appearance: none;
    -webkit-appearance: none;
}

.input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 2px var(--orange-dim);
}

.input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

select.input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

textarea.input {
    line-height: 1.55;
}

/* ── Progress ── */
.progress-wrap { display: none; margin: 1.5rem 0 0; }
.progress-wrap.visible { display: block; }

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    font-family: var(--mono);
    font-size: 0.72rem;
}

.progress-label { color: var(--orange); letter-spacing: 0.1em; }
.progress-pct   { color: var(--muted); }

.progress-bar {
    height: 3px;
    background: var(--bg3);
    border-radius: 1px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--orange), #ffaa55);
    width: 0%;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px var(--orange);
}

/* ── Pipeline Steps ── */
.pipeline-steps {
    display: flex;
    gap: 0;
    margin: var(--gap-lg) 0;
    overflow-x: auto;
}

.pipeline-step {
    flex: 1;
    min-width: 140px;
    padding: var(--gap-md);
    background: var(--bg3);
    border: 1px solid var(--border);
    position: relative;
    text-align: center;
    transition: all 0.3s;
}

.pipeline-step + .pipeline-step { border-left: none; }

.pipeline-step.active {
    border-color: var(--orange);
    background: var(--orange-dim);
}

.pipeline-step.completed {
    border-color: var(--success);
    background: var(--success-dim);
}

.pipeline-step.failed {
    border-color: var(--danger);
    background: var(--danger-dim);
}

.pipeline-step-icon {
    font-size: 1.2rem;
    margin-bottom: var(--gap-xs);
}

.pipeline-step-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.pipeline-step.active .pipeline-step-label,
.pipeline-step.completed .pipeline-step-label { color: var(--white); }

/* ── Output Blocks ── */
.output-block { margin-bottom: 1.75rem; }
.output-block:last-child { margin-bottom: 0; }

.output-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--muted);
    letter-spacing: 0.16em;
    padding: 0.5rem 0.9rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.output-label::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--orange);
}

.output-content {
    background: #07070f;
    border: 1px solid var(--border);
    padding: 1rem 1.1rem;
    font-family: var(--mono);
    font-size: 0.74rem;
    color: #a8a8c8;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 280px;
    overflow-y: auto;
}

.output-content::-webkit-scrollbar { width: 5px; }
.output-content::-webkit-scrollbar-track { background: var(--bg3); }
.output-content::-webkit-scrollbar-thumb { background: var(--orange); }

/* ── Detection Grid ── */
.detection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--gap-sm);
    margin: var(--gap-md) 0;
}

.detection-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.84rem;
}

.detection-engine { color: var(--text-secondary); }
.detection-result { letter-spacing: 0.06em; font-size: 0.72rem; }
.detection-result.detected { color: var(--danger); }
.detection-result.clean    { color: var(--success); }

/* ── Score Ring ── */
.score-ring {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto var(--gap-md);
}

.score-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-ring-bg {
    fill: none;
    stroke: var(--bg3);
    stroke-width: 8;
}

.score-ring-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1.5s ease;
}

.score-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-value {
    font-family: var(--display);
    font-size: 2rem;
    line-height: 1;
}

.score-label {
    font-family: var(--mono);
    font-size: 0.6rem;
    color: var(--muted);
    letter-spacing: 0.1em;
    margin-top: 0.25rem;
}

/* ── Timeline ── */
.timeline {
    position: relative;
    padding-left: var(--gap-lg);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-event {
    position: relative;
    padding: var(--gap-sm) 0 var(--gap-md) var(--gap-md);
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--gap-lg) + 4px);
    top: 0.65rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 0 6px var(--orange-glow);
}

.timeline-event.severity-high::before   { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.timeline-event.severity-medium::before { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.timeline-event.severity-info::before   { background: var(--info); box-shadow: 0 0 6px var(--info); }

.timeline-time {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--muted);
    letter-spacing: 0.08em;
}

.timeline-title {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--white);
    margin: 0.15rem 0;
}

.timeline-source {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.timeline-source .tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: var(--orange-dim);
    color: var(--orange);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
}

/* ── Spinner ── */
.spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2.5px solid rgba(10, 10, 15, 0.4);
    border-top-color: #0a0a0f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
    border-color: var(--border);
    border-top-color: var(--orange);
}

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--gap-md);
    margin: var(--gap-lg) 0;
}

.stat-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--gap-md) var(--gap-lg);
}

.stat-value {
    font-family: var(--display);
    font-size: 2.2rem;
    color: var(--white);
    line-height: 1;
}

.stat-label {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--muted);
    letter-spacing: 0.12em;
    margin-top: 0.3rem;
}

/* ── Mobile hamburger (hidden on desktop) ── */
.nav-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 4px;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}
.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--white);
    border-radius: 1px;
    transition: transform 0.25s, opacity 0.2s;
}
.navbar.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.navbar.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
.navbar.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Responsive ── */
@media (max-width: 768px) {
    /* Navbar */
    .nav-hamburger { display: flex; }
    .navbar { flex-wrap: wrap; padding: var(--gap-sm) var(--gap-md); }
    .navbar-links {
        display: none !important;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: var(--gap-sm);
        padding: var(--gap-sm) 0 var(--gap-xs);
        border-top: 1px solid var(--border);
        margin-top: var(--gap-sm);
    }
    .navbar.nav-open .navbar-links { display: flex !important; }
    #nav-guest, #nav-user {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: var(--gap-sm);
        width: 100%;
    }
    .navbar-links > a { padding: 0.15rem 0; }

    /* Page */
    .page { padding: var(--gap-md); }

    /* Upload page */
    .vm-targets { grid-template-columns: 1fr 1fr; }

    /* Detection / stats */
    .detection-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }

    /* Pipeline */
    .pipeline-steps { flex-direction: column; }
    .pipeline-step { min-width: unset; }
    .pipeline-step + .pipeline-step { border-left: 1px solid var(--border); border-top: none; }

    /* Tables — horizontal scroll */
    .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Drop zone — tighter on mobile */
    .drop-zone { padding: 2rem 1.25rem; }

    /* Auth cards */
    .auth-card { padding: 1.75rem 1.25rem; }

    /* Header h1 */
    h1 { font-size: clamp(2rem, 9vw, 4rem); }
}

@media (max-width: 480px) {
    .vm-targets { grid-template-columns: 1fr; }
    .stats-grid  { grid-template-columns: 1fr; }
    h1 { font-size: clamp(1.75rem, 10vw, 3rem); }
    .page { padding: var(--gap-sm) var(--gap-md); }
}

/* ── Animations ── */
@keyframes fadeDown { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(24px); }  to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse    { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes spin     { to { transform: rotate(360deg); } }

/* Stagger animations */
.anim-delay-1 { animation-delay: 0.1s; }
.anim-delay-2 { animation-delay: 0.2s; }
.anim-delay-3 { animation-delay: 0.3s; }
.anim-delay-4 { animation-delay: 0.4s; }
