:root {
    --bg-primary: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.75);
    --border-card: rgba(255, 255, 255, 0.12);
    --accent-blue: #38bdf8;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    color: var(--text-primary);
}

body {
    display: flex;
    flex-direction: column;
}

/* ==========================================
   1. Header Navigation (115px High Kiosk Nav)
   ========================================== */
header {
    height: 115px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 24px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 2px solid var(--border-card);
    flex-shrink: 0;
    z-index: 100;
}

.nav-tabs {
    display: flex;
    gap: 14px;
    background: rgba(30, 41, 59, 0.7);
    padding: 8px;
    border-radius: 20px;
    border: 1px solid var(--border-card);
}

.tab-btn {
    padding: 16px 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 2.4rem;
    font-weight: 800;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: var(--accent-blue);
    color: #0f172a;
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

/* ==========================================
   2. Main Layout (Full Screen Kiosk)
   ========================================== */
main {
    flex: 1;
    width: 100%;
    height: calc(100vh - 115px);
    position: relative;
    overflow: hidden;
}

.view-section {
    display: none;
    width: 100%;
    height: 100%;
    padding: 16px;
    animation: fadeIn 0.25s ease-in-out;
}

.view-section.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.99); }
    to { opacity: 1; transform: scale(1); }
}

/* Common Card */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    height: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

/* ==========================================
   3. Face Kiosk Fullscreen View
   ========================================== */
.face-kiosk-fullscreen {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    gap: 14px;
}

/* Camera Box (Takes all available vertical space) */
.camera-box {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    border-radius: 24px;
    overflow: hidden;
    background: #000;
    border: 3px solid var(--accent-blue);
    box-shadow: 0 0 35px rgba(56, 189, 248, 0.25);
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* 거울 모드 */
}

canvas {
    display: none;
}

.face-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 400px;
    max-height: 75%;
    border: 3px dashed rgba(56, 189, 248, 0.75);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.3);
}

.scan-status-badge {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 18px 44px;
    border-radius: 50px;
    font-size: 2.2rem;
    font-weight: 800;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border: 3px solid var(--border-card);
    white-space: nowrap;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
}

.scan-status-badge.scanning {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

.scan-status-badge.success {
    color: var(--accent-green);
    border-color: var(--accent-green);
    background: rgba(34, 197, 94, 0.25);
}

/* 7-Second Full Screen Camera Overlay (3.0rem ~ 3.8rem) */
.fullscreen-member-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(20px);
    z-index: 50;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 16px;
    animation: fadeIn 0.25s ease-in-out;
}

.fullscreen-member-overlay.active {
    display: flex;
}

.overlay-member-header {
    font-size: 3.6rem;
    font-weight: 800;
    color: var(--accent-green);
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: -1px;
    text-shadow: 0 4px 20px rgba(34, 197, 94, 0.35);
}

.overlay-cards-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 900px;
}

.overlay-card {
    background: rgba(30, 41, 59, 0.88);
    border: 2px solid var(--border-card);
    border-radius: 20px;
    padding: 16px 28px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.overlay-card.active {
    border-color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.14);
}

.overlay-card.inactive {
    opacity: 0.55;
}

.overlay-card-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.overlay-icon {
    font-size: 2.6rem;
}

.overlay-label {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.overlay-value {
    font-size: 3.2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.overlay-value.active {
    color: var(--accent-blue);
}

.overlay-value.inactive {
    color: var(--text-secondary);
}

.manual-scan-btn {
    width: 180px;
    height: 100%;
    flex-shrink: 0;
    background: var(--accent-blue);
    color: #0f172a;
    border: none;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.manual-scan-btn:active {
    transform: scale(0.96);
    background: #0284c7;
}

/* ==========================================
   4. Keypad View
   ========================================== */
.keypad-container {
    width: 100%;
    max-width: 850px;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    height: auto;
}

.phone-display {
    width: 100%;
    max-width: 440px;
    padding: 16px;
    font-size: 2.2rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 4px;
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid var(--accent-blue);
    border-radius: 16px;
    color: var(--accent-blue);
}

.keypad-grid {
    width: 100%;
    max-width: 440px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.key-btn {
    height: 72px;
    border-radius: 16px;
    border: 1px solid var(--border-card);
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-primary);
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.key-btn:active {
    background: var(--accent-blue);
    color: #0f172a;
    transform: scale(0.96);
}

.key-btn.action {
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent-blue);
}

.key-btn.submit {
    grid-column: span 3;
    background: var(--accent-green);
    color: #0f172a;
    font-size: 1.4rem;
}

/* Result Banner for Keypad */
.result-banner {
    display: none;
    width: 100%;
    padding: 24px;
    border-radius: 24px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
}

.result-banner.success {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid var(--accent-green);
    color: var(--text-primary);
}

.result-banner.fail {
    display: block;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

/* ==========================================
   5. Admin View
   ========================================== */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.admin-panel {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    padding: 20px;
}

.admin-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--accent-blue);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-control {
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-card);
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-primary);
    font-size: 1rem;
}

.btn-primary {
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    background: var(--accent-blue);
    color: #0f172a;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
}

.member-list-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.member-list-table th, .member-list-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-card);
    font-size: 0.9rem;
}

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.face-on { background: rgba(34, 197, 94, 0.2); color: var(--accent-green); cursor: pointer; }
.badge.face-off { background: rgba(148, 163, 184, 0.2); color: var(--text-secondary); }

/* Photo Modal Backdrop */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.modal-backdrop.active {
    display: flex;
    animation: fadeIn 0.2s ease-in-out;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 440px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    text-align: center;
}

/* Admin Camera Box */
.admin-camera-box {
    position: relative;
    width: 100%;
    height: 220px;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    border: 2px solid #8b5cf6;
    margin: 10px 0;
}

.admin-camera-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
    .manual-scan-btn {
        width: 130px;
        font-size: 0.95rem;
    }
}
