/* ============================================
   CLOCKIN KIOSK — Design System
   Restaurant Staff Time Tracker
   ============================================ */

:root {
    /* Colours */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #1a1a1a;
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.65);
    --text-tertiary: rgba(255, 255, 255, 0.35);
    --text-muted: rgba(255, 255, 255, 0.2);

    --accent-green: #34d399;
    --accent-green-glow: rgba(52, 211, 153, 0.2);
    --accent-red: #f87171;
    --accent-red-glow: rgba(248, 113, 113, 0.2);
    --accent-blue: #60a5fa;
    --accent-blue-glow: rgba(96, 165, 250, 0.15);
    --accent-amber: #fbbf24;
    --accent-amber-glow: rgba(251, 191, 36, 0.15);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-green: 0 0 40px rgba(52, 211, 153, 0.15);
    --shadow-glow-red: 0 0 40px rgba(248, 113, 113, 0.15);

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', 'Menlo', monospace;
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Prevent zoom */
input, select, textarea {
    font-size: 16px !important;
}

/* ============================================
   App Container
   ============================================ */

#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ============================================
   Screens
   ============================================ */

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) var(--ease-out),
                visibility var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out);
    transform: scale(0.97);
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    z-index: 10;
}

/* ============================================
   Top Bar (shared)
   ============================================ */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) var(--space-2xl);
    flex-shrink: 0;
}

.live-clock {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.live-clock .time {
    font-size: 22px;
    color: var(--text-primary);
    font-weight: 600;
}

.live-clock .date {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* ============================================
   IDLE Screen
   ============================================ */

#idle-screen {
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.idle-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
}

.logo-container {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-ring {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-subtle);
    animation: breathe 4s var(--ease-in-out) infinite;
}

.logo-ring:nth-child(2) {
    inset: -8px;
    animation-delay: -1.3s;
    opacity: 0.5;
}

.logo-ring:nth-child(3) {
    inset: -16px;
    animation-delay: -2.6s;
    opacity: 0.25;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.05); opacity: 0.6; }
}

.logo-icon {
    font-size: 48px;
    z-index: 1;
}

.idle-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.idle-subtitle {
    font-size: 16px;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Staff ticker */
.ticker-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    overflow: hidden;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.ticker-label {
    position: absolute;
    left: var(--space-2xl);
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-green);
    z-index: 2;
    background: var(--bg-primary);
    padding-right: var(--space-md);
}

.ticker-track {
    display: flex;
    align-items: center;
    height: 100%;
    padding-left: 180px;
    animation: ticker-scroll 30s linear infinite;
}

.ticker-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0 var(--space-xl);
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.ticker-item .dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--accent-green);
    flex-shrink: 0;
}

.ticker-item .name {
    font-weight: 500;
    color: var(--text-primary);
}

.ticker-item .role {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: capitalize;
}

@keyframes ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ============================================
   PIN Screen
   ============================================ */

#pin-screen {
    align-items: center;
    justify-content: center;
}

.pin-layout {
    display: flex;
    align-items: center;
    gap: var(--space-3xl);
}

.pin-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
}

.pin-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-secondary);
}

.pin-dots {
    display: flex;
    gap: var(--space-lg);
}

.pin-dot {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-light);
    transition: all var(--duration-fast) var(--ease-spring);
}

.pin-dot.filled {
    background: var(--text-primary);
    border-color: var(--text-primary);
    transform: scale(1.15);
}

.pin-dot.error {
    border-color: var(--accent-red);
    background: var(--accent-red);
}

.pin-error {
    font-size: 14px;
    color: var(--accent-red);
    height: 20px;
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-out);
}

.pin-error.visible {
    opacity: 1;
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

.key {
    width: 88px;
    height: 88px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 32px;
    font-weight: 500;
    font-family: var(--font-sans);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.key:active {
    background: var(--bg-glass-hover);
    transform: scale(0.95);
}

.key.fn {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.key.fn:active {
    color: var(--text-primary);
}

/* Camera preview */
.camera-preview-container {
    position: absolute;
    bottom: var(--space-xl);
    right: var(--space-xl);
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 2px solid var(--border-subtle);
    opacity: 0.6;
}

.camera-preview-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

/* Back button */
.back-btn {
    position: absolute;
    top: var(--space-xl);
    left: var(--space-xl);
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: all var(--duration-fast) var(--ease-out);
}

.back-btn:active {
    background: var(--bg-glass-hover);
    transform: scale(0.92);
}

/* Shake animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
    20%, 40%, 60%, 80% { transform: translateX(6px); }
}

.shake {
    animation: shake 0.5s var(--ease-out);
}

/* ============================================
   CONFIRM Screen
   ============================================ */

#confirm-screen {
    align-items: center;
    justify-content: center;
}

.confirm-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
}

.staff-avatar {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.staff-info {
    text-align: center;
}

.staff-name {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.staff-role {
    font-size: 16px;
    color: var(--text-secondary);
    text-transform: capitalize;
    margin-top: var(--space-xs);
}

.confirm-btn {
    min-width: 280px;
    padding: var(--space-lg) var(--space-2xl);
    border-radius: var(--radius-xl);
    border: none;
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.confirm-btn.clock-in {
    background: var(--accent-green);
    color: #0a0a0a;
    box-shadow: var(--shadow-glow-green);
}

.confirm-btn.clock-in:active {
    transform: scale(0.96);
    box-shadow: 0 0 60px rgba(52, 211, 153, 0.3);
}

.confirm-btn.clock-out {
    background: var(--accent-red);
    color: #0a0a0a;
    box-shadow: var(--shadow-glow-red);
}

.confirm-btn.clock-out:active {
    transform: scale(0.96);
    box-shadow: 0 0 60px rgba(248, 113, 113, 0.3);
}

.confirm-time {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-tertiary);
}

/* ============================================
   SUCCESS Screen
   ============================================ */

#success-screen {
    align-items: center;
    justify-content: center;
}

.success-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.success-checkmark {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    animation: pop-in 0.5s var(--ease-spring);
}

.success-checkmark.clock-in {
    background: var(--accent-green-glow);
    color: var(--accent-green);
}

.success-checkmark.clock-out {
    background: var(--accent-red-glow);
    color: var(--accent-red);
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.success-action {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.success-action.clock-in {
    color: var(--accent-green);
}

.success-action.clock-out {
    color: var(--accent-red);
}

.success-name {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.success-role {
    font-size: 16px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.success-timestamp {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--text-tertiary);
    margin-top: var(--space-sm);
}

.success-progress {
    width: 200px;
    height: 3px;
    background: var(--border-subtle);
    border-radius: var(--radius-full);
    margin-top: var(--space-xl);
    overflow: hidden;
}

.success-progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--text-tertiary);
    animation: progress-shrink 4s linear forwards;
}

@keyframes progress-shrink {
    0% { width: 100%; }
    100% { width: 0%; }
}

/* ============================================
   Hidden Canvas & Video
   ============================================ */

#camera-canvas {
    display: none;
}

#camera-stream {
    display: none;
}

/* ============================================
   Loading spinner
   ============================================ */

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.loading-overlay.visible {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--text-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Landscape orientation lock message
   ============================================ */

@media (orientation: portrait) {
    #app::after {
        content: 'Please rotate to landscape mode';
        position: fixed;
        inset: 0;
        background: var(--bg-primary);
        color: var(--text-secondary);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        z-index: 9999;
    }
}
