/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #252542;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(102, 126, 234, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* ===== Login Screen ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-container {
    text-align: center;
    padding: 40px 32px;
    width: 100%;
    max-width: 320px;
}

.login-icon {
    font-size: 64px;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pin-input {
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 20px;
    text-align: center;
    letter-spacing: 8px;
    outline: none;
    transition: var(--transition);
}

.pin-input:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.pin-input::placeholder {
    letter-spacing: normal;
    font-size: 14px;
    color: var(--text-muted);
}

.login-btn {
    padding: 16px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.login-btn:active {
    transform: scale(0.97);
}

.login-btn:disabled {
    opacity: 0.6;
}

.login-error {
    font-size: 13px;
    color: var(--danger);
    min-height: 20px;
    margin-top: 8px;
}

/* ===== App Container ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    /* Dynamic viewport height for iOS */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* ===== Header ===== */
.app-header {
    padding: 20px 24px 16px;
    text-align: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.app-icon {
    font-size: 32px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.app-header h1 {
    font-size: 24px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.last-updated {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.update-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.update-time {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Floor Selector ===== */
.floor-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 0 20px 20px;
}

.floor-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 8px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.floor-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: var(--transition);
}

.floor-btn:active {
    transform: scale(0.95);
}

.floor-btn.active {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.floor-btn.active::before {
    opacity: 0.15;
}

.floor-btn.has-car {
    border-color: var(--success);
}

.floor-btn.has-car .floor-number::after {
    content: '🚗';
    position: absolute;
    font-size: 12px;
    top: -8px;
    right: -12px;
}

.floor-number {
    position: relative;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    z-index: 1;
}

.floor-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1;
}

/* ===== Floor Display ===== */
.floor-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 20px;
    min-height: 0;
}

.layout-container {
    flex: 1;
    position: relative;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    box-shadow: var(--shadow-lg);
}

.floor-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.floor-image.loaded {
    opacity: 1;
}

.layout-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
}

.layout-placeholder-icon {
    font-size: 48px;
    opacity: 0.5;
}

/* ===== Car Marker ===== */
.car-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.car-marker.visible {
    opacity: 1;
}

.marker-pulse {
    position: absolute;
    width: 60px;
    height: 60px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--accent-gradient);
    border-radius: 50%;
    opacity: 0.3;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.3;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.1;
    }
}

.marker-icon {
    position: relative;
    font-size: 32px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0% {
        transform: scale(0) rotate(-10deg);
    }

    50% {
        transform: scale(1.2) rotate(5deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* ===== Instruction Text ===== */
.instruction-text {
    text-align: center;
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Status Bar ===== */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-bar.syncing .status-indicator {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.status-bar.offline .status-indicator {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
    animation: none;
}

.status-text {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Loading State ===== */
.loading .layout-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* ===== Touch Feedback ===== */
.layout-container:active::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 50%;
    opacity: 0.3;
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    from {
        transform: scale(0);
        opacity: 0.5;
    }

    to {
        transform: scale(3);
        opacity: 0;
    }
}