/* ══════ CSS VARIABLES (Theme) ══════ */
:root {
    --bg-dark: #000000;
    --text-main: #ffffff;
    --text-muted: rgba(235, 235, 245, 0.6);
    --glass-bg: rgba(28, 28, 30, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --color-checkin: #22c55e;
    --color-checkout: #0ea5e9;
    --color-error: #ef4444;
}

/* ══════ RESET & BASE ══════ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* The magic fix for the iPad Safari Viewport bug! */
    height: 100%;
    height: -webkit-fill-available;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    min-height: 100%;
    min-height: -webkit-fill-available;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ══════ BACKGROUND VIDEO ══════ */
.bg-video {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    z-index: -2;
    object-fit: cover;
}

.video-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1;
}

/* ══════ APP SHELL ══════ */
.shell {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 2.8vw, 2.4rem);
    height: 100%;
    height: -webkit-fill-available;
}

/* ══════ GLASSMORPHISM UTILITIES ══════ */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 25px 40px -22px rgba(0, 0, 0, 0.45);
}

.glass-panel-heavy {
    background: rgba(15, 15, 18, 0.85);
    backdrop-filter: blur(60px);
    -webkit-backdrop-filter: blur(60px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 32px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

/* ══════ LAYOUT: 3-COLUMN GRID ══════ */
.state-idle {
    display: grid;
    grid-template-columns: clamp(230px, 24vw, 380px) minmax(0, 1fr) clamp(250px, 24vw, 390px);
    gap: clamp(0.9rem, 2vw, 2rem);
    width: 100%;
    height: 100%;
    opacity: 0;
    /* Animated in via JS */
    transition: opacity 0.5s ease;
}

.state-idle.active {
    opacity: 1;
}

.col-left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
}

.col-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.col-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.8rem;
}

.weather-widget,
.company-info {
    width: min(100%, 320px);
}

/* LEFT WIDGETS */
.weather-temp {
    font-size: 2.5rem;
    font-weight: 300;
    line-height: 1;
}

.weather-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.weather-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.weather-icon {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex: 0 0 52px;
}

.weather-info {
    min-width: 0;
}

.weather-wind {
    color: rgba(235, 235, 245, 0.7);
    font-size: 0.82rem;
    margin-top: 0.3rem;
}

.company-info h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.company-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* OFFLINE INDICATOR */
.offline-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.15);
    /* Red tinted glass */
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    margin-top: -0.5rem;
    /* pull up closer */
}

.offline-indicator i {
    font-size: 1.4rem;
    position: relative;
}

.offline-indicator i::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -20%;
    right: -20%;
    height: 2px;
    background: #fca5a5;
    transform: rotate(45deg);
}

.offline-text {
    display: flex;
    flex-direction: column;
}

.offline-text strong {
    font-size: 0.9rem;
    font-weight: 600;
}

.offline-text span {
    font-size: 0.75rem;
    color: rgba(252, 165, 165, 0.8);
}

.pulse-slow {
    animation: pulse 4s infinite;
}

/* CENTER WIDGET (CLOCK) */
.date-display {
    font-size: clamp(1.1rem, 1.5vw, 1.9rem);
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.15;
}

.time-display {
    font-family: 'Inter', sans-serif;
    font-size: clamp(5.2rem, 9vw, 10.5rem);
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.04em;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
    /* Monospaced numerals so the clock doesn't jiggle */
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* RIGHT WIDGETS */
.logo {
    width: auto;
    max-width: min(100%, 250px);
    max-height: 68px;
    opacity: 0.8;
    filter: brightness(2) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.logo-secret-trigger {
    cursor: pointer;
}

.branding {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    margin-top: 0.2rem;
    margin-bottom: auto;
    text-align: right;
    width: min(100%, 360px);
}

/* SCAN PROMPT */
.scan-prompt {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.2rem 1.5rem;
    width: min(100%, 340px);
    justify-content: space-between;
}

.prompt-text {
    text-align: right;
}

.prompt-text h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.prompt-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
    max-width: 210px;
}

.icon-circle {
    width: 54px;
    height: 54px;
    min-width: 54px;
    min-height: 54px;
    aspect-ratio: 1 / 1;
    flex: 0 0 54px;
    border-radius: 50%;
    background: rgba(10, 132, 255, 0.2);
    border: 1px solid rgba(10, 132, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(10, 132, 255, 0.3);
}

.icon-circle i {
    font-size: 1.4rem;
    color: #5bb5ff;
    transform: rotate(45deg);
}

/* ══════ SUCCESS & ERROR STATES ══════ */
.state-success,
.state-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 600px;
    max-width: 90%;
    text-align: center;
    padding: 4rem 2rem;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 10;
}

.state-success.active,
.state-error.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.success-icon,
.error-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    margin: 0 auto 2rem auto;
}

/* Dynamic colors injected by JS */
.state-success.theme-checkin .success-icon {
    background: rgba(34, 197, 94, 0.2);
    color: var(--color-checkin);
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.4);
    border: 2px solid var(--color-checkin);
}

.state-success.theme-checkin .success-action {
    color: var(--color-checkin);
}

.state-success.theme-checkout .success-icon {
    background: rgba(14, 165, 233, 0.2);
    color: var(--color-checkout);
    box-shadow: 0 0 30px rgba(14, 165, 233, 0.4);
    border: 2px solid var(--color-checkout);
}

.state-success.theme-checkout .success-action {
    color: var(--color-checkout);
}

.state-error .error-icon {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-error);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
    border: 2px solid var(--color-error);
}

.state-success h1,
.state-error h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.success-action,
.error-message {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 2rem;
}

.success-time {
    font-size: 2.5rem;
    font-weight: 300;
    font-family: 'JetBrains Mono', monospace;
}

.success-duration {
    margin-top: 1.5rem;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.success-duration span {
    color: var(--text-main);
    font-weight: 600;
}

/* ══════ HELPERS & ANIMATIONS ══════ */
.hidden {
    display: none !important;
}

.pulse {
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
    }
}

/* ══════ SETTINGS MODAL ══════ */
.settings-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pin-panel {
    width: min(420px, 92vw);
    background: linear-gradient(145deg, rgba(25, 25, 30, 0.97), rgba(15, 15, 18, 0.99));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.pin-panel h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.pin-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.pin-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pin-form input {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pin-form input:focus {
    border-color: rgba(45, 207, 208, 0.6);
    box-shadow: 0 0 0 3px rgba(45, 207, 208, 0.15);
}

.pin-error {
    color: #fca5a5;
    font-size: 0.82rem;
}

.pin-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* ══════ SETTINGS PANEL ══════ */
.settings-panel {
    width: min(580px, 94vw);
    max-height: 88vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(145deg, rgba(25, 25, 30, 0.97), rgba(15, 15, 18, 0.99));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 1.75rem;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);

    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.settings-panel::-webkit-scrollbar {
    width: 5px;
}

.settings-panel::-webkit-scrollbar-track {
    background: transparent;
}

.settings-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.settings-close-btn {
    border: 0;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.settings-close-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

/* Settings form – now single column with grouped sections */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.01em;
}

.settings-form input,
.settings-form select {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    font-size: 0.88rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-form input:focus,
.settings-form select:focus {
    border-color: rgba(45, 207, 208, 0.5);
    box-shadow: 0 0 0 3px rgba(45, 207, 208, 0.1);
}

.settings-form input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.numpad-btn {
    transition: all 0.15s;
}

.numpad-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    transform: scale(1.03);
}

.numpad-btn:active {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: scale(0.97);
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
}

/* ══════ BUTTONS ══════ */
.btn-save,
.btn-reset {
    border: 0;
    border-radius: 12px;
    padding: 0.65rem 1.2rem;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn-save {
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: #fff;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.btn-save:hover {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.4);
    transform: translateY(-1px);
}

.btn-save:active {
    transform: translateY(0);
}

.btn-save.disabled,
.btn-save:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-reset {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-reset:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.15);
}

/* ══════ NFC PAIRING SECTION ══════ */
.nfc-pairing-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

/* ══════ RESPONSIVE ══════ */
@media (max-width: 1366px) {
    .company-info h2 {
        font-size: 1.05rem;
    }

    .weather-temp {
        font-size: 2.15rem;
    }

    .scan-prompt {
        padding: 1rem 1.1rem;
    }
}

@media (max-width: 980px) {
    .state-idle {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        align-items: center;
    }

    .col-left {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }

    .col-right {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1.5rem;
    }

    .branding {
        margin-bottom: 0;
        margin-left: 0.8rem;
    }
}

@media (max-width: 760px) {
    .shell {
        padding: 0.8rem;
    }

    .col-left,
    .col-right {
        flex-direction: column;
        align-items: stretch;
    }

    .branding,
    .prompt-text {
        text-align: left;
    }

    .scan-prompt {
        width: 100%;
    }

    .settings-panel {
        width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
}