/* --- Root Variables --- */
:root {
    --bg-gradient: radial-gradient(circle at 50% 0%, #2c3e50, #000000); 
    --glass-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    --glass-border: 1px solid rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --gold-primary: #E6C25F; 
    --gold-muted: #C2A153;   
    --text-main: #F8FAFC;    
    --text-secondary: #CBD5E1; 

    /* --- Active State Colors --- */
    --active-gold-bg: linear-gradient(135deg, rgba(230, 194, 95, 0.95), rgba(255, 223, 128, 0.9));
    --active-text-dark: #0f172a; /* Deep dark blue for contrast on gold */
}

/* --- General Reset & Body --- */
* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

body { 
    margin: 0; padding: 0; 
    font-family: 'Heebo', sans-serif; 
    background: var(--bg-gradient); 
    color: var(--text-main); 
    display: flex; flex-direction: column; 
    align-items: center; 
    width: 100%;
    height: 100vh; 
    overflow: hidden; 
    transition: box-shadow 0.5s ease;
}

/* --- NEW: Active Screen Mode Glow (Inner Shadow/Glow) --- */
/* Changed from green to gold per user request */
body.screen-active-mode {
    box-shadow: inset 0 0 50px 10px rgba(230, 194, 95, 0.5), inset 0 0 20px 2px #E6C25F;
}

/* --- Layout Containers --- */
#displayContainer { 
    display: none; /* Hidden until auth */
    width: 100%; 
    height: 100%;
    flex-direction: column; 
    align-items: center; 
    padding-bottom: 50px; 
    padding-top: 5px;
}

/* --- Logo & Header --- */
.top-logo-container {
    margin-top: 5px;
    margin-bottom: 2px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.top-logo {
    width: 100px; 
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(230, 194, 95, 0.3));
}

#main-shabbat-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--gold-primary);
    font-size: 1.5em; 
    font-weight: 700;
    margin-bottom: 5px; 
    text-shadow: 0 0 20px rgba(230, 194, 95, 0.4); 
    flex-shrink: 0;
}

.shabbat-candle-svg {
    width: 20px; height: auto;
    filter: drop-shadow(0 0 10px rgba(230, 194, 95, 0.6));
}

/* --- Dashboard (Elevators) --- */
.dashboard-container { 
    display: flex; 
    flex-wrap: wrap; 
    justify-content: center; 
    align-content: flex-start;
    gap: 8px; 
    width: 100%; 
    max-width: 600px; /* Mobile Default */
    padding: 0 5px;
    overflow-y: auto; 
    flex: 1; 
    min-height: 0;
}

.elevator-panel { 
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: 16px; 
    box-shadow: var(--glass-shadow);
    padding: 8px;  
    width: 48%; 
    max-width: 180px; /* Mobile Default */
    display: flex;
    flex-direction: column; 
    align-items: center;
    justify-content: space-between;
    height: auto;
    min-height: 160px; /* Mobile Default */
    flex-grow: 1;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Active State Animation (Pulse) --- */
@keyframes pulse-gold {
    0% { 
        box-shadow: 0 0 15px rgba(230, 194, 95, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.4); 
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 30px rgba(230, 194, 95, 1), inset 0 0 25px rgba(255, 255, 255, 0.6); 
        transform: scale(1.02);
        border-color: #fff;
    }
    100% { 
        box-shadow: 0 0 15px rgba(230, 194, 95, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.4); 
        transform: scale(1);
    }
}

/* --- Active State (Approaching) --- */
.elevator-panel.approaching {
    background: var(--active-gold-bg);
    border-color: rgba(255, 255, 255, 0.8);
    z-index: 10;
    animation: pulse-gold 2s infinite ease-in-out;
}

.elevator-id { font-size: 0.9em; color: var(--text-secondary); margin-bottom: 2px; transition: color 0.3s; }

/* Color Inversion */
.elevator-panel.approaching .elevator-id { color: rgba(15, 23, 42, 0.7); font-weight: 600; }

.floor-indicator { 
    font-size: 3.5em; 
    font-weight: 800; color: var(--gold-primary);
    text-shadow: 0 0 15px rgba(230, 194, 95, 0.3); line-height: 1; margin: 5px 0;
    transition: color 0.3s;
}

/* Color Inversion */
.elevator-panel.approaching .floor-indicator { color: var(--active-text-dark); text-shadow: none; }

.direction-status { height: 40px; width: 40px; display: flex; align-items: center; justify-content: center; position: relative; }
.elevator-arrow-svg { width: 35px; height: 35px; fill: var(--gold-primary); transition: fill 0.3s; }

/* Color Inversion */
.elevator-panel.approaching .elevator-arrow-svg { fill: var(--active-text-dark); }

.arrow-up { transform: rotate(0deg); }
.arrow-down { transform: rotate(180deg); }

/* RESTORED STOP ANIMATION STYLES */
.stop-status-svg {
    width: 38px;
    height: 38px;
    overflow: visible;
}
.stop-ring {
    fill: none;
    stroke: var(--gold-primary);
    stroke-width: 6; /* Thicker for small size visibility */
    stroke-linecap: round;
    transform-origin: center;
    transform: rotate(-90deg);
    stroke-dasharray: 283; 
    stroke-dashoffset: 283;
    filter: drop-shadow(0 0 5px rgba(230, 194, 95, 0.4));
    animation: ringLoad 3s ease-in-out infinite alternate;
    transition: stroke 0.3s;
}
.stop-bars {
    fill: var(--gold-primary);
    filter: drop-shadow(0 0 4px rgba(230, 194, 95, 0.5));
    transform-origin: center;
    animation: barsPulse 2s ease-in-out infinite;
    transition: fill 0.3s;
}

/* Color Inversion */
.elevator-panel.approaching .stop-ring { stroke: var(--active-text-dark); filter: none; }
.elevator-panel.approaching .stop-bars { fill: var(--active-text-dark); filter: none; }

@keyframes ringLoad { 0% { stroke-dashoffset: 283; } 20% { stroke-dashoffset: 283; } 100% { stroke-dashoffset: 0; } }
@keyframes barsPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }


.eta-display {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%; padding-top: 5px; margin-top: 5px; text-align: center;
    transition: border-color 0.3s;
}
.elevator-panel.approaching .eta-display { border-top: 1px solid rgba(15, 23, 42, 0.2); }

.floor-label { font-size: 0.75em; color: var(--text-secondary); transition: color 0.3s; }
.elevator-panel.approaching .floor-label { color: rgba(15, 23, 42, 0.7); }

.eta-result { 
    font-size: 1.1em; 
    font-weight: 600; 
    color: var(--gold-primary); 
    min-height: 1.2em;
    transition: all 0.3s ease;
}

/* Active ETA Style */
.elevator-panel.approaching .eta-result {
    color: var(--active-text-dark);
    text-shadow: none;
    font-weight: 800;
    font-size: 1.5em; /* Scale for Mobile */
    letter-spacing: 0.5px;
}

/* --- Controls (Horizontal at bottom) --- */
.side-controls-container {
    position: fixed;
    bottom: 38px; 
    right: 0; left: 0;
    display: flex;
    flex-direction: row; 
    justify-content: center; 
    gap: 15px;
    align-items: center;
    z-index: 100;
    padding: 5px 10px;
    pointer-events: none; 
}

.side-controls-container > * { pointer-events: auto; }

.control-btn-round {
    background: rgba(20, 30, 48, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid var(--gold-muted);
    color: var(--gold-primary);
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

.screen-lock-btn {
    background: rgba(20, 30, 48, 0.8);
    backdrop-filter: blur(5px);
    color: var(--gold-primary);
    border: 1px solid var(--gold-muted);
    border-radius: 20px;
    font-size: 0.85em;
    padding: 0 15px;
    height: 42px; 
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    white-space: nowrap;
}
.screen-lock-btn.active {
    background: rgba(230, 194, 95, 0.25);
    border-color: var(--gold-primary);
    color: #fff;
}

/* --- Persistent Screen Message --- */
#persistentScreenMsg {
    position: fixed;
    bottom: 90px; /* Positioned just above controls */
    left: 0; right: 0;
    text-align: center;
    color: var(--gold-primary);
    font-size: 0.95em;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    opacity: 0;
    pointer-events: none; 
    transition: opacity 0.3s ease;
    z-index: 95;
    padding: 0 10px;
}
#persistentScreenMsg.show-persistent {
    opacity: 1;
}

/* --- Footer Status Bar --- */
.bottom-status-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #000;
    border-top: 1px solid var(--gold-muted);
    padding: 6px 0;
    text-align: center;
    z-index: 200;
    line-height: 1.2;
}
.status-text {
    font-size: 0.9em; 
    color: var(--text-secondary);
    font-weight: 400;
    display: flex; justify-content: center; align-items: center; gap: 5px;
}
.status-time { font-weight: bold; color: var(--gold-primary); font-size: 1.1em; }

/* --- Bottom Left Logo --- */
.bottom-left-logo {
    position: fixed; bottom: 45px; left: 10px;
    height: 20px; opacity: 0.5; z-index: 90;
}

/* --- LANDSCAPE OPTIMIZATION (Mobile Landscape) --- */
@media (orientation: landscape) and (max-height: 500px) {
    .top-logo-container, .bottom-left-logo { display: none !important; }
    
    #main-shabbat-indicator {
        font-size: 1.1em;
        margin-bottom: 2px;
        margin-top: 2px;
    }
    .shabbat-candle-svg { width: 14px; }
    
    #displayContainer { padding-bottom: 35px; padding-top: 0; }
    
    .dashboard-container { gap: 6px; padding-top: 0; }
    
    .elevator-panel {
        min-height: 110px;
        padding: 5px;
    }
    
    .floor-indicator { font-size: 2.2em; margin: 0; }
    .elevator-id { font-size: 0.8em; }
    .direction-status { height: 26px; width: 26px; }
    .elevator-arrow-svg { width: 24px; height: 24px; }
    .stop-status-svg { width: 24px; height: 24px; } 
    
    .eta-display { margin-top: 2px; padding-top: 2px; }
    .eta-result { font-size: 0.9em; min-height: 1em; }
    .floor-label { display: none; } 
    
    .side-controls-container { bottom: 32px; gap: 10px; }
    .control-btn-round { width: 34px; height: 34px; font-size: 0.9em; }
    .screen-lock-btn { height: 34px; font-size: 0.75em; padding: 0 10px; }
    
    #persistentScreenMsg { bottom: 80px; font-size: 0.85em; }
}

/* --- DESKTOP / LARGE TABLET OPTIMIZATION --- */
@media (min-width: 768px) {
    
    /* Lock viewport - no scroll */
    html, body {
        width: 100vw !important;
        height: 100vh !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Main container fills screen */
    #displayContainer {
        width: 100vw !important;
        height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        overflow: hidden !important;
        padding: 10px 20px 100px 20px !important; /* more bottom space */
    }

    /* Logo - small */
    .top-logo-container {
        margin: 5px 0 !important;
        flex-shrink: 0 !important;
    }
    .top-logo { 
        width: 90px !important;
        height: auto !important;
    }

    /* Header text - small */
    #main-shabbat-indicator {
        font-size: 1.6em !important;
        margin-bottom: 8px !important;
        flex-shrink: 0 !important;
    }
    .shabbat-candle-svg { 
        width: 20px !important; 
    }

    /* Dashboard - takes remaining space */
    .dashboard-container {
        flex: 1 !important;
        width: 100% !important;
        max-width: 850px !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 20px !important;
        padding: 5px !important;
        overflow: hidden !important;
        min-height: 0 !important;
    }

    /* Panels - conservative height */
    .elevator-panel {
        width: 300px !important;
        max-width: 42% !important;
        height: calc(100vh - 320px) !important; /* More space for header/footer */
        max-height: 420px !important;
        min-height: 280px !important;
        
        border-radius: 18px !important;
        padding: 12px 18px !important;
        
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-shrink: 0 !important;
    }

    /* Typography */
    .elevator-id {
        font-size: 1.2em !important;
        margin-bottom: 3px !important;
    }

    .floor-indicator {
        font-size: 5em !important;
        line-height: 1 !important;
        margin: 8px 0 !important;
    }

    .direction-status {
        height: 50px !important;
        width: 50px !important;
        margin: 8px 0 !important;
    }
    
    .elevator-arrow-svg, .stop-status-svg {
        width: 45px !important;
        height: 45px !important;
    }

    .eta-display {
        margin-top: auto !important;
        padding-top: 8px !important;
        width: 100% !important;
    }

    .floor-label {
        font-size: 0.95em !important;
    }

    .eta-result {
        font-size: 1.5em !important;
    }

    .elevator-panel.approaching .eta-result {
        font-size: 1.8em !important;
    }

    /* Controls at bottom - higher up */
    .side-controls-container {
        position: fixed !important;
        bottom: 45px !important;
        gap: 12px !important;
    }
    
    .control-btn-round { 
        width: 40px !important; 
        height: 40px !important; 
        font-size: 1em !important; 
    }
    .screen-lock-btn { 
        height: 40px !important; 
        font-size: 0.9em !important; 
        padding: 0 15px !important; 
    }
    
    .bottom-status-bar {
        height: 30px !important;
        font-size: 0.85em !important;
    }

    /* Subtle hover */
    .elevator-panel:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        border-color: rgba(230, 194, 95, 0.4);
    }
}

/* --- Auth & Modals --- */
#authContainer, .modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(15px);
    z-index: 9999; display: none;
    align-items: center; justify-content: center;
    flex-direction: column;
}
.auth-box, .modal-content {
    background: var(--glass-bg); border: var(--glass-border);
    border-radius: 28px; padding: 30px; width: 90%; max-width: 400px;
    text-align: center; position: relative;
    box-shadow: var(--glass-shadow);
}

.input-wrapper { position: relative; width: 100%; }
.auth-input {
    width: 100%; padding: 12px; margin-bottom: 15px;
    border-radius: 12px; border: 1px solid var(--gold-muted);
    background: rgba(255,255,255,0.05); color: #fff;
    box-sizing: border-box; font-family: inherit; font-size: 1em;
}
.auth-input::placeholder { color: rgba(255,255,255,0.5); }

/* --- NEW: Floor Grid & Buttons Style --- */
.floor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
    margin-bottom: 15px;
    padding: 5px;
}

/* Custom scrollbar for grid */
.floor-grid::-webkit-scrollbar { width: 6px; }
.floor-grid::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 3px; }
.floor-grid::-webkit-scrollbar-thumb { background: var(--gold-muted); border-radius: 3px; }

.floor-option-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
}

.floor-option-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--gold-muted);
}

.floor-option-btn.selected {
    background: var(--gold-primary);
    color: #0f172a; /* Dark text for contrast */
    box-shadow: 0 0 15px rgba(230, 194, 95, 0.4);
    border-color: var(--gold-primary);
    font-weight: 800;
    transform: scale(1.05);
}

.password-toggle { position: absolute; left: 10px; top: 12px; color: var(--gold-muted); cursor: pointer; z-index: 10; }

.auth-btn {
    width: 100%; padding: 12px;
    background: linear-gradient(135deg, var(--gold-muted), var(--gold-primary));
    color: #0f172a; font-weight: bold; border: none;
    border-radius: 12px; cursor: pointer; font-size: 1.1em;
    margin-bottom: 10px;
}

/* NEW: Auth Language Button */
.auth-lang-btn {
    position: absolute; top: 20px; left: 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--gold-muted);
    color: var(--gold-primary);
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.3s;
}
html[dir='ltr'] .auth-lang-btn { left: auto; right: 20px; }

.google-btn { background: #fff; color: #333; display: flex; align-items: center; justify-content: center; gap: 10px; }

.forgot-pass-link { display: block; margin-top: 10px; color: var(--text-secondary); text-decoration: underline; cursor: pointer; font-size: 0.9em; }

.primary-btn {
    width: 100%; padding: 12px; margin-top: 10px;
    background: var(--gold-primary); color: #000; font-weight: bold;
    border: none; border-radius: 8px; cursor: pointer; font-size: 1em;
}
.close-btn { position: absolute; top: 15px; left: 20px; color: var(--text-secondary); font-size: 28px; cursor: pointer; line-height: 1; }

.contact-link-action { display: block; margin-top: 10px; margin-bottom: 10px; color: var(--gold-primary); text-decoration: underline; font-weight: bold; font-size: 1.1em; }
.qr-wrapper { background: white; padding: 10px; border-radius: 10px; display: inline-block; }

.notification-popup { 
    visibility: hidden; opacity: 0; min-width: 250px; 
    background: var(--gold-primary); color: #000; 
    text-align: center; border-radius: 50px; padding: 12px 25px; 
    position: fixed; z-index: 10000; top: 20px; left: 50%; transform: translateX(-50%); 
    transition: all 0.3s; font-weight: bold; box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
.notification-popup.show { visibility: visible; opacity: 1; top: 40px; }

.loader {
    border: 4px solid rgba(255,255,255,0.1); border-top: 4px solid var(--gold-primary);
    border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin-bottom: 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes flowAnimation { 0% { opacity: 0; transform: translateY(20%); } 50% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40%); } }
.elevator-arrow-path { animation: flowAnimation 1.5s infinite linear; }

/* Mobile Optimization for Horizontal Buttons */
@media (max-width: 380px) {
    .screen-lock-btn span { display: none; } 
    .side-controls-container { gap: 8px; }
}

/* --- NEW: Install App Button & iOS Modal Styles --- */
.install-app-btn {
    background: rgba(20, 30, 48, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid var(--gold-primary);
    color: var(--gold-primary);
    border-radius: 20px;
    padding: 6px 15px;
    font-size: 0.9em;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    margin-top: 5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: all 0.2s;
    animation: fadeIn 0.5s ease-out;
}
.install-app-btn:hover {
    background: rgba(230, 194, 95, 0.15);
    transform: translateY(-2px);
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.ios-instructions {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid rgba(255,255,255,0.1);
}

.ios-step {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: #fff;
    margin-bottom: 12px;
    font-size: 1.05em;
    text-align: right;
}
.ios-step:last-child { margin-bottom: 0; }
.step-num { font-weight: bold; color: var(--gold-primary); margin-left: 8px; }

html[dir='ltr'] .ios-step { text-align: left; }
html[dir='ltr'] .step-num { margin-left: 0; margin-right: 8px; }