/**
 * ============================================================================
 * USER PWA STYLE - WATER GLASS THEME
 * /taxi/app/assets/css/style.css
 * ============================================================================
 */

:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* =========================================
   1. VÝCHOZÍ / SVĚTLÝ REŽIM (DEN)
   ========================================= */
:root, html[data-theme="light"] {
    color-scheme: light;
    --bg: #ffffff;
    --text: #000000;
    --card: #ffffff;
    --brand: #2ecc71; 
    --brand-text: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.35);     
    --glass-border: rgba(0, 0, 0, 0.15);       
    --glass-btn-bg: rgba(0, 0, 0, 0.03);
    --glass-btn-active: rgba(0, 0, 0, 0.1);
    
    /* 🟢 Formuláře: Ve dne bílé pozadí, černý text, černý okraj */
    --form-bg: #ffffff;
    --form-text: #000000;
    --form-border: #000000;
}

/* =========================================
   2. TMAVÝ REŽIM (RUČNÍ VYNUCENÍ - NOC)
   ========================================= */
html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #000000;
    --text: #ffffff;
    --card: #141418;
    --brand: #ffcc00; 
    --brand-text: #000000;
    --glass-bg: rgba(15, 15, 18, 0.35);      
    --glass-border: rgba(255, 255, 255, 0.15); 
    --glass-btn-bg: rgba(255, 255, 255, 0.05); 
    --glass-btn-active: rgba(255, 255, 255, 0.15);
    
    /* 🟢 Formuláře: V noci černé pozadí, Taxi žlutý text, bílý okraj */
    --form-bg: #000000;
    --form-text: var(--brand);
    --form-border: #ffffff;
}

html[data-theme="dark"] .leaflet-tile-container {
    filter: brightness(85%) contrast(105%);
}

/* =========================================
   3. TMAVÝ REŽIM (AUTO - PODLE SYSTÉMU TELEFONU)
   ========================================= */
@media (prefers-color-scheme: dark) {
    /* Sepne pouze v případě, že uživatel nemá vynucený světlý režim */
    html:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #000000;
        --text: #ffffff;
        --card: #141418;
        --brand: #ffcc00; 
        --brand-text: #000000;
        --glass-bg: rgba(15, 15, 18, 0.35);      
        --glass-border: rgba(255, 255, 255, 0.15); 
        --glass-btn-bg: rgba(255, 255, 255, 0.05); 
        --glass-btn-active: rgba(255, 255, 255, 0.15);
        
        /* 🟢 Formuláře: V noci černé pozadí, Taxi žlutý text, bílý okraj */
        --form-bg: #000000;
        --form-text: var(--brand);
        --form-border: #ffffff;
    }

    html:not([data-theme="light"]) .leaflet-tile-container {
        filter: brightness(85%) contrast(105%);
    }
}

/* =========================================
   TĚLO A ZÁKLADNÍ STRUKTURA
   ========================================= */

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

html, body { 
    margin: 0; padding: 0; 
    /* 🟢 OPRAVA FRAGMENTACE ANDROIDU: Pevné uzamčení do rámu fyzického okna */
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%; 
    overflow: hidden; 
    font-family: system-ui, -apple-system, sans-serif; 
    background: var(--bg); color: var(--text);
}

#map-container { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 1; }
#map-container .leaflet-container { height: 100%; width: 100%; }

#smart-glass-sheet {
    position: fixed; bottom: 0; left: 0; right: 0; 
    /* 🟢 OPRAVA S25 FE: Zvětšení o mrtvou zónu (gesta/tlačítka) */
    height: calc(90% + var(--safe-bottom));
    background: var(--glass-bg); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    border-top: 1px solid var(--glass-border); border-radius: 28px 28px 0 0;
    z-index: 1000; display: flex; flex-direction: column;
    will-change: transform; 
    /* 🟢 OPRAVA S25 FE: Odsazení o 80px + bezpečná zóna pro panel gest, aby nápis zůstal 100% vidět */
    transform: translateY(calc(100% - 80px - var(--safe-bottom))); 
    box-shadow: 0 -5px 25px rgba(0,0,0,0.15);
    transition: background 0.3s, border-color 0.3s;
}

.glass-handle-area {
    height: 80px; flex-shrink: 0; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; position: relative; cursor: grab; touch-action: none;
}

.glass-handle { 
    width: 40px; height: 5px; border-radius: 3px; background: var(--text); opacity: 0.2; position: absolute; top: 12px; 
}

#smart-bar-content { 
    margin-top: 10px; font-weight: 800; font-size: 16px; 
    color: var(--brand);
    pointer-events: none; transition: color 0.3s; 
}

.glass-body { flex: 1; position: relative; overflow: hidden; width: 100%; }

.glass-view {
    position: absolute; 
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%; box-sizing: border-box;
    padding: 0 20px calc(20px + var(--safe-bottom)) 20px;
    overflow-y: auto; touch-action: pan-y; display: none; animation: fadeIn 0.2s ease;
}
.glass-view.active { display: block; }

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

.glass-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 10px; width: 100%; }

.glass-btn {
    background: var(--glass-btn-bg); border: 1px solid var(--glass-border); border-radius: 18px; 
    padding: 18px 12px; text-align: center; color: var(--text); cursor: pointer; position: relative; 
    display: flex; flex-direction: column; gap: 8px; transition: background 0.2s, border-color 0.3s;
    -webkit-user-select: none; user-select: none;
}
.glass-btn:active { background: var(--glass-btn-active); }
.glass-btn .icon { font-size: 28px; line-height: 1; position: relative; display: inline-block; margin: 0 auto; }
.glass-btn .label { font-size: 13px; font-weight: 800; opacity: 0.9; }

.red-dot {
    position: absolute; top: -2px; right: -6px; width: 12px; height: 12px;
    background: #e74c3c; border-radius: 50%; box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
    animation: pulse 2s infinite; border: 2px solid var(--card);
}
@keyframes pulse { 0% { transform: scale(0.95); opacity: 0.8;} 50% { transform: scale(1.1); opacity: 1;} 100% { transform: scale(0.95); opacity: 0.8;} }

.install-banner {
    position: fixed; top: calc(20px + var(--safe-top)); left: 50%; transform: translateX(-50%); 
    z-index: 9999; background: var(--card); border: 1px solid var(--brand); border-radius: 16px; 
    padding: 12px 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); width: 90%; max-width: 400px; 
    align-items: center; justify-content: space-between;
}
.banner-left { display: flex; align-items: center; gap: 12px; }
.banner-left img { width: 40px; height: 40px; border-radius: 8px; }
.banner-text { color: var(--text); line-height: 1.2; display: flex; flex-direction: column; }
.banner-text strong { font-size: 14px; }
.banner-text span { font-size: 12px; opacity: 0.8; }
.btn-banner-install { background: var(--brand); color: var(--brand-text); border: none; padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: 13px; cursor: pointer; }
.btn-banner-close { position: absolute; top: -8px; right: -8px; background: var(--card); color: var(--text); width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; border: 1px solid var(--glass-border); }

.glass-global-close {
    position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--glass-btn-bg); border: 1px solid var(--glass-border);
    color: var(--brand); 
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 900; cursor: pointer; z-index: 10;
    transition: background 0.2s, transform 0.1s, color 0.3s; 
    -webkit-tap-highlight-color: transparent;
}
.glass-global-close:active { background: var(--glass-btn-active); transform: translateY(-50%) scale(0.95); }


/* =========================================
   NAŠEptávač (SUGGEST.JS) OVERRIDES
   ========================================= */

.suggest { 
    position: absolute !important; 
    top: calc(100% + 6px) !important; 
    bottom: auto !important; 
    left: 0 !important; 
    right: 0 !important; 
    width: 100% !important; 
    background: var(--glass-bg) !important; 
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid var(--glass-border) !important; 
    border-radius: 16px !important; 
    box-shadow: 0 16px 40px rgba(0,0,0,0.15) !important; 
    /* 🟢 OPRAVA PRO STARÉ ANDROIDY */
    max-height: 40vh !important;
    max-height: 40dvh !important; 
    overflow-y: auto !important; 
    z-index: 999999 !important; 
    padding: 0 !important; 
    margin: 0 !important; 
}

.suggest .item { 
    padding: 16px !important; 
    cursor: pointer !important; 
    border-bottom: 1px solid var(--glass-border) !important; 
    color: var(--text) !important; 
    font-size: 16px !important; 
    font-weight: 700 !important; 
    background: transparent !important; 
    transition: background 0.2s, color 0.2s !important;
}

.suggest .item:last-child { 
    border-bottom: none !important; 
}

.suggest .item:active,
.suggest .item:hover { 
    background: var(--glass-btn-active) !important;
    color: var(--brand) !important; 
}

/* =========================================
   MAPA - ABSOLUTNÍ DIKTÁT TRASY (WATER Glass)
   ========================================= */

#map-container svg path.leaflet-interactive {
    stroke: #ffcc00 !important;         
    stroke-width: 4px !important;        
    stroke-dasharray: none !important;   
    stroke-opacity: 1 !important;        
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.8)) drop-shadow(-1px -1px 1px rgba(0,0,0,0.8)) !important;
}

/* =========================================
   SKRÝVÁNÍ PRVKŮ UVNITŘ PWA IFRAME
   ========================================= */
html.in-iframe .top-nav,
html.in-iframe .pill--brand[href="/"] {
    display: none !important;
}

html.in-iframe,
html.in-iframe body {
    background: transparent !important;
}

/* =========================================
   🟢 VYNUCENÝ KONTRASTNÍ VZHLED FORMULÁŘŮ
   ========================================= */
input, select, textarea {
    background: var(--form-bg) !important;
    color: var(--form-text) !important;
    border: 1px solid var(--form-border) !important;
}

input::placeholder, textarea::placeholder {
    color: var(--form-text) !important;
    opacity: 0.5;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--brand) !important;
    outline: none;
}