/* ============================================================
   style.css  —  Luxury Mobile-First Design
   Color Palette: Deep Navy + Champagne Gold + Warm White
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Reset & Custom Properties ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy:        #0d1b2a;
    --navy-mid:    #1b2d42;
    --navy-light:  #243447;
    --gold:        #c9a84c;
    --gold-light:  #e2c97e;
    --gold-dim:    #8a6e2f;
    --cream:       #faf8f4;
    --white:       #ffffff;
    --text:        #1a1f2e;
    --muted:       #6b7280;
    --muted-light: #9ca3af;
    --border:      #e8e3db;
    --border-dark: #d4cec4;
    --success:     #16a34a;
    --danger:      #dc2626;
    --warning:     #d97706;
    --radius-sm:   8px;
    --radius:      16px;
    --radius-lg:   24px;
    --shadow-sm:   0 2px 8px rgba(13,27,42,0.08);
    --shadow:      0 8px 32px rgba(13,27,42,0.12);
    --shadow-lg:   0 20px 60px rgba(13,27,42,0.18);
    --transition:  0.25s cubic-bezier(0.4,0,0.2,1);
    --font-body:   'Sarabun', 'Inter', sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--cream);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
    background: var(--navy);
    color: #fff;
    padding: 0 1.25rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 4px 24px rgba(13,27,42,0.25);
}

.navbar::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.4;
}

.navbar-brand {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--cream);
}

.navbar-brand span {
    color: var(--gold);
}

.navbar-nav {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.nav-link {
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    padding: 0.45rem 0.85rem;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
    letter-spacing: 0.02em;
}

.nav-link:hover, .nav-link.active {
    background: rgba(201,168,76,0.15);
    color: var(--gold-light);
}

/* ── Container ──────────────────────────────────────────── */
.container {
    max-width: 520px;
    margin: 0 auto;
    padding: 1.5rem 1rem 5rem;
}

/* ── Clock Hero ─────────────────────────────────────────── */
.clock-box {
    background: linear-gradient(145deg, var(--navy) 0%, var(--navy-mid) 60%, #1e3a5f 100%);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem 2rem;
    text-align: center;
    margin-bottom: 1.25rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.clock-box::before {
    content: '';
    position: absolute;
    top: -40%; left: -20%;
    width: 140%; height: 180%;
    background: radial-gradient(ellipse at 30% 30%, rgba(201,168,76,0.12) 0%, transparent 60%);
    pointer-events: none;
}

.clock-box::after {
    content: '';
    position: absolute;
    bottom: 0; left: 10%; right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.3;
}

.clock-time {
    font-size: clamp(2.8rem, 12vw, 4.5rem);
    font-weight: 300;
    letter-spacing: 0.06em;
    color: var(--white);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-shadow: 0 0 40px rgba(201,168,76,0.3);
}

.clock-colon {
    color: var(--gold);
    opacity: 1;
    animation: blink 1s step-end infinite;
}

@keyframes blink { 50% { opacity: 0.2; } }

.clock-date {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.55);
    margin-top: 0.75rem;
    letter-spacing: 0.04em;
    font-weight: 400;
}

.clock-gold-line {
    width: 48px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 1rem auto 0;
    border-radius: 99px;
}

/* ── Card ───────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--navy);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.card-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
    margin-left: 0.5rem;
}

/* ── Form ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.45rem;
    font-size: 0.82rem;
    color: var(--navy);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

input[type="text"],
input[type="date"],
input[type="month"],
input[type="password"],
select {
    width: 100%;
    padding: 0.85rem 1.1rem;
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--cream);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
    -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="month"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: var(--gold);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

input[type="text"]::placeholder { color: var(--muted-light); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.8rem 1.75rem;
    border: none;
    border-radius: 99px;
    font-size: 0.95rem;
    font-family: var(--font-body);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.03em;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--navy-mid), var(--navy));
    color: var(--gold-light);
    box-shadow: 0 4px 16px rgba(13,27,42,0.25);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--navy), var(--navy-mid));
    box-shadow: 0 6px 20px rgba(13,27,42,0.35);
    color: var(--gold-light);
}

.btn-success {
    background: linear-gradient(135deg, #15803d, #166534);
    color: #fff;
    box-shadow: 0 4px 16px rgba(21,128,61,0.3);
}
.btn-success:hover {
    box-shadow: 0 6px 20px rgba(21,128,61,0.4);
    filter: brightness(1.05);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    box-shadow: 0 4px 16px rgba(220,38,38,0.3);
}
.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(220,38,38,0.4);
    filter: brightness(1.05);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: var(--navy);
    box-shadow: 0 4px 16px rgba(201,168,76,0.35);
    font-weight: 700;
}
.btn-gold:hover {
    box-shadow: 0 6px 20px rgba(201,168,76,0.5);
    filter: brightness(1.05);
}

.btn-outline {
    background: transparent;
    color: var(--navy);
    border: 1.5px solid var(--border-dark);
}
.btn-outline:hover {
    border-color: var(--gold);
    color: var(--gold-dim);
    background: rgba(201,168,76,0.06);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.05rem;
    width: 100%;
    border-radius: var(--radius-sm);
}

.btn-xl {
    padding: 1.2rem 2rem;
    font-size: 1.1rem;
    width: 100%;
    border-radius: var(--radius-sm);
}

.btn-group { display: flex; gap: 0.75rem; }

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Check-in / Check-out Hero Button ───────────────────── */
.action-hero {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

/* ── Status Card ─────────────────────────────────────────── */
.status-card {
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    border: 1px solid var(--border);
    background: var(--cream);
    transition: all var(--transition);
}

.status-card.checked-in {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: #86efac;
}

.status-icon { font-size: 2rem; line-height: 1; }

.status-info strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.status-info small {
    color: var(--muted);
    font-size: 0.82rem;
}

/* ── GPS Status ──────────────────────────────────────────── */
.gps-status {
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    letter-spacing: 0.02em;
}

.gps-loading {
    background: rgba(13,27,42,0.06);
    color: var(--navy);
    border: 1px solid rgba(13,27,42,0.12);
    animation: pulse-gentle 1.5s ease-in-out infinite;
}

.gps-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.gps-error {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

@keyframes pulse-gentle {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ── Alert ───────────────────────────────────────────────── */
.alert {
    padding: 1rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-top: 1rem;
    display: none;
    align-items: flex-start;
    gap: 0.5rem;
    line-height: 1.5;
    animation: slide-in 0.3s ease;
}

.alert.show { display: flex; }

.alert-success {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #15803d;
    border: 1px solid #86efac;
}

.alert-error {
    background: linear-gradient(135deg, #fff1f2, #ffe4e6);
    color: #be123c;
    border: 1px solid #fda4af;
}

.alert-info {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

@keyframes slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Badge ───────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-info    { background: rgba(201,168,76,0.15); color: var(--gold-dim); }

/* ── Tab Switch ──────────────────────────────────────────── */
.tab-switch {
    display: flex;
    background: var(--cream);
    border: 1.5px solid var(--border-dark);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 1.25rem;
    padding: 3px;
    gap: 3px;
}

.tab-switch button {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--muted);
    transition: all var(--transition);
    border-radius: 99px;
    letter-spacing: 0.02em;
}

.tab-switch button.active {
    background: var(--navy);
    color: var(--gold-light);
    box-shadow: 0 2px 8px rgba(13,27,42,0.2);
}

/* ── Filter Bar ──────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1.25rem;
}

.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    background: var(--navy);
    color: rgba(255,255,255,0.7);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--gold-dim);
    white-space: nowrap;
}

thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(201,168,76,0.04); }

td {
    padding: 0.8rem 1rem;
    vertical-align: middle;
}

.td-name { font-weight: 700; color: var(--navy); }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

.empty-state .emoji { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* ── Summary Grid ────────────────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.summary-item {
    background: linear-gradient(135deg, var(--cream), var(--white));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.1rem 1.25rem;
    transition: all var(--transition);
}

.summary-item:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 16px rgba(201,168,76,0.15);
}

.summary-item .s-name { font-weight: 700; margin-bottom: 0.3rem; color: var(--navy); }
.summary-item .s-detail { font-size: 0.83rem; color: var(--muted); line-height: 1.6; }

/* ── Stat Cards (Admin) ──────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 20px rgba(201,168,76,0.2);
    transform: translateY(-2px);
}

.stat-card .num {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.stat-card .lbl {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Admin Badge ─────────────────────────────────────────── */
.admin-badge {
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: var(--navy);
    padding: 0.15rem 0.6rem;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    vertical-align: middle;
    margin-left: 0.3rem;
}

/* ── Today Record row highlight ──────────────────────────── */
tbody tr.highlight-in { background: rgba(201,168,76,0.06) !important; }

/* ── Divider ─────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

/* ── Gold accent line ────────────────────────────────────── */
.gold-line {
    width: 40px; height: 2px;
    background: linear-gradient(90deg, var(--gold), transparent);
    border-radius: 99px;
    margin: 0.5rem 0 1rem;
}

/* ── Floating action (mobile) ────────────────────────────── */
.fab-bar {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    z-index: 100;
    box-shadow: 0 -4px 24px rgba(13,27,42,0.1);
    gap: 0.75rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .container { padding: 1rem 0.875rem 5.5rem; }
    .clock-time { font-size: clamp(2.5rem, 14vw, 3.5rem); }
    .clock-box { padding: 2rem 1.25rem 1.75rem; border-radius: 20px; }
    .card { padding: 1.25rem; border-radius: 14px; }
    .btn-lg, .btn-xl { font-size: 1.05rem; padding: 1.1rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .stat-card .num { font-size: 1.8rem; }
    .summary-grid { grid-template-columns: 1fr; }
    .table-wrap { border-radius: 10px; }
    td, th { padding: 0.65rem 0.75rem; }
    .filter-bar { flex-direction: column; }
    .filter-bar .btn { width: 100%; border-radius: var(--radius-sm); }
    .navbar { height: 58px; }
    .navbar-brand { font-size: 0.95rem; }
    .tab-switch button { font-size: 0.82rem; padding: 0.55rem 0.5rem; }
}

@media (min-width: 641px) {
    .container { padding: 2rem 1.5rem; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Custom Confirm Modal ────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13,27,42,0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 32px 80px rgba(13,27,42,0.5);
    width: 100%;
    max-width: 340px;
    overflow: hidden;
    transform: translateY(24px) scale(0.95);
    transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-overlay.visible .modal-box {
    transform: translateY(0) scale(1);
}

.modal-header {
    background: linear-gradient(145deg, var(--navy), var(--navy-mid));
    padding: 2rem 1.75rem 1.5rem;
    text-align: center;
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 20%; right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.5;
}

.modal-icon {
    font-size: 2.75rem;
    display: block;
    margin-bottom: 0.6rem;
    filter: drop-shadow(0 4px 16px rgba(201,168,76,0.4));
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--cream);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.modal-body {
    padding: 1.25rem 1.75rem;
    background: var(--cream);
}

.modal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    gap: 1rem;
}

.modal-row:last-child { border-bottom: none; }

.modal-row .lbl {
    color: var(--muted);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.modal-row .val {
    font-weight: 700;
    color: var(--navy);
    text-align: right;
}

.modal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border);
}

.modal-footer button {
    padding: 1rem;
    border: none;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.02em;
    -webkit-tap-highlight-color: transparent;
}

.modal-footer button:active { filter: brightness(0.92); }

.modal-btn-cancel {
    background: var(--cream);
    color: var(--muted);
    border-right: 1px solid var(--border);
}

.modal-btn-cancel:hover { background: #ebe9e4; color: var(--text); }

.modal-btn-checkin {
    background: linear-gradient(135deg, #15803d, #166534);
    color: #fff;
}

.modal-btn-checkin:hover { filter: brightness(1.08); }

.modal-btn-checkout {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
}

.modal-btn-checkout:hover { filter: brightness(1.08); }

/* ── Accessibility ───────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Selection ───────────────────────────────────────────── */
::selection { background: rgba(201,168,76,0.25); color: var(--navy); }

/* ── Scrollbar (WebKit) ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--cream); }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
