* { margin: 0; padding: 0; box-sizing: border-box; }
[x-cloak] { display: none !important; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
#map { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 1; }

/* Top bar */
.top-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; padding: 8px 10px; }
/* Bez natpisa lijevo, kontrole idu desno */
.top-row1 { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 8px; }
.top-controls { display: flex; align-items: center; gap: 6px; }
.lang-switch { display: flex; background: rgba(0,51,102,0.92); border-radius: 16px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.25); }
.lang-btn { border: none; background: transparent; color: rgba(255,255,255,0.6); padding: 5px 9px; font-size: 0.72em; cursor: pointer; font-weight: 600; }
.lang-btn.active { background: white; color: #003366; }
.gps-btn { display: flex; align-items: center; gap: 5px; background: rgba(0,51,102,0.92); border: none; color: white; padding: 6px 12px; border-radius: 20px; font-size: 0.8em; font-weight: 600; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.25); white-space: nowrap; }
.top-row2 { display: flex; gap: 8px; }
.tab {
    flex: 1; min-height: 46px; border: none; border-radius: 12px;
    background: rgba(0,51,102,0.92); color: white; font-size: 0.95em; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.tab.active { background: #003366; box-shadow: 0 2px 12px rgba(0,0,0,0.4); }

/* Panels */
.panel {
    position: fixed; top: 108px; left: 10px; right: 10px; z-index: 999;
    background: white; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    max-height: 70vh; overflow-y: auto; padding: 16px;
}
.panel-title { font-weight: bold; color: #003366; margin-bottom: 10px; }
.panel-close { position: absolute; top: 10px; right: 12px; background: none; border: none; font-size: 1.3em; cursor: pointer; color: #888; }

/* Search input + clear button */
.search-wrap { position: relative; }
.search-input { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 10px; font-size: 0.95em; margin-bottom: 12px; outline: none; }
.search-input:focus { border-color: #003366; }
.search-clear {
    position: absolute; top: 9px; right: 10px; width: 24px; height: 24px;
    border: none; background: #eee; color: #666; border-radius: 50%;
    font-size: 0.75em; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.search-clear:active { background: #ddd; }

.result-card { border: 1px solid #eee; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.result-card:active { background: #f5f8fc; }
.result-name { font-weight: bold; color: #003366; font-size: 0.95em; }
.result-meta { font-size: 0.75em; color: #888; margin-top: 2px; }
.result-badge { font-size: 0.7em; padding: 2px 8px; border-radius: 10px; color: white; }
.b-active { background: #00aa55; } .b-stale { background: #999; }
.berth-row { display: flex; justify-content: space-between; align-items: center; }

/* Donja traka — pojavljuje se samo kad ima sto reci (pracenje ili ustajali podaci) */
#status-bar {
    position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
    display: none; align-items: center; gap: 8px; max-width: calc(100vw - 24px);
    background: rgba(0,0,30,0.82); color: white; padding: 7px 8px 7px 14px;
    border-radius: 20px; font-size: 0.82em; z-index: 500;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.bar-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-warn { color: #ffcc00; }
.bar-x {
    flex-shrink: 0; width: 22px; height: 22px; border: none; border-radius: 50%;
    background: rgba(255,255,255,0.18); color: white; cursor: pointer;
    font-size: 0.85em; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.bar-x:active { background: rgba(255,255,255,0.3); }
@keyframes barAlert { 0%,100% { background: rgba(0,0,30,0.82); } 50% { background: #00aa55; } }
.bar-alert { animation: barAlert 0.6s ease-in-out 4; }

/* Dugmad u popupu */
.popup-btns { display: flex; gap: 6px; margin-top: 8px; }
.popup-btn {
    flex: 1; padding: 7px 6px; background: #003366; color: white; border: none;
    border-radius: 6px; cursor: pointer; font-size: 0.82em; white-space: nowrap;
}
.popup-btn:active { background: #00284f; }
.popup-btn-on { background: #00aa55; }

/* Animations */
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(33,150,243,0.6); } 100% { box-shadow: 0 0 0 12px rgba(33,150,243,0); } }
@keyframes vesselPulse { 0% { transform: scale(1); } 50% { transform: scale(1.5); } 100% { transform: scale(1); } }
.vessel-pulse { animation: vesselPulse 1.2s ease-in-out infinite; transform-origin: center; }
@keyframes berthPulse { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.4); opacity: 0.6; } 100% { transform: scale(1); opacity: 1; } }
.berth-pulse { animation: berthPulse 1.3s ease-in-out infinite; transform-origin: center bottom; }

/* Popup */
.leaflet-popup-content { font-family: -apple-system, sans-serif; font-size: 13px; line-height: 1.5; min-width: 220px; }
.popup-name { font-weight: bold; font-size: 1.1em; color: #003366; }
.popup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; }

/* Najava veza — vez iz sluzbenog reda plovidbe, ne iz AIS-a */
.berth-badge {
    flex-shrink: 0; background: #003366; color: #fff;
    border-radius: 9px; padding: 5px 10px; text-align: center;
    font-size: 0.82em; font-weight: bold; line-height: 1.15;
    white-space: nowrap; box-shadow: 0 2px 6px rgba(0,51,102,0.35);
}
.berth-badge small { display: block; font-size: 0.85em; font-weight: 600; opacity: 0.8; margin-top: 1px; }
.popup-eta { background: #f0f7ff; border-radius: 6px; padding: 6px 10px; margin-top: 6px; }
.popup-eta-val { font-size: 1.3em; font-weight: bold; color: #003366; }
/* Skocni prozor uz sidro veza */
.berth-pop { min-width: 190px; text-align: center; }
.berth-pop-name { font-weight: bold; color: #003366; font-size: 1.05em; }
.berth-pop-coord { font-size: 0.72em; color: #999; margin: 2px 0 8px; font-family: monospace; }
.berth-pop .popup-btn { display: block; text-decoration: none; text-align: center; }
