/* static/css/style.css - DESKTOP FIXED SIDEBAR + DEPTH HUD */

:root {
  --primary: #007AFF; 
  --surface: #ffffff; 
  --bg: #f5f7fa; 
  --text: #1c1c1e; 
  --text-sub: #6c6c70;
  --success: #34c759; 
  --danger: #ff3b30; 
  --warn-red: #d32f2f;
  /* Levennetty sivupalkki 360px -> 400px, jotta napit ja kentät mahtuvat hyvin */
  --sidebar-width: 400px;
  --header-height: 60px;
  --shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* --- YLEISET --- */
body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

a { text-decoration: none; color: var(--primary); }
a:hover { text-decoration: underline; }

/* --- YLÄPALKKI --- */
#top-bar { 
    height: var(--header-height); 
    background: #002b4d; 
    color: white; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 20px; 
    flex-shrink: 0;
    z-index: 3000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
#top-bar h1 { margin: 0; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.top-act a { color: white; margin-left: 20px; font-size: 18px; transition: opacity 0.2s; }
.top-act a:hover { opacity: 0.8; }

/* --- PÄÄLAYOUT (FLEX) --- */
#main-layout {
    display: flex;
    flex: 1;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* --- SIVUPALKKI (VASEN) --- */
#sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid #e5e5ea;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

/* --- KARTTA (OIKEA) --- */
#map-container {
    flex: 1;
    position: relative;
    background: #e2e6ea;
}
#map { width: 100%; height: 100%; z-index: 1; }

/* --- HUD (Sivupalkin yläosa) --- */
#hud-section {
    padding: 24px;
    background: linear-gradient(to bottom, #ffffff, #f9f9fb);
    border-bottom: 1px solid #e5e5ea;
}

.hud-head { display: flex; justify-content: space-between; align-items: baseline; }
.sp-big { font-size: 56px; font-weight: 800; letter-spacing: -2px; color: var(--text); line-height: 1; }
.sp-unit { font-size: 20px; font-weight: 600; color: var(--text-sub); margin-left: 4px; }
.sp-sub { font-size: 16px; font-weight: 500; color: var(--text-sub); margin-top: 4px; }

/* Navigointitiedot (Syvyys, Matka, ETA) */
#nav-stats { 
    display: grid; 
    /* KORJAUS: 4 saraketta, jotta välietappi mahtuu */
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 8px; 
    margin-top: 20px; 
    padding-top: 15px; 
    border-top: 1px solid #eee; 
}
.st-box h4 { margin: 0 0 4px 0; font-size: 10px; text-transform: uppercase; color: var(--text-sub); letter-spacing: 0.5px; font-weight: 700; white-space: nowrap; }
.st-val { font-size: 18px; font-weight: 700; color: var(--text); display: block; line-height: 1.1; }
.st-sub { font-size: 11px; color: var(--text-sub); font-weight: 500; }

/* Varoitukset HUDissa */
#warns { display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; min-height: 5px; }

/* Merimerkit */
.sign-base, .sgn-speed, .bridge-sign, .sign-img-container {
    width: 48px; height: 48px; 
    background: white; border: 3px solid var(--danger);
    display: flex; align-items: center; justify-content: center;
    position: relative; font-weight: 800; color: black;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 4px;
}
.sign-img-container { border: 1px solid #ccc; }
.sign-img-container img { max-width: 90%; max-height: 90%; }
.sgn-speed { border-radius: 0; font-size: 20px; border-width: 4px; }
.bridge-sign { border-radius: 0; flex-direction: column; }
.bridge-triangle {
    width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 10px solid black;
    position: absolute; top: 4px;
}
.bridge-val { margin-top: 8px; font-size: 14px; }

/* --- NAVIGOINTI / REITTIHAKU (HUDin alla) --- */
#route-section {
    padding: 24px;
    flex: 1; 
}

.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.section-head h3 { margin: 0; font-size: 18px; font-weight: 700; color: #1c1c1e; }

/* Inputit */
.input-row { display: flex; gap: 8px; margin-bottom: 12px; }
.input-wrapper { 
    position: relative; flex-grow: 1; display: flex; align-items: center; 
    background: #f2f2f7; border: 1px solid #e5e5ea; border-radius: 10px; 
}
.input-icon { padding: 0 10px; font-size: 14px; color: #888; }
.map-input { border: none; background: transparent; width: 100%; padding: 12px 5px; font-size: 15px; outline: none; }
.clr-btn { background: none; border: none; color: #aaa; cursor: pointer; padding: 0 10px; visibility: hidden; }
.map-input:not(:placeholder-shown) + .clr-btn { visibility: visible; }

.square-btn {
  width: 46px; height: 46px; 
  flex-shrink: 0; background: white; border: 1px solid #d1d1d6; border-radius: 10px;
  cursor: pointer; color: #555; display: flex; align-items: center; justify-content: center; font-size: 18px;
  transition: 0.1s;
}
.square-btn:hover { background: #f0f0f5; }
.square-btn:active { background: #e5e5ea; transform: scale(0.96); }

/* Napit */
.btn { 
    width: 100%; padding: 12px; border: none; border-radius: 10px; 
    font-weight: 600; font-size: 16px; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; gap: 8px; 
    margin-top: 10px; transition: 0.2s; 
}
/* Estetty tila napeille */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.b-blue { background: var(--primary); color: white; }
.b-blue:not(:disabled):hover { background: #0063d1; }
.b-green { background: var(--success); color: white; display: none; }
.b-green:not(:disabled):hover { background: #2db350; }
.b-gray { background: #eef0f2; color: #333; }
.b-red { background: #fff0f0; color: var(--danger); }

/* Tallennetut reitit */
.s-list { margin-top: 30px; }
.s-head { font-size: 12px; font-weight: 700; color: #999; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.s-item { 
    padding: 12px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; 
    cursor: pointer; transition: 0.1s; border-radius: 8px;
}
.s-item:hover { background: #f5f7fa; }
.tr-btn { color: #ccc; transition: 0.2s; }
.tr-btn:hover { color: var(--danger); }

/* --- GPS MARKER --- */
.leaflet-div-icon.gps-marker-custom { background: transparent; border: none; }

/* --- MODAL --- */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 5000; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); align-items: center; justify-content: center; }
.modal-box { background: white; padding: 30px; border-radius: 16px; width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.modal-box input { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 8px; box-sizing: border-box; }
.pmode { cursor: crosshair !important; }
.input-error { border-color: var(--danger); background: #fff5f5; }


/* =========================================
   YHTENÄISET SIVUT (Login, Admin, Salasana) 
   ========================================= */

.app-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg);
    padding: 20px;
    box-sizing: border-box;
}

.app-container {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

.app-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 32px;
    border: 1px solid #e5e5ea;
    margin-bottom: 24px;
}

.app-card-title {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid #d1d1d6;
    border-radius: 10px;
    font-size: 15px;
    background: #f2f2f7;
    outline: none;
    box-sizing: border-box;
    transition: 0.2s;
    font-family: inherit;
}

.app-input:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.app-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.app-btn:hover { background: #0062cc; color: white; text-decoration: none; }
.app-btn.danger { background: #fff0f0; color: var(--danger); border: 1px solid #ffcdd2; }
.app-btn.danger:hover { background: var(--danger); color: white; }
.app-btn.secondary { background: #f2f2f7; color: var(--text); border: 1px solid #e5e5ea;}
.app-btn.secondary:hover { background: #e5e5ea; }
.app-btn-sm { padding: 8px 12px; font-size: 14px; width: auto; border-radius: 8px; }

/* Admin-taulut ja Grid */
.grid-layout { display: grid; grid-template-columns: 1fr 2.5fr; gap: 24px; }
@media (max-width: 900px) { .grid-layout { grid-template-columns: 1fr; } }

.admin-table { width: 100%; border-collapse: collapse; text-align: left; }
.admin-table th { background: #f2f2f7; padding: 12px 16px; font-size: 12px; text-transform: uppercase; color: var(--text-sub); border-bottom: 1px solid #e5e5ea; letter-spacing: 0.5px;}
.admin-table td { padding: 16px; border-bottom: 1px solid #f2f2f7; vertical-align: middle; }

/* Kartan Yläpalkin uudet napit */
.top-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
    font-size: 14px;
    text-decoration: none;
}
.top-btn:hover { background: rgba(255,255,255,0.25); color: white; text-decoration: none; }
.top-btn.logout { background: rgba(255, 59, 48, 0.15); border-color: rgba(255, 59, 48, 0.3); color: #ff6b6b; }
.top-btn.logout:hover { background: rgba(255, 59, 48, 0.4); color: #ff8585; }