/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette - Medical Professional Theme */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2234;
    --bg-card-hover: #222d44;
    
    --accent-teal: #14b8a6;
    --accent-teal-glow: rgba(20, 184, 166, 0.4);
    
    --status-ok: #10b981;
    --status-ok-soft: rgba(16, 185, 129, 0.15);
    --status-ok-glow: rgba(16, 185, 129, 0.5);
    
    --status-alert: #ef4444;
    --status-alert-soft: rgba(239, 68, 68, 0.15);
    --status-alert-glow: rgba(239, 68, 68, 0.6);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(20, 184, 166, 0.3);
    
    /* Typography */
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Sizing for 7" tablet (typically 1024x600 or 1280x800) */
    --header-height: 52px;
    --footer-height: 48px;
    --grid-gap: 10px;
    --card-radius: 14px;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
}

/* Background Pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(20, 184, 166, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    pointer-events: none;
    z-index: -1;
}

/* Container */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    padding: 8px 12px;
    gap: 8px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 8px;
    background: var(--bg-card);
    border-radius: var(--card-radius);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.header-right {
    justify-content: flex-end;
}

.header-center {
    flex: 2;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--accent-teal);
    filter: drop-shadow(0 0 8px var(--accent-teal-glow));
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-teal) 0%, #22d3ee 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--status-ok-soft);
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--status-ok);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--status-ok-glow);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

.status-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--status-ok);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.clock {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 70px;
    text-align: right;
}

/* Bed Grid */
.bed-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: var(--grid-gap);
    min-height: 0;
}

/* Bed Card */
.bed-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--card-radius);
    border: 2px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}

.bed-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 50%);
    pointer-events: none;
}

.bed-card:hover {
    background: var(--bg-card-hover);
    transform: scale(1.02);
}

.bed-card:active {
    transform: scale(0.98);
}

/* OK State */
.bed-card.status-ok {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 
        0 0 0 1px rgba(16, 185, 129, 0.1),
        inset 0 1px 0 rgba(16, 185, 129, 0.1);
}

.bed-card.status-ok .bed-icon {
    color: var(--status-ok);
    filter: drop-shadow(0 0 6px var(--status-ok-glow));
}

.bed-card.status-ok .bed-status-dot {
    background: var(--status-ok);
    box-shadow: 0 0 6px var(--status-ok-glow);
}

/* Alert State */
.bed-card.status-alert {
    border-color: var(--status-alert);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.12) 0%, var(--bg-card) 100%);
    animation: alert-pulse 0.8s ease-in-out infinite;
    box-shadow: 
        0 0 20px var(--status-alert-glow),
        0 0 40px rgba(239, 68, 68, 0.3),
        inset 0 0 20px rgba(239, 68, 68, 0.1);
}

.bed-card.status-alert .bed-icon {
    color: var(--status-alert);
    filter: drop-shadow(0 0 10px var(--status-alert-glow));
    animation: icon-shake 0.5s ease-in-out infinite;
}

.bed-card.status-alert .bed-number {
    color: var(--status-alert);
    animation: text-blink 0.8s ease-in-out infinite;
}

.bed-card.status-alert .bed-status-dot {
    background: var(--status-alert);
    box-shadow: 0 0 8px var(--status-alert-glow);
    animation: dot-blink 0.4s ease-in-out infinite;
}

@keyframes alert-pulse {
    0%, 100% { 
        box-shadow: 
            0 0 20px var(--status-alert-glow),
            0 0 40px rgba(239, 68, 68, 0.3),
            inset 0 0 20px rgba(239, 68, 68, 0.1);
    }
    50% { 
        box-shadow: 
            0 0 30px var(--status-alert-glow),
            0 0 60px rgba(239, 68, 68, 0.4),
            inset 0 0 30px rgba(239, 68, 68, 0.15);
        border-color: #ff6b6b;
    }
}

@keyframes icon-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

@keyframes text-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes dot-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* Bed Icon */
.bed-icon {
    width: 42%;
    height: auto;
    max-height: 45%;
    transition: all 0.3s ease;
}

/* Bed Number */
.bed-number {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 4px;
    letter-spacing: -0.02em;
    line-height: 1;
}

/* Status Dot */
.bed-status-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

/* Bed Label */
.bed-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* Footer */
.footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    height: var(--footer-height);
    padding: 0 16px;
    background: var(--bg-card);
    border-radius: var(--card-radius);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 32px;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-ok {
    color: var(--status-ok);
}

.stat-alert {
    color: var(--status-alert);
}

.alert-stat .stat-value {
    padding: 2px 10px;
    background: var(--status-alert-soft);
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Acknowledge Animation */
.bed-card.acknowledging {
    animation: acknowledge 0.4s ease;
}

@keyframes acknowledge {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); background: rgba(16, 185, 129, 0.2); }
    100% { transform: scale(1); }
}

/* Responsive adjustments for different 7" tablet resolutions */
@media (max-height: 600px) {
    .container {
        padding: 6px 10px;
        gap: 6px;
    }
    
    .header {
        height: 44px;
    }
    
    .footer {
        height: 40px;
    }
    
    .bed-grid {
        gap: 8px;
    }
    
    .bed-number {
        font-size: clamp(1rem, 3.5vw, 1.4rem);
    }
    
    .bed-icon {
        width: 38%;
    }
    
    .logo-text, .title {
        font-size: 1rem;
    }
    
    .clock {
        font-size: 1.1rem;
    }
}

@media (max-width: 800px) {
    .status-text {
        display: none;
    }
    
    .header-left, .header-right {
        gap: 8px;
    }
    
    .footer {
        gap: 24px;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
}

/* Landscape orientation optimization */
@media (orientation: landscape) and (max-height: 500px) {
    .bed-grid {
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }
    
    .bed-icon {
        width: 35%;
    }
    
    .bed-number {
        font-size: 1rem;
    }
    
    .bed-label {
        display: none;
    }
}

/* Hide scrollbars */
::-webkit-scrollbar {
    display: none;
}

* {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

