/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px;
}

/* ========== Card container ========== */
.card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    width: 100%;
    max-width: 440px;
    padding: 36px 32px;
    transition: opacity .3s;
}

.card h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}

.card .subtitle {
    font-size: 14px;
    color: #666;
    text-align: center;
    margin-bottom: 24px;
}

/* ========== Forms ========== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: border-color .2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: #4361ee;
}

.form-group textarea { resize: vertical; min-height: 80px; }

.btn {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}

.btn:active { transform: scale(.98); }

.btn-primary { background: #4361ee; color: #fff; }
.btn-primary:hover { background: #3a56d4; }
.btn-primary:disabled { background: #a0aec0; cursor: not-allowed; }

.btn-success { background: #2ec4b6; color: #fff; }
.btn-success:hover { background: #26a69a; }

/* ========== Screens ========== */
.screen { display: none; }
.screen.active { display: block; }

/* ========== Loader ========== */
.loader-wrap {
    text-align: center;
    padding: 40px 0;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #4361ee;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 16px;
}

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

.loader-wrap p {
    font-size: 14px;
    color: #888;
}

/* ========== Code display (Button1) ========== */
.code-box {
    background: #f8f9fa;
    border: 2px dashed #4361ee;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    margin: 20px 0;
}

.code-box .label {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.code-box .code {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 4px;
    color: #4361ee;
    font-family: 'Courier New', monospace;
}

/* ========== Success screen ========== */
.success-icon {
    width: 72px;
    height: 72px;
    background: #2ec4b6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.success-icon svg {
    width: 36px;
    height: 36px;
    stroke: #fff;
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.success-text {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.success-sub {
    text-align: center;
    font-size: 14px;
    color: #666;
}

/* ========== Session ID badge ========== */
.session-badge {
    font-size: 12px;
    color: #999;
    text-align: center;
    margin-top: 20px;
    word-break: break-all;
}

/* ========== Admin ========== */
.admin-wrap {
    max-width: 960px;
    width: 100%;
}

.admin-wrap h1 { text-align: left; margin-bottom: 20px; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th { background: #f8f9fa; font-weight: 600; color: #555; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-waiting  { background: #fff3cd; color: #856404; }
.badge-button1  { background: #cce5ff; color: #004085; }
.badge-button1_wait_code { background: #e2d6f3; color: #5a2d82; }
.badge-button2  { background: #d4edda; color: #155724; }
.badge-button3  { background: #d1ecf1; color: #0c5460; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-b1 { background: #4361ee; color: #fff; }
.btn-b2 { background: #2ec4b6; color: #fff; }
.btn-b3 { background: #6c757d; color: #fff; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-overlay.active { display: flex; }

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 360px;
}

.modal h3 { margin-bottom: 12px; }

.modal input {
    width: 100%;
    padding: 10px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 12px;
}

.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Events log */
.events-panel {
    margin-top: 24px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
}

.events-panel h3 { margin-bottom: 12px; font-size: 16px; }

.event-row {
    font-size: 13px;
    padding: 6px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    gap: 12px;
}

.event-time { color: #999; white-space: nowrap; }
.event-type { font-weight: 600; min-width: 120px; }
.event-src  { color: #888; font-style: italic; }

/* Responsive */
@media (max-width: 480px) {
    body { padding: 16px 8px; }
    .card { padding: 24px 18px; }
}
