/* =============================================
   FACE ID — YOLOv8 Recognition UI
   Design: Industrial / Terminal Aesthetic
   ============================================= */

:root {
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-2: #1a1a1a;
    --border: #2a2a2a;
    --border-light: #333333;
    --accent: #e8ff47;
    --accent-dim: rgba(232, 255, 71, 0.12);
    --accent-hover: #f0ff6e;
    --red: #ff3b3b;
    --green: #39ff8f;
    --text-primary: #f0f0f0;
    --text-secondary: #888888;
    --text-muted: #444444;
    --font-display: "Syne", sans-serif;
    --font-mono: "Space Mono", monospace;
    --radius: 4px;
    --radius-lg: 8px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-mono);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* NOISE TEXTURE OVERLAY */
.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px;
}

/* =============================================
   HEADER
   ============================================= */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(12px);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-mark {
    font-family: var(--font-mono);
    font-size: 22px;
    color: var(--accent);
    letter-spacing: -2px;
    line-height: 1;
}

.logo-bracket {
    color: var(--text-muted);
}
.logo-icon {
    color: var(--accent);
}

.header-title h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    line-height: 1;
}

.header-sub {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* STATUS PILL */
.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s ease;
}

.status-pill.connected {
    border-color: var(--green);
    color: var(--green);
}
.status-pill.connected .status-dot {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse-green 2s infinite;
}

.status-pill.error {
    border-color: var(--red);
    color: var(--red);
}
.status-pill.error .status-dot {
    background: var(--red);
}

@keyframes pulse-green {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

/* =============================================
   MAIN LAYOUT
   ============================================= */
.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* =============================================
   PANELS
   ============================================= */
.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    background: var(--surface);
    position: relative;
    animation: fadeSlideIn 0.4s ease forwards;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* =============================================
   CONFIG PANEL
   ============================================= */
.config-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 40px 12px 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease;
}

.input-wrapper input:focus {
    border-color: var(--accent);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(232, 255, 71, 0.2);
}
.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}
.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-icon {
    font-size: 14px;
}

/* =============================================
   UPLOAD PANEL — MODE TABS
   ============================================= */
.upload-modes {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    width: fit-content;
}

.mode-tab {
    padding: 10px 24px;
    background: transparent;
    border: none;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-tab.active {
    background: var(--accent);
    color: #000;
    font-weight: 700;
}

.mode-tab:not(.active):hover {
    color: var(--text-primary);
    background: var(--surface-2);
}

/* =============================================
   DROPZONE
   ============================================= */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 56px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.dropzone::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--accent-dim);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.dropzone:hover,
.dropzone.drag-over {
    border-color: var(--accent);
}
.dropzone:hover::before,
.dropzone.drag-over::before {
    opacity: 1;
}

.dropzone-inner {
    position: relative;
    z-index: 1;
}

.dropzone-icon {
    font-size: 40px;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: block;
    transition: color 0.25s ease;
}

.dropzone:hover .dropzone-icon {
    color: var(--accent);
}

.dropzone-text {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.dropzone-hint {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* =============================================
   CAMERA
   ============================================= */
.camera-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    aspect-ratio: 16/9;
    max-height: 400px;
}

video#cameraFeed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Scan line animation */
.scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    animation: scan 3s linear infinite;
}

@keyframes scan {
    0% {
        top: 0%;
        opacity: 0;
    }
    5% {
        opacity: 0.7;
    }
    95% {
        opacity: 0.7;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Corner brackets */
.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--accent);
    border-style: solid;
    opacity: 0.8;
}
.tl {
    top: 16px;
    left: 16px;
    border-width: 2px 0 0 2px;
}
.tr {
    top: 16px;
    right: 16px;
    border-width: 2px 2px 0 0;
}
.bl {
    bottom: 16px;
    left: 16px;
    border-width: 0 0 2px 2px;
}
.br {
    bottom: 16px;
    right: 16px;
    border-width: 0 2px 2px 0;
}

.camera-controls {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* =============================================
   RESULT PANEL
   ============================================= */
.result-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
    align-items: center;
    margin-bottom: 24px;
}

.image-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.image-card-label {
    padding: 10px 16px;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.image-card-body {
    position: relative;
    aspect-ratio: 4/3;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-card-body img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.output-card .image-card-label {
    border-color: var(--accent);
    color: var(--accent);
}

/* PROCESSING PLACEHOLDER */
.processing-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ARROW */
.result-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.arrow-track {
    width: 3px;
    height: 60px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.arrow-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--accent);
    height: 0%;
    transition: height 1.2s ease;
}

.arrow-icon {
    font-size: 20px;
    color: var(--accent);
}

/* =============================================
   STATS BAR
   ============================================= */
.stats-bar {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
    background: var(--surface-2);
}

.stat-item {
    flex: 1;
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.success {
    color: var(--green);
}
.stat-value.error {
    color: var(--red);
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: var(--border);
    flex-shrink: 0;
}

/* =============================================
   RESULT ACTIONS
   ============================================= */
.result-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* =============================================
   TOAST
   ============================================= */
.toast-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    max-width: 320px;
    pointer-events: all;
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    border-color: var(--green);
}
.toast.success .toast-dot {
    background: var(--green);
}
.toast.error {
    border-color: var(--red);
}
.toast.error .toast-dot {
    background: var(--red);
}
.toast.info {
    border-color: var(--accent);
}
.toast.info .toast-dot {
    background: var(--accent);
}

.toast-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .header {
        padding: 16px 20px;
    }
    .main {
        padding: 24px 20px;
    }
    .panel {
        padding: 20px;
    }

    .config-row {
        flex-direction: column;
    }
    .config-row .btn {
        width: 100%;
        justify-content: center;
    }

    .result-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    .result-arrow {
        flex-direction: row;
        justify-content: center;
    }
    .arrow-track {
        width: 60px;
        height: 3px;
    }
    .arrow-fill {
        bottom: auto;
        top: 0;
        height: auto;
        width: 0%;
        right: auto;
        transition: width 1.2s ease;
    }

    .stats-bar {
        flex-direction: column;
    }
    .stat-divider {
        width: 100%;
        height: 1px;
    }

    .camera-controls {
        flex-wrap: wrap;
    }
    .camera-controls .btn {
        flex: 1;
        justify-content: center;
    }
}
