@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ==========================================================
   CSS Design Tokens & Modern Theme Variables
   ========================================================== */
:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-rgb: 2, 132, 199;

    --success: #10b981;
    --success-dark: #059669;
    --success-light: #d1fae5;
    --success-rgb: 16, 185, 129;

    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #fee2e2;
    --danger-rgb: 239, 68, 68;

    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-rgb: 245, 158, 11;

    --info: #06b6d4;
    --info-light: #cffafe;
    --info-rgb: 6, 182, 212;

    --dark-navy: #091322;
    --surface-dark: #0f1d33;
    --surface-card: #13243f;
    --surface-card-hover: #172c4c;
    --border-dark: rgba(255, 255, 255, 0.09);
    --border-dark-highlight: rgba(56, 189, 248, 0.25);

    --text-light: #f8fafc;
    --text-light-muted: #94a3b8;
    --text-dark: #1e293b;
    --text-dark-muted: #64748b;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 6px 20px -2px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 14px 35px -5px rgba(0, 0, 0, 0.15);
    --shadow-kiosk: 0 12px 35px rgba(0, 0, 0, 0.5);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================
   Base Styles & Modern Typography (Baseline 2024+)
   ========================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-dark);
    background-color: #f1f5f9;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Modern text wrapping per modern-web-guidance */
h1, h2, h3, h4, h5, h6, .text-balance {
    text-wrap: balance;
    letter-spacing: -0.01em;
}

p, .text-pretty {
    text-wrap: pretty;
}

/* Accessible focus ring */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ==========================================================
   Public App Navbar
   ========================================================== */
.app-navbar {
    background: linear-gradient(135deg, #091322 0%, #0369a1 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.app-navbar .navbar-brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: #fff !important;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.2px;
}
.app-navbar .navbar-brand i {
    color: #38bdf8;
    filter: drop-shadow(0 2px 6px rgba(56, 189, 248, 0.4));
}

/* ==========================================================
   Card Styling & Glassmorphism
   ========================================================== */
.custom-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}
.custom-card:hover {
    box-shadow: var(--shadow-lg);
}

/* ==========================================================
   Citizen Registration Form (index.php)
   ========================================================== */
.reg-container {
    max-width: 580px;
    margin: 1.5rem auto 3rem auto;
    padding: 0 1rem;
}

.reg-hero {
    text-align: center;
    margin-bottom: 1.5rem;
}
.reg-hero-badge {
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.5rem;
}

/* Photo Upload Box with Floating Camera Badge */
.photo-uploader-wrapper {
    position: relative;
    width: 170px;
    margin: 0 auto 1rem auto;
}
.photo-preview-box {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    border: 4px solid #bae6fd;
    background: #f8fafc;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    box-shadow: 0 10px 25px -4px rgba(2, 132, 199, 0.25);
    transition: var(--transition);
}
.photo-preview-box:hover {
    transform: scale(1.03);
    border-color: var(--primary);
}
.photo-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.camera-badge-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
    border: 3px solid #ffffff;
    cursor: pointer;
    transition: var(--transition);
}
.camera-badge-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.photo-required-alert {
    border: 3px dashed var(--danger) !important;
    background-color: #fef2f2 !important;
    animation: pulseBorder 1.5s infinite;
}
@keyframes pulseBorder {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Modern Form Controls */
.form-label {
    color: #1e293b;
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}
.input-group {
    border-radius: var(--radius-md);
    transition: var(--transition);
}
.input-group:focus-within {
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.18);
}
.input-group:focus-within .input-group-text,
.input-group:focus-within .form-control {
    border-color: var(--primary);
}
.input-group-text {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    border-color: #cbd5e1;
    background: #f8fafc;
    color: #0284c7;
    padding: 0.72rem 1rem;
    font-size: 1.05rem;
}
.form-control {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    border-color: #cbd5e1;
    padding: 0.72rem 1rem;
    font-size: 1rem;
    color: #0f172a;
    transition: var(--transition);
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: none;
}
.form-control::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

/* High-Contrast Visible Checkbox */
.pdpa-check-input {
    width: 1.4rem !important;
    height: 1.4rem !important;
    border: 2.5px solid #0369a1 !important; /* สีเข้ม คมชัด มองเห็นง่าย 100% */
    border-radius: 6px !important;
    background-color: #ffffff !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}
.pdpa-check-input:hover {
    border-color: #0284c7 !important;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15) !important;
}
.pdpa-check-input:checked {
    background-color: #0284c7 !important;
    border-color: #0284c7 !important;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2) !important;
}

/* Digital Pass Card in Modal */
.pass-card-container {
    background: linear-gradient(145deg, #091a2f 0%, #1e3a5f 60%, #0284c7 100%);
    border-radius: var(--radius-xl);
    color: white;
    padding: 1.5rem;
    box-shadow: 0 20px 40px -10px rgba(9, 26, 47, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    overflow: hidden;
}
.pass-card-container::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.35) 0%, transparent 70%);
    border-radius: 50%;
}
.pass-qr-frame {
    background: #ffffff;
    padding: 16px;
    border-radius: 18px;
    display: inline-block;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    position: relative;
}
#qrcodeContainer {
    position: relative;
    z-index: 2;
}

/* ==========================================================
   Fullscreen Unified Kiosk Mode Styles (gate.php)
   ========================================================== */
.kiosk-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--dark-navy);
    color: var(--text-light);
}

.kiosk-navbar {
    background: var(--surface-dark);
    border-bottom: 2px solid #1c3254;
    padding: 0.55rem 1.5rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.kiosk-content {
    flex: 1;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
}

.gate-in-card {
    background: #0f213b;
    border: 1px solid #1c3d69;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-kiosk);
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.gate-in-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #06b6d4);
}

.gate-out-card {
    background: #0d1d33;
    border: 1px solid #183354;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-kiosk);
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.gate-out-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #0284c7, #38bdf8);
}

.kiosk-banner {
    padding: 0.95rem 1.25rem;
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 700;
    font-size: 1.6rem;
    letter-spacing: 0.3px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.banner-idle-in {
    background: #172a45;
    color: #93c5fd;
    border: 2px dashed #2563eb;
}
.banner-idle-out {
    background: #13243b;
    color: #7dd3fc;
    border: 2px dashed #0284c7;
}
.banner-allow {
    background: #064e3b;
    color: #6ee7b7;
    border: 2px solid var(--success);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.45);
    animation: glowSuccess 1.5s infinite alternate;
}
@keyframes glowSuccess {
    from { box-shadow: 0 0 20px rgba(16, 185, 129, 0.3); }
    to { box-shadow: 0 0 40px rgba(16, 185, 129, 0.6); }
}

.banner-deny {
    background: #7f1d1d;
    color: #fca5a5;
    border: 2px solid var(--danger);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.45);
    animation: glowDeny 1.5s infinite alternate;
}
@keyframes glowDeny {
    from { box-shadow: 0 0 20px rgba(239, 68, 68, 0.3); }
    to { box-shadow: 0 0 40px rgba(239, 68, 68, 0.6); }
}

.kiosk-photo-box {
    width: 235px;
    height: 235px;
    border-radius: var(--radius-lg);
    border: 4px solid var(--success);
    background: #06101d;
    overflow: hidden;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.kiosk-photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.last-exit-box {
    background: #091629;
    border: 1px solid #1c3d66;
    border-radius: var(--radius-md);
    padding: 0.95rem 1.15rem;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.2);
}
.avatar-sm {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    border: 2px solid #38bdf8;
    object-fit: cover;
}

/* Kiosk Dark Tables */
.table-dark-custom {
    --bs-table-bg: transparent;
    --bs-table-color: #e2e8f0;
}
.table-dark-custom thead th {
    background: #091424;
    color: #94a3b8;
    border-bottom: 2px solid #1c3250;
    font-weight: 600;
    padding: 0.65rem 0.5rem;
    font-size: 0.88rem;
}
.table-dark-custom tbody td {
    border-bottom: 1px solid #132742;
    padding: 0.65rem 0.5rem;
    vertical-align: middle;
}
.table-dark-custom tbody tr {
    transition: background-color 0.2s ease;
}
.table-dark-custom tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.clock-display {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 1.35rem;
    letter-spacing: 1px;
}
.manual-scanner-box {
    background: #07101c;
    border-radius: var(--radius-md);
    padding: 0.75rem 0.9rem;
    border: 1px solid #183152;
}

/* ==========================================================
   Modern Floating Toast Notifications (Component)
   ========================================================== */
#appToastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.app-toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 420px;
    background: rgba(15, 29, 51, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #f8fafc;
    border-radius: var(--radius-md);
    padding: 12px 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: var(--transition);
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.app-toast.toast-hiding {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
}
.app-toast.toast-success {
    border-left: 4px solid var(--success);
}
.app-toast.toast-error {
    border-left: 4px solid var(--danger);
}
.app-toast.toast-info {
    border-left: 4px solid var(--info);
}
.app-toast.toast-warning {
    border-left: 4px solid var(--warning);
}

/* ==========================================================
   Reduced Motion Preferences (Accessibility)
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
