/* =========================================================================
   1. RESET I USTAWIENIA GLOBALNE
   ========================================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: #111;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    font-family: sans-serif; /* Dodane dla konsystencji */
    min-height: 100vh; /* Zapewnij, że strona ma wystarczającą wysokość */
}

/* =========================================================================
   2. OPIS APLIKACJI (Górna część strony - poza telefonem)
   ========================================================================= */
#topDesc {
    width: 100%;
    max-width: 400px; /* Ograniczenie szerokości */
    padding-bottom: 20px;
    text-align: left; /* Zgodnie z index.html */
    color: #eee;
    font-family: sans-serif;
}

#topDesc h1 { font-size: 18px; color: #FFA500; margin-bottom: 8px; }
#topDesc .short { font-size: 14px; color: #ccc; margin-bottom: 12px; }
#topDesc details summary { color: #90EE90; cursor: pointer; font-size: 14px; font-weight: bold; }
#topDesc details div.full-content {
    color: #bbb;
    line-height: 1.6;
    margin-top: 10px;
    /* Upewniamy się, że nie ma obcinania */
    max-height: none;
    overflow: visible;
}
#topDesc details p { font-size: 13px; color: #bbb; margin-top: 8px; line-height: 1.4; }
#topDesc details ul { list-style: none; padding-left: 0; margin-top: 8px; }
#topDesc details li { margin-bottom: 15px; padding-left: 20px; position: relative; color: #bbb; }


/* =========================================================================
   3. KONSTRUKCJA OBUDOWY TELEFONU (Wrapper)
   ========================================================================= */
#phoneWrapper {
    width: 380px;
    height: 760px;
    min-width: 380px;
    min-height: 760px;
    background: #000;
    border: 8px solid #333;
    border-radius: 40px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Z powrotem na hidden dla zaokrąglonych rogów */
    position: relative;
    transform: scale(1.26); /* Zachowujemy skalowanie z index.html */
    transform-origin: top center;
    margin-top: 60px; /* Dopasowanie marginesu */
    margin-left: auto;
    margin-right: auto;
}

/* =========================================================================
   4. EKRAN WEWNĘTRZNY (Zawartość aplikacji)
   ========================================================================= */
#phone {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
    overflow: hidden;
    padding: 0; /* Usunięte padding, zawartość ma własny padding */
    position: relative; /* Potrzebne dla absolutnie pozycjonowanych elementów */
}

/* Belka tytułowa (TopBar) - przywrócona */
#topBar {
    height: 55px;
    background: #0F1420; /* ciemny szafir */
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid #1A2030;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}
#topBar #menuBtn {
    background:none; border:none; cursor:pointer; display:flex; align-items:center;
}
#topBar #menuBtn svg {
    width:22px; height:22px; stroke:#E0E0E0; stroke-width:2; fill:none;
}
#topBar #pageTitle {
    color: #E0E0E0; font-size: 18px; font-weight: bold; margin-left: 10px;
}
#topBar #topMenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    width: 200px;
    background: #1A1F29;
    border: 1px solid #2a3040;
    border-radius: 6px;
    z-index: 999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
#topBar #topMenu a {
    display:block; padding:10px 15px; color:#ccc; text-decoration:none;
}
#topBar #topMenu a:first-child { color:#FFA500; font-weight:bold; }


/* Pasek powiadomień na górze aplikacji (nowy element z XAML) */
#notificationBar {
    background-color: transparent; /* Domyślny, zmieni się dynamicznie */
    padding: 12px 16px 14px 16px;
    max-height: 120px;
    color: #fff; /* Domyślny kolor tekstu */
    font-size: 14px;
    text-align: center;
    line-height: 1.4;
    word-wrap: break-word;
    overflow: hidden;
    display: none; /* Domyślnie ukryty, pokazywany przez JS */
    cursor: pointer;
    flex-shrink: 0; /* Nie kurczy się */
}

/* Scrollable content (VerticalStackLayout z XAML) */
.scrollable-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 0; /* Padding nałożony na VSL */
}

.main-vertical-stack {
    padding: 0 30px; /* Padding z XAML */
    display: flex;
    flex-direction: column;
    gap: 15px; /* Spacing z XAML */
    align-items: center; /* HorizontalOptions="Center" */
    margin-bottom: 20px; /* Trochę przestrzeni przed sysNav, jeśli scrollview jest mały */
}

/* STATUS LABEL */
#statusLabel {
    background: #222;
    color: yellow;
    padding: 10px; /* Padding z XAML */
    text-align: center;
    border-radius: 8px; /* Standardowy dla label-status */
    font-size: 14px; /* Poprawiono: z Micro na Small (14px) */
    min-height: 50px; /* MinimumHeightRequest z XAML */
    display: flex; /* Do centrowania tekstu pionowo */
    align-items: center;
    justify-content: center;
    line-height: 1.4; /* LineHeight z XAML */
    word-wrap: break-word;
    flex-shrink: 0;
    width: 100%; /* Rozciągnij na całą szerokość dostępną dla VSL */
}

/* Checkboxy z emoji (Sound/Vehicle) */
.checkbox-row-emoji {
    display: flex;
    gap: 25px; /* Spacing z XAML */
    align-items: center;
    margin-top: 1px; /* Margin z XAML */
    flex-shrink: 0;
    width: auto; /* Domyślna szerokość by elementy były obok siebie */
    justify-content: center; /* Wyśrodkowanie */
}

/* Checkboxy z tekstem (Only POI/Offline) */
.checkbox-row-text {
    display: flex;
    gap: 13px; /* Spacing z XAML */
    align-items: center;
    flex-shrink: 0;
    width: auto; /* Domyślna szerokość by elementy były obok siebie */
    justify-content: center; /* Wyśrodkowanie */
}

/* Globalne style dla checkboxów */
input[type="checkbox"] {
    appearance: none; /* Ukryj domyślny wygląd */
    width: 20px;
    height: 20px;
    border: 2px solid #696969; /* Domyślna ramka */
    border-radius: 4px;
    background-color: #333; /* Domyślne tło */
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

input[type="checkbox"]:checked {
    background-color: #FFD700; /* Kolor z XAML Color="#FFD700" */
    border-color: #FFD700;
}

input[type="checkbox"]:checked::before {
    content: '✓'; /* Znaczek checkmark */
    color: #000;
    font-size: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.checkbox-row-emoji label,
.checkbox-row-text label {
    color: #ccc;
    font-size: 11px; /* FontSize="Micro" */
    cursor: pointer;
}

/* PRZYCISKI APLIKACJI (ogólne z styles.css) */
.btn {
    height: 44px;
    border: none;
    border-radius: 5px; /* CornerRadius="5" z XAML */
    font-size: 15px; /* FontSize="Micro" */
    /*font-weight: bold; /* Consistency z XAML */
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out; /* Płynniejsze przejście */
    flex-shrink: 0;
    width: 100%; /* Domyślna szerokość, nadpisywana przez widthRequest */
}

/* Mapowanie kolorów z XAML na klasy CSS */
.btn-primary { background: #006400; } /* SetInterval, ImpEx, Reset, Manual */
.btn-primary:active { background: #90EE90; }
.btn-primary:disabled { background: #696969; cursor: default; }

.btn-orange { background: #FFA500; } /* Start, RouteList, Kalman thumb */
.btn-orange:active { background: #FFA07A; }
.btn-orange:disabled { background: #696969; cursor: default; }

.btn-info { background: #1E90FF; } /* ShareManager (zmienione z #17A2B8 na #1E90FF) */
.btn-info:active { background: #ADD8E6; }
.btn-info:disabled { background: #696969; cursor: default; }

.btn-blue { background: #4682B4; } /* StartBluetooth */
.btn-blue:active { background: #87CEFA; }
.btn-blue:disabled { background: #696969; cursor: default; }

.btn-purple { background: #800080; } /* Admin buttons (ClearLogs, Test) */
.btn-purple:active { background: #DDA0DD; }
.btn-purple:disabled { background: #696969; cursor: default; }

.btn-skyblue { background: #2196F3; } /* ClearPhotos, Report (zmienione z btn-lightblue) */
.btn-skyblue:active { background: #64B5F6; }
.btn-skyblue:disabled { background: #696969; cursor: default; }


/* POLA FORMULARZA */
input[type=text], select {
    height: 40px;
    background: #222;
    border: 1px solid #444;
    color: #fff;
    padding: 0 10px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Styling dla suwaka (Slider) */
.kalman-slider-container {
    display: flex;
    flex-direction: column;
    gap: 5px; /* Spacing z XAML */
    width: 320px; /* WidthRequest z XAML */
    margin-top: 15px; /* Margin z XAML */
    flex-shrink: 0;
}

.kalman-slider-grid {
    display: flex; /* Zamiast grid, dla uproszczenia w HTML */
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px; /* Dystans między 0%, sliderem i 100% */
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px; /* Wysokość tracka */
    background: #696969; /* MaximumTrackColor */
    border-radius: 5px;
    outline: none;
    padding: 0;
    margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(to right, #FFA500 0%, #FFA500 var(--slider-value, 50%), #696969 var(--slider-value, 50%), #696969 100%);
    border-radius: 5px;
    height: 5px;
}

input[type="range"]::-moz-range-track {
    background: linear-gradient(to right, #FFA500 0%, #FFA500 var(--slider-value, 50%), #696969 var(--slider-value, 50%), #696969 100%);
    border-radius: 5px;
    height: 5px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #006400; /* ThumbColor */
    border-radius: 50%;
    cursor: grab;
    margin-top: -7.5px; /* Centrowanie kciuka na tracku */
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #006400; /* ThumbColor */
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
}

.kalman-slider-container .label {
    font-size: 11px; /* FontSize="Micro" */
    color: #ccc;
}

.kalman-slider-container .label.bold {
    font-weight: bold; /* FontAttributes="Bold" */
}

#KalmanDebugLabel {
    font-size: 11px; /* FontSize="Micro" */
    color: #FFD700; /* TextColor="#FFD700" */
    text-align: center;
}

/* Language Picker */
#langCombo {
    width: 320px; /* WidthRequest z XAML */
    margin-top: 10px; /* Margin z XAML */
    background: #1a1f29; /* Odpowiada default background-color w XAML dla Picker */
    color: white;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid #444; /* Domyślna ramka */
    font-size: 14px;
    flex-shrink: 0;
}

/* Admin Layout */
#admin {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Spacing z XAML */
    padding-top: 10px; /* Padding z XAML */
    margin-top: 15px; /* Dodatkowy margines, aby odseparować od góry */
    width: 320px; /* Wymuszamy szerokość, aby przyciski były wyśrodkowane */
    align-items: center; /* Wyśrodkowanie przycisków wewnątrz */
    flex-shrink: 0;
}

#admin .button-row { /* Dla ClearFotyBtn i TestButton */
    display: flex;
    gap: 10px; /* Spacing z XAML */
    width: 100%;
    justify-content: center;
}
#admin .button-row .btn {
    font-size: 11px; /* FontSize="Micro" */
}


/* GPS Fix Overlay */
#GpsFixOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95); /* #F2000000 */
    display: none; /* Domyślnie ukryty */
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Wyżej niż wszystko inne */
    cursor: pointer;
}

#GpsFixOverlay > div { /* VerticalStackLayout w overlayu */
    display: flex;
    flex-direction: column;
    gap: 25px; /* Spacing z XAML */
    padding: 30px;
    align-items: center;
    text-align: center;
}

#GpsFixOverlay label {
    color: #4682B4; /* TextColor="#4682B4" */
    font-size: 14px; /* FontSize="Small" */
    font-weight: bold; /* FontAttributes="Bold" */
    line-height: 1.4;
}

/* =========================================================================
   5. DOLNA BELKA SYSTEMOWA (Android Navigation Bar)
   ========================================================================= */
#sysNav {
    height: 55px;
    min-height: 55px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: space-around;
    border-top: 1px solid #222;
    flex-shrink: 0;
}

.sysBtn {
    background: none;
    border: none;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sysBtn svg {
    width: 22px;
    height: 22px;
    fill: none; /* SVG są stroke a nie fill dla tych ikon w HTML */
    stroke: #777; /* Domyślnie na #777 */
    stroke-width: 2;
}

/* =========================================================================
   6. TOOLTIPY (Dymki podpowiedzi) - Bez zmian, powinny działać
   ========================================================================= */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;

    left: auto;
    right: 0;
    margin-right: -10px;

    width: 280px;
    max-width: 320px;

    background: rgba(30, 30, 30, 0.98);
    color: #fff;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #FFA500;
    z-index: 1000;
    text-align: left;

    font-family: "Times New Roman", Times, serif;
    font-size: 15px;
    line-height: 1.4;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

[data-tooltip]:hover::after {
    opacity: 1;
}

.row [data-tooltip]::after {
    right: 0;
    left: auto;
}

/* =========================================================================
   7. STOPKA STRONY (poza telefonem)
   ========================================================================= */
footer {
    margin-top: 250px; /* ZWIĘKSZONO MARGINES - Zapewnia widoczność po skalowaniu telefonu */
    text-align: center;
    padding: 40px 20px;
    border-top: 1px solid #333;
    color: #888;
    width: 100%; /* Rozciągnij na całą szerokość */
    max-width: 800px; /* Ogranicz maksymalną szerokość */
}
footer a {
    color: #FFA500;
    text-decoration: none;
    font-weight: bold;
}
footer a:hover {
    text-decoration: underline;
}