/* ── Design tokens — matches VDC upload.php exactly ─ */
:root {
    --primary:      #00BFA6;
    --primary-dark: #00897B;
    --success:      #48bb78;
    --warning:      #ed8936;
    --error:        #f56565;
    --info:         #4299e1;
    --gray-50:      #f9fafb;
    --gray-100:     #f3f4f6;
    --gray-200:     #e5e7eb;
    --gray-300:     #d1d5db;
    --gray-400:     #9ca3af;
    --gray-500:     #6b7280;
    --gray-600:     #4b5563;
    --gray-700:     #374151;
    --gray-800:     #1f2937;
    --gray-900:     #111827;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    padding: 1rem;
}

/* ── Container ───────────────────────────────────── */
.container {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    overflow: hidden;
}

/* ── Header ──────────────────────────────────────── */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 2rem 1.5rem;
    text-align: center;
}
.header h1 { font-size: 1.5rem; margin-bottom: .5rem; }

.session-info {
    background: rgba(255,255,255,.15);
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: .85rem;
}
.session-info span { opacity: .8; }

/* ── Content ─────────────────────────────────────── */
.content { padding: 2rem 1.5rem; }

/* ── Step cards — same as VDC upload.php ─────────── */
.step-card {
    border: 2px solid var(--gray-300);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all .3s;
}
.step-card.active    { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,191,166,.2); }
.step-card.completed { border-color: var(--success); background: rgba(72,187,120,.05); }
.step-card.locked    { opacity: .5; pointer-events: none; }

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.step-number { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.step-status { font-size: 1.4rem; }
.step-title  { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); margin-bottom: .4rem; }
.step-desc   { font-size: .9rem;  color: var(--gray-600); margin-bottom: 1rem; }

/* ── Camera wrapper ──────────────────────────────── */
.video-wrapper { position: relative; margin: 1rem 0; }

video {
    width: 100%;
    border-radius: 12px;
    border: 3px solid var(--error);
    transform: scaleX(-1);
    display: none;
    transition: border-color .3s;
}
video.active { display: block; }
video.aligned { border-color: var(--success); }

.face-oval {
    position: absolute;
    top: 18%; left: 36%;
    width: 28%; height: 58%;
    border: 3px dashed var(--primary);
    border-radius: 50% / 60%;
    pointer-events: none;
    display: none;
}
video.active ~ .face-oval { display: block; }

.arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    display: none;
    color: #fff;
    text-shadow: 0 0 8px rgba(0,191,166,.8);
}
#arrowLeft  { left: 8px; }
#arrowRight { right: 8px; }

/* ── Detection status box ────────────────────────── */
#detectionBox {
    position: absolute;
    top: 6%;
    left: 50%;
    transform: translateX(-50%);
    width: 55%;
    height: 44px;
    border: 3px solid var(--error);
    border-radius: 8px;
    background: rgba(245, 101, 101, 0.15);
    pointer-events: none;
    display: none;
    z-index: 10;
    transition: border-color .25s, background .25s, box-shadow .25s;
}
video.active ~ #detectionBox { display: block; }

#detectionBox.aligned {
    border-color: var(--success);
    background: rgba(72, 187, 120, 0.15);
    box-shadow: 0 0 16px rgba(72,187,120,.5);
}

/* ── Guide bar ───────────────────────────────────── */
#guideBar {
    background: var(--gray-100);
    border-radius: 8px;
    padding: .6rem 1rem;
    text-align: center;
    font-size: .9rem;
    color: var(--gray-700);
    margin-bottom: 1rem;
    display: none;
    transition: background .3s;
}
#guideBar.aligned {
    background: rgba(72,187,120,.15);
    color: #276749;
}
#guideBar.warning {
    background: rgba(237,137,54,.15);
    color: #7b341e;
}

/* ── Thumbnails panel ────────────────────────────── */
.captures-panel {
    background: var(--gray-50);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
}
.captures-panel h3 { font-size: .95rem; color: var(--gray-600); margin-bottom: 1rem; font-weight: 600; }

.thumbs-row { display: flex; gap: 10px; }

.thumb-slot {
    flex: 1;
    text-align: center;
}
.thumb-slot p {
    font-size: .75rem;
    color: var(--gray-500);
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.thumb-slot img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    background: var(--gray-200);
    border-radius: 8px;
    border: 2px solid var(--gray-300);
    display: block;
    transition: border-color .3s;
}
.thumb-slot img.captured { border-color: var(--success); }

/* ── Preview ─────────────────────────────────────── */
.photo-preview        { display: none; margin: 1rem 0; }
.photo-preview.active { display: block; }
.photo-preview img {
    width: 100%;
    max-width: 300px;
    border-radius: 8px;
    border: 2px solid var(--success);
}

/* ── Buttons — exact match to VDC ───────────────── */
.btn {
    padding: .875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: all .2s;
}
.btn-primary          { background: var(--primary);  color: #fff; }
.btn-primary:active   { background: var(--primary-dark); }
.btn-success          { background: var(--success);  color: #fff; }
.btn-warning          { background: var(--warning);  color: #fff; }
.btn-secondary        { background: var(--gray-300); color: var(--gray-800); }
.btn-large { width: 100%; padding: 1rem; font-size: 1rem; margin: .5rem 0; }

/* ── Status toast ────────────────────────────────── */
.status-message {
    position: fixed;
    top: 1rem; left: 50%;
    transform: translateX(-50%);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    z-index: 9999;
    display: none;
    max-width: 90%;
}
.status-message.active  { display: block; animation: slideDown .3s ease-out; }
.status-info            { background: var(--info);    color: #fff; }
.status-success         { background: var(--success); color: #fff; }
.status-error           { background: var(--error);   color: #fff; }
.status-warning         { background: var(--warning); color: #fff; }

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Loading overlay ─────────────────────────────── */
.loading-overlay        { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: center; justify-content: center; z-index: 9998; }
.loading-overlay.active { display: flex; }
.loader {
    border: 4px solid rgba(255,255,255,.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    width: 60px; height: 60px;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result modal — matches VDC exactly ─────────── */
.result-modal         { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; z-index: 10000; padding: 20px; }
.result-modal.active  { display: flex; }

.result-content {
    background: #fff;
    border-radius: 20px;
    padding: 40px 30px;
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    animation: slideUp .5s cubic-bezier(.175,.885,.32,1.275);
    position: relative;
    text-align: center;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-close-btn {
    position: absolute; top: 15px; right: 15px;
    width: 36px; height: 36px;
    border-radius: 50%; background: var(--gray-200);
    border: none; font-size: 22px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--gray-600); transition: all .2s;
}
.modal-close-btn:hover { background: var(--gray-300); }

.icon-circle {
    width: 100px; height: 100px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    animation: scaleIn .5s cubic-bezier(.175,.885,.32,1.275) .2s both;
}
.icon-circle.success { background: linear-gradient(135deg, var(--success), #38a169); }
.icon-circle.error   { background: linear-gradient(135deg, var(--error),   #e53e3e); }
.icon-circle.warning { background: linear-gradient(135deg, var(--warning), #dd6b20); }
@keyframes scaleIn { from { transform: scale(0); } to { transform: scale(1); } }

.icon-svg {
    width: 52px; height: 52px;
    stroke: #fff; stroke-width: 4;
    stroke-linecap: round; stroke-linejoin: round; fill: none;
    stroke-dasharray: 100; stroke-dashoffset: 100;
    animation: drawIcon .8s ease-out .5s both;
}
@keyframes drawIcon { to { stroke-dashoffset: 0; } }

.result-title    { font-size: 1.6rem; font-weight: 700; color: var(--gray-900); margin-bottom: .5rem; }
.result-message  { font-size: .95rem; color: var(--gray-600); line-height: 1.7; margin-bottom: 1.5rem; }

.modal-actions   { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 1rem; }
.btn-modal {
    flex: 1; min-width: 130px;
    padding: 12px 20px; font-size: .95rem; font-weight: 600;
    border-radius: 10px; cursor: pointer; border: none; transition: all .2s;
}
.btn-modal.btn-success { background: linear-gradient(135deg, var(--success), #38a169); color: #fff; }
.btn-modal.btn-warning { background: linear-gradient(135deg, var(--warning), #dd6b20); color: #fff; }
.btn-modal.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }

/* ── Hidden canvas ───────────────────────────────── */
#canvas { display: none; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
    .content        { padding: 1rem; }
    .result-content { padding: 24px 16px; }
    .modal-actions  { flex-direction: column; }
    .btn-modal      { width: 100%; }
    .thumbs-row     { gap: 6px; }
}