/* ============================================
   Face Login System — Main Stylesheet
   Dark / Cyberpunk Theme
   ============================================ */

:root {
    --bg-dark:      #0a0e1a;
    --bg-card:      #111827;
    --bg-input:     #1f2937;
    --accent:       #6366f1;
    --accent-glow:  #6366f180;
    --accent-2:     #06b6d4;
    --success:      #10b981;
    --danger:       #ef4444;
    --warning:      #f59e0b;
    --text:         #f1f5f9;
    --text-muted:   #94a3b8;
    --border:       #1e293b;
    --border-glow:  #6366f140;
    --radius:       16px;
    --radius-sm:    10px;
}

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

html, body {
    height: 100%;
    background: var(--bg-dark);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
}

/* Background grid */
body::before {
    content: '';
    position: fixed; inset: 0;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative; z-index: 1;
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

/* ── Card ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%; max-width: 500px;
    box-shadow: 0 0 60px #6366f120, 0 20px 60px #00000060;
}

.card-header { text-align: center; margin-bottom: 32px; }

.logo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 50%; font-size: 28px; margin-bottom: 16px;
    box-shadow: 0 0 30px var(--accent-glow);
}

.card-header h1 {
    font-size: 26px; font-weight: 700;
    background: linear-gradient(135deg, var(--text), var(--accent-2));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.card-header p { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

/* ── Camera Box ── */
.camera-wrapper {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
    background: #000;
    margin-bottom: 20px;
    border: 2px solid var(--border);
    transition: border-color 0.4s;
}

.camera-wrapper.scanning  { border-color: var(--accent);  box-shadow: 0 0 20px var(--accent-glow); }
.camera-wrapper.challenge { border-color: var(--warning);  box-shadow: 0 0 20px #f59e0b40; }
.camera-wrapper.success   { border-color: var(--success);  box-shadow: 0 0 20px #10b98140; }
.camera-wrapper.error     { border-color: var(--danger);   box-shadow: 0 0 20px #ef444440; }

#videoEl, #canvasEl {
    width: 100%; height: 100%; object-fit: cover;
    position: absolute; top: 0; left: 0;
    transform: scaleX(-1); /* Mirror selfie cam */
}

#canvasEl { pointer-events: none; }

.camera-placeholder {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    background: var(--bg-input); color: var(--text-muted);
}

.camera-placeholder .icon { font-size: 48px; opacity: 0.5; }

/* ── Status overlays on camera ── */
.camera-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 12px 16px;
    background: linear-gradient(transparent, #000000cc);
    display: none;
}

.camera-overlay.visible { display: block; }

.status-text {
    font-size: 15px; font-weight: 600; text-align: center;
    color: var(--text); text-shadow: 0 1px 4px #000;
}

/* Challenge badge */
.challenge-badge {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
    background: var(--warning);
    color: #000; font-weight: 700; font-size: 14px;
    padding: 6px 18px; border-radius: 20px;
    display: none; white-space: nowrap;
}
.challenge-badge.visible { display: block; }

/* Progress bar for challenge */
.challenge-progress {
    position: absolute; bottom: 0; left: 0;
    height: 4px; background: var(--warning);
    transition: width 0.1s linear;
    display: none;
}
.challenge-progress.visible { display: block; }

/* Face detection box (drawn on canvas) */

/* ── Buttons ── */
.btn {
    width: 100%; padding: 14px;
    border: none; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: all 0.2s; display: flex;
    align-items: center; justify-content: center; gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #4f46e5);
    color: #fff;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    box-shadow: 0 4px 20px #10b98140;
}
.btn-success:hover:not(:disabled) { transform: translateY(-2px); }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

/* ── Input ── */
.input-group { margin-bottom: 16px; }

.input-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.5px;
}

.input-wrap { position: relative; }

.input-wrap input {
    width: 100%; padding: 13px 16px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 15px; outline: none; transition: border 0.2s;
    letter-spacing: 4px; text-align: center; font-weight: 600;
}

.input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.eye-toggle {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 18px; padding: 4px;
}

/* ── Alerts ── */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 14px; margin-bottom: 16px; display: none;
    border-left: 3px solid;
}
.alert.show { display: flex; align-items: center; gap: 10px; }
.alert-success { background: #10b98115; border-color: var(--success); color: #6ee7b7; }
.alert-error   { background: #ef444415; border-color: var(--danger);  color: #fca5a5; }
.alert-info    { background: #6366f115; border-color: var(--accent);  color: #a5b4fc; }
.alert-warning { background: #f59e0b15; border-color: var(--warning); color: #fcd34d; }

/* ── Step indicator ── */
.steps {
    display: flex; align-items: center; justify-content: center;
    gap: 0; margin-bottom: 28px;
}

.step {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600;
    color: var(--text-muted); transition: color 0.3s;
}

.step.active { color: var(--accent); }
.step.done   { color: var(--success); }

.step-num {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid currentColor;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; transition: all 0.3s; flex-shrink: 0;
}

.step.done .step-num { background: var(--success); border-color: var(--success); color: #fff; }
.step.active .step-num { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 12px var(--accent-glow); }

.step-divider {
    flex: 1; height: 1px; background: var(--border); max-width: 40px;
}

/* ── Panels ── */
.panel { display: none; }
.panel.active { display: block; }

/* ── Spinner ── */
.spinner {
    width: 20px; height: 20px; border: 2px solid transparent;
    border-top-color: currentColor; border-radius: 50%;
    animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Face detection ring ── */
.face-ring {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 180px; height: 220px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--accent-glow);
    animation: ringPulse 2s ease-in-out infinite;
    pointer-events: none; display: none;
}
.face-ring.visible { display: block; }
.face-ring.found   { border-color: var(--success); box-shadow: 0 0 0 4px #10b98140; animation: none; }
.face-ring.lost    { border-color: var(--danger); animation: none; }
.face-ring.warn    { border-color: var(--warning); animation: none; }

@keyframes ringPulse {
    0%,100% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
    50%      { opacity: 0.6; transform: translate(-50%,-50%) scale(1.04); }
}

/* ── User info chip (after match) ── */
.user-chip {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-input); border: 1px solid var(--success);
    border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 20px;
}
.user-chip .avatar {
    width: 44px; height: 44px; background: var(--accent);
    border-radius: 50%; display: flex; align-items: center;
    justify-content: center; font-size: 20px; flex-shrink: 0;
}
.user-chip .info h3 { font-size: 16px; font-weight: 700; }
.user-chip .info p  { font-size: 12px; color: var(--success); }

/* ── Responsive ── */
@media (max-width: 480px) {
    .card { padding: 24px 20px; }
    .card-header h1 { font-size: 22px; }
    .steps { gap: 4px; }
    .step span:not(.step-num) { display: none; }
}
