/* =============================================================
   Attendance System — Stylesheet
   ============================================================= */

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

:root {
    --primary: #0ea5e9;
    --primary-dark: #0369a1;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sarabun", "Noto Sans Thai", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    padding: 16px;
}

.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 24px 20px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.header p {
    font-size: 14px;
    opacity: 0.9;
}

.card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

.card h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text);
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.field input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    background: #fff;
    font-family: inherit;
}

.field input:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

.btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-ghost   { background: #f1f5f9; color: var(--text); }

.btn + .btn { margin-top: 10px; }

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

.row .btn { margin-top: 0; }

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
}

.status-ok      { background: #dcfce7; color: #166534; }
.status-warn    { background: #fef3c7; color: #854d0e; }
.status-error   { background: #fee2e2; color: #991b1b; }
.status-info    { background: #dbeafe; color: #1e40af; }

.dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

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

.timer {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    margin: 16px 0;
    font-variant-numeric: tabular-nums;
}

.timer.over { color: var(--danger); }

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child { border: none; }
.info-row .label { color: var(--text-muted); }
.info-row .value { font-weight: 600; }

.preview {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    background: #000;
    object-fit: cover;
    margin-bottom: 12px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal.show { display: flex; }

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.muted {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
}

.hidden { display: none !important; }

/* Dashboard table */
.table {
    width: 100%;
    font-size: 14px;
    border-collapse: collapse;
}
.table th, .table td {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: #f1f5f9;
    font-weight: 600;
    font-size: 13px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-yellow{ background: #fef3c7; color: #854d0e; }
.badge-gray  { background: #f1f5f9; color: #475569; }

/* Language switcher */
.lang-switcher {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
}
.lang-btn {
    padding: 6px 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-muted);
}
.lang-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.lang-btn:hover:not(.active) {
    background: #f1f5f9;
}

/* Inline action buttons (in tables) */
.btn-action {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    margin-right: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.btn-action:hover {
    background: #f1f5f9;
}
select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: #fff;
}
