/* ============================================================
   DRONILO — Vizuální prototyp
   Moderní tmavý sidebar + celoobrazovková mapa
   ============================================================ */

/* --- Základní reset a proměnné --- */
.hidden { display: none !important; }

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Paleta „Terroir" — teplé tóny, měděný akcent (vinice + pole) */
    --sidebar-bg: #121018;
    --sidebar-bg-secondary: #1a1624;
    --sidebar-border: #2e2838;
    --sidebar-text: #f0ebe6;
    --sidebar-text-muted: #9a919e;
    --sidebar-accent: #c9956a;
    --sidebar-accent-bright: #e4b888;
    --sidebar-accent-dim: rgba(201, 149, 106, 0.18);
    --sidebar-accent-border: rgba(201, 149, 106, 0.4);
    --sidebar-hover: #221e2c;
    --sidebar-active: #2a2436;
    --sidebar-accent-on: #121018;

    /* Ikony polí a vinic */
    --vineyard-bg: rgba(160, 72, 104, 0.25);
    --vineyard-color: #d4899a;
    --field-bg: rgba(140, 118, 62, 0.25);
    --field-color: #c9b068;

    /* Kalendář — dny letů dronem */
    --flight-bg: rgba(72, 118, 155, 0.28);
    --flight-bg-hover: rgba(72, 118, 155, 0.42);
    --flight-color: #8eb8d4;
    --flight-dot: #5a8fad;

    /* Mapa */
    --map-polygon: #c9956a;
    --map-polygon-fill: rgba(201, 149, 106, 0.18);
    --map-gps: #5a8fad;
    --map-control-bg: #f5f0ea;
    --map-control-text: #1a1624;
    --map-control-hover: #ebe4db;
    --map-control-active: #5a8fad;
    --map-control-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
    --info-bar-bg: rgba(18, 16, 24, 0.9);

    /* Rozměry */
    --sidebar-width: 320px;
    --header-height: 64px;

    /* Přechody */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;

    /* Font */
    --font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

html,
body {
    height: 100%;
    width: 100%;
    min-height: 100dvh;
    overflow: hidden;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--sidebar-text);
    background: var(--sidebar-bg);
    -webkit-font-smoothing: antialiased;
}

/* --- Hlavní layout --- */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* --- Sidebar toggle (mobil) --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2000;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--map-control-shadow);
    transition: background var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--sidebar-bg-secondary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1400;
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* --- Levý panel --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    overflow: visible;
    z-index: 1500;
    transition: transform var(--transition-normal);
}

/* Scrollovatelná střední část — pole, kalendář, posuvník */
.sidebar-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
}

.sidebar-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 3px;
}

.sidebar-top-section {
    flex-shrink: 0;
}

/* Logo */
.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--sidebar-accent-dim);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-name {
    display: block;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #ffffff;
}

.logo-tagline {
    display: block;
    font-size: 11px;
    color: var(--sidebar-text-muted);
    margin-top: 2px;
}

/* Klient info */
/* Wrapper pro profil + dropdown */
.client-info-wrapper {
    position: relative;
    flex-shrink: 0;
}

.client-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--sidebar-bg-secondary);
    border-bottom: 1px solid var(--sidebar-border);
}
.client-info--clickable {
    cursor: pointer;
    transition: background .15s;
    user-select: none;
}
.client-info--clickable:hover { background: var(--sidebar-hover, rgba(255,255,255,.05)); }
.client-info--clickable.active { background: var(--sidebar-hover, rgba(255,255,255,.07)); }
.client-info-chevron {
    margin-left: auto;
    color: var(--sidebar-muted, #8899aa);
    transition: transform .2s;
    flex-shrink: 0;
}
.client-info--clickable.active .client-info-chevron { transform: rotate(180deg); }

/* Dropdown profilu */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 10px;
    right: 10px;
    background: #1e2a3a;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    z-index: 600;
    overflow: hidden;
    animation: dropdownIn .15s ease;
}
@keyframes dropdownIn {
    from { opacity:0; transform:translateY(-6px); }
    to   { opacity:1; transform:translateY(0); }
}
.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    background: none;
    border: none;
    color: #c8d8e8;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background .12s;
}
.profile-dropdown-item:hover { background: rgba(255,255,255,.07); }
.profile-dropdown-item--danger { color: #f87171; }
.profile-dropdown-item--danger:hover { background: rgba(248,113,113,.1); }
.profile-dropdown-divider {
    height: 1px;
    background: rgba(255,255,255,.07);
    margin: 2px 0;
}

/* Modal: Změna hesla */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-box {
    background: #1a2435;
    border-radius: 14px;
    width: 380px;
    max-width: 95vw;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border: none;
    margin: 0;
    padding: 0;
    font: inherit;
    color: inherit;
}
.modal-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.modal-box-title { font-weight: 700; font-size: 15px; color: #e2e8f0; }
.modal-box-close {
    background: none; border: none; color: #8899aa;
    font-size: 18px; cursor: pointer; line-height: 1; padding: 2px 6px;
    border-radius: 6px; transition: background .12s;
}
.modal-box-close:hover { background: rgba(255,255,255,.08); color:#e2e8f0; }
.modal-box-body { padding: 20px 22px 4px; }
.modal-box-field { margin-bottom: 14px; }
.modal-box-field label { display:block; font-size:12px; color:#8899aa; margin-bottom:5px; font-weight:500; }
.modal-box-field input {
    width: 100%; box-sizing: border-box;
    background: #0f1623; border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px; padding: 9px 12px;
    color: #e2e8f0; font-size: 14px; outline: none;
    transition: border-color .15s;
}
.modal-box-field input:focus { border-color: #3b82f6; }
.cp-error {
    background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3);
    border-radius: 8px; padding: 9px 12px; color: #f87171;
    font-size: 13px; margin-bottom: 10px;
}
.modal-box-actions {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 14px 22px 20px;
}
.cp-btn {
    padding: 9px 20px; border-radius: 8px; border: none;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.cp-btn--ghost { background: rgba(255,255,255,.07); color: #c8d8e8; }
.cp-btn--ghost:hover { background: rgba(255,255,255,.12); }
.cp-btn--primary { background: #2563eb; color: #fff; }
.cp-btn--primary:hover { background: #1d4ed8; }
.cp-btn--primary:disabled { background: #374151; color: #6b7280; cursor: not-allowed; }

.client-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sidebar-accent-bright), var(--sidebar-accent));
    color: var(--sidebar-accent-on);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.client-name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #ffffff;
}

.client-role {
    display: block;
    font-size: 12px;
    color: var(--sidebar-text-muted);
    margin-top: 2px;
}

/* Sekce sidebaru */
.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.section-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sidebar-text-muted);
    margin-bottom: 10px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.section-header .section-label {
    margin-bottom: 0;
}

.field-count {
    background: var(--sidebar-accent-dim);
    color: var(--sidebar-accent);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Výběr farmy */
.farm-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--sidebar-bg-secondary);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238899aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    transition: border-color var(--transition-fast);
}

.farm-display {
    width: 100%;
    padding: 10px 12px;
    background: var(--sidebar-bg-secondary);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 600;
    cursor: default;
    user-select: none;
}

.farm-display-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.farm-select:hover,
.farm-select:focus {
    border-color: var(--sidebar-accent);
    outline: none;
}

/* Seznam polí */
.fields-section {
    flex-shrink: 0;
}

.field-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Kalendář a ostatní sekce — nikdy se nesmí smrsknout */
.calendar-section,
.opacity-section {
    flex-shrink: 0;
}

.field-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border: 1px solid transparent;
}

.field-item:hover {
    background: var(--sidebar-hover);
}

.field-item.active {
    background: var(--sidebar-active);
    border-color: var(--sidebar-accent-border);
}

.field-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.field-icon--vineyard {
    background: var(--vineyard-bg);
    color: var(--vineyard-color);
}

.field-icon--field {
    background: var(--field-bg);
    color: var(--field-color);
}

.field-info {
    flex: 1;
    min-width: 0;
}

.field-name {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-meta {
    display: block;
    font-size: 11px;
    color: var(--sidebar-text-muted);
    margin-top: 2px;
}

/* Tlačítko editace pole (jen Správce) */
.field-edit-btn {
    flex-shrink: 0;
    margin-left: auto;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: rgba(255,255,255,.3);
    padding: 4px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
    opacity: 0;
}
.field-item:hover .field-edit-btn { opacity: 1; }
.field-edit-btn:hover {
    background: rgba(201,149,106,.15);
    border-color: rgba(201,149,106,.3);
    color: #c9956a;
}

/* Dotyk / mobil — hover neexistuje, tlačítko musí být vidět */
@media (hover: none), (max-width: 1024px) {
    .field-edit-btn {
        opacity: 1;
        color: rgba(255, 255, 255, 0.5);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .field-item.active .field-edit-btn {
        color: #c9956a;
        border-color: rgba(201, 149, 106, 0.35);
    }
}

.field-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 6px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field-badge--new {
    background: var(--sidebar-accent-dim);
    color: var(--sidebar-accent-bright);
}

/* Kalendář */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.calendar-month {
    font-weight: 600;
    font-size: 14px;
    color: #ffffff;
}

.calendar-nav-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: var(--sidebar-bg-secondary);
    color: var(--sidebar-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.calendar-nav-btn:hover {
    border-color: var(--sidebar-accent);
    color: var(--sidebar-accent);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.calendar-day-header {
    font-size: 10px;
    font-weight: 600;
    color: var(--sidebar-text-muted);
    padding: 4px 0;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 6px;
    cursor: default;
    color: var(--sidebar-text-muted);
    position: relative;
    transition: all var(--transition-fast);
}

.calendar-day--empty {
    cursor: default;
}

.calendar-day--clickable {
    cursor: pointer;
    color: var(--sidebar-text);
}

.calendar-day--clickable:hover {
    background: var(--sidebar-hover);
}

.calendar-day--flight {
    background: var(--flight-bg);
    color: var(--flight-color);
    font-weight: 600;
    cursor: pointer;
}

.calendar-day--flight:hover {
    background: var(--flight-bg-hover);
}

.calendar-day--flight::after {
    content: "";
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--flight-dot);
}

.calendar-day--selected {
    background: var(--sidebar-accent) !important;
    color: var(--sidebar-accent-on) !important;
    font-weight: 700;
}

.calendar-day--today {
    border: 1px solid var(--sidebar-border);
}

.calendar-legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--sidebar-text-muted);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot--flight {
    background: var(--flight-dot);
}

.legend-dot--selected {
    background: var(--sidebar-accent);
}

/* Posuvník průhlednosti */
.opacity-section .section-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.opacity-value {
    font-size: 12px;
    font-weight: 700;
    color: var(--sidebar-accent);
    text-transform: none;
    letter-spacing: 0;
}

.opacity-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--sidebar-bg-secondary);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--sidebar-accent);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.opacity-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--sidebar-accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Patička sidebaru */
.sidebar-footer {
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    border-top: 1px solid var(--sidebar-border);
}

.footer-version {
    font-size: 11px;
    color: var(--sidebar-text-muted);
}

.footer-date {
    font-size: 11px;
    color: var(--sidebar-accent);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-text-muted);
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    border-color: rgba(200, 120, 120, 0.5);
    color: #e8a0a0;
    background: rgba(160, 72, 72, 0.12);
}

/* --- Oblast mapy --- */
.map-area {
    flex: 1;
    position: relative;
    height: 100vh;
    min-width: 0;
    overflow: hidden;
}

#leaflet-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #1a1624;
}

#leaflet-map.leaflet-container,
#leaflet-map .leaflet-container {
    width: 100% !important;
    height: 100% !important;
    background: #1a1624;
}

/* Přepsání Leaflet výchozích stylů */
.leaflet-control-zoom {
    display: none !important;
}

.leaflet-control-attribution {
    font-size: 10px !important;
    background: rgba(255, 255, 255, 0.85) !important;
    border-radius: 4px 0 0 0 !important;
}

/* Vzorový polygon pole na mapě */
.field-polygon-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 700;
    font-size: 12px;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

/* Ovládací prvky mapy */
.map-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    transition: right .28s cubic-bezier(.4,0,.2,1);
    flex-direction: column;
    gap: 8px;
}

.map-control-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: var(--map-control-bg);
    color: var(--map-control-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--map-control-shadow);
    transition: all var(--transition-fast);
}

.map-control-btn:hover {
    background: var(--map-control-hover);
    transform: scale(1.05);
}

.map-control-btn.active {
    background: var(--map-control-active);
    color: #ffffff;
}

/* Informační lišta */
.map-info-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--info-bar-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    color: var(--sidebar-text-muted);
    border-top: 1px solid var(--sidebar-border);
}

.map-info-item strong {
    color: #ffffff;
    font-weight: 600;
}

.map-info-divider {
    color: var(--sidebar-border);
}

/* Desktop: obalové bloky se „rozpustí“ do flex řádku */
.map-info-primary,
.map-info-actions {
    display: contents;
}

.map-info-notes-btn {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--sidebar-accent-dim);
    border: 1px solid var(--sidebar-accent-border);
    border-radius: 6px;
    color: var(--sidebar-accent);
    font-size: 12px; font-weight: 600;
    font-family: inherit;
    padding: 3px 10px;
    cursor: pointer;
    transition: all .15s ease;
    margin-left: 4px;
}
.map-info-notes-btn:hover { background: var(--sidebar-accent); color: #121018; }

/* --- Tlačítka s badge (poznámky, mapy) --- */
.notes-toggle-btn,
.maps-toggle-btn {
    position: relative;
    overflow: visible;
}
.notes-badge,
.maps-badge {
    position: absolute;
    top: 5px; right: 5px;
    background: #5a8fad;
    color: #fff;
    font-size: 9px; font-weight: 700;
    min-width: 15px; height: 15px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
    line-height: 1;
    border: 2px solid var(--map-control-bg);
    pointer-events: none;
}
.notes-badge.hidden { display: none; }

.maps-badge {
    position: absolute;
    top: 5px; right: 5px;
    background: #5a8fad;
    color: #fff;
    font-size: 9px; font-weight: 700;
    min-width: 15px; height: 15px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
    line-height: 1;
    border: 2px solid var(--map-control-bg);
    pointer-events: none;
}
.maps-badge.hidden { display: none; }

/* Posun ovládání mapy při otevřeném draweru */
.map-area.drawer-open .map-controls { right: calc(360px + 16px); }
.map-area.drawer-open .geotiff-bar { display: none !important; }
.app:has(.sidebar.open) .geotiff-bar { display: none !important; }

/* GeoTIFF aktivní vrstva — bar dole uprostřed obrazovky */
.geotiff-bar {
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9000;
    display: flex; align-items: center; gap: 10px;
    background: rgba(18,16,24,.95);
    border: 1px solid rgba(90,143,173,.4);
    border-radius: 24px;
    padding: 8px 12px 8px 16px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0,0,0,.6);
    white-space: nowrap;
    pointer-events: all;
}
.geotiff-bar.hidden { display: none !important; }
.geotiff-bar-left { display: flex; align-items: center; gap: 8px; }
.geotiff-bar-badge {
    font-size: 9px; font-weight: 800;
    padding: 2px 6px; border-radius: 4px;
    background: rgba(90,143,173,.2); color: #7db8d8;
    border: 1px solid rgba(90,143,173,.3);
}
.geotiff-bar-badge--ndvi     { background: rgba(60,160,60,.2);  color: #7dd87d;  border-color: rgba(60,160,60,.3); }
.geotiff-bar-badge--thermal  { background: rgba(220,80,50,.2);  color: #f0806a;  border-color: rgba(220,80,50,.3); }
.geotiff-bar-badge--variable { background: rgba(201,149,106,.2);color: #e4b888;  border-color: rgba(201,149,106,.3); }
.geotiff-bar-badge--rgb      { background: rgba(180,180,180,.15);color: #c0c0c0; border-color: rgba(180,180,180,.2); }
.geotiff-bar-label { font-size: 12px; font-weight: 600; color: #e8e3ed; }
.geotiff-bar-field { font-size: 11px; color: #9a919e; }
.geotiff-bar-opacity {
    display: flex; align-items: center; gap: 8px;
    padding: 0 4px;
    border-left: 1px solid rgba(255,255,255,.1);
    border-right: 1px solid rgba(255,255,255,.1);
    margin: 0 2px;
}
.geotiff-opacity-value {
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #9a919e;
    min-width: 34px;
    text-align: right;
}
.geotiff-opacity-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 96px;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #5a8fad var(--val, 100%), rgba(255,255,255,.15) var(--val, 100%));
    outline: none;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
}
.geotiff-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #7db8d8;
    border: 2px solid #121018;
    cursor: pointer;
    transition: background .15s;
}
.geotiff-opacity-slider::-webkit-slider-thumb:hover { background: #fff; }
.geotiff-opacity-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #7db8d8;
    border: 2px solid #121018;
    cursor: pointer;
}
.geotiff-opacity-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.15);
}

.geotiff-bar-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    transition: all .15s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.geotiff-bar-remove:hover { background: rgba(255,255,255,.1); color: #fff; }

/* --- Maps Drawer --- */
.maps-drawer {
    position: absolute;
    top: 0; right: 0;
    width: 360px;
    height: calc(100% - 57px);
    background: rgba(18,16,24,.97);
    border-left: 1px solid rgba(255,255,255,.08);
    display: flex; flex-direction: column;
    z-index: 900;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    backdrop-filter: blur(12px);
}
.maps-drawer.open  { transform: translateX(0); }
.maps-drawer.hidden { display: none; }

.maps-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.maps-drawer-title-wrap { display: flex; align-items: center; gap: 8px; }
.maps-drawer-title { font-size: 13px; font-weight: 700; color: #e8e3ed; }
.maps-drawer-field { font-size: 12px; color: #9a919e; background: rgba(255,255,255,.06); padding: 2px 8px; border-radius: 20px; }
.maps-drawer-close {
    background: none; border: none; color: rgba(255,255,255,.4);
    cursor: pointer; padding: 4px; border-radius: 6px; display: flex;
    transition: all .15s;
}
.maps-drawer-close:hover { background: rgba(255,255,255,.08); color: #fff; }

.maps-date-filter { flex-shrink: 0; }
.maps-date-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 10px 16px 8px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.maps-date-chip {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    color: #9a919e;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px; font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.maps-date-chip:hover  { background: rgba(255,255,255,.1); color: #e8e3ed; }
.maps-date-chip.active {
    background: rgba(90,143,173,.2);
    border-color: rgba(90,143,173,.5);
    color: #7db8d8;
}

.maps-active-date-bar {
    padding: 7px 16px;
    font-size: 11px; font-weight: 700;
    color: #7db8d8;
    background: rgba(90,143,173,.1);
    border-bottom: 1px solid rgba(90,143,173,.2);
    letter-spacing: .03em;
}
.maps-active-date-bar.hidden { display: none; }

.maps-list-wrap { flex: 1; overflow-y: auto; padding: 12px 0 20px; }

/* Skupina letů podle datumu */
.maps-flight-group { margin-bottom: 4px; }
.maps-flight-date {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px 6px;
    font-size: 11px; font-weight: 700; color: #9a919e;
    text-transform: uppercase; letter-spacing: .06em;
    position: sticky; top: 0;
    background: rgba(18,16,24,.95);
}
.maps-flight-date::after {
    content: ""; flex: 1; height: 1px;
    background: rgba(255,255,255,.07);
}

/* Položka mapy */
.map-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px;
    transition: background .12s;
}
.map-item--active {
    background: rgba(90,143,173,.08);
    border-left: 2px solid #5a8fad;
    padding-left: 14px;
    cursor: default;
}
.map-item:hover { background: rgba(255,255,255,.04); }

.map-type-badge {
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 800; letter-spacing: .04em;
    text-transform: uppercase;
}
.map-type-badge--ndvi     { background: rgba(92,184,92,.15);   color: #7ac97a; border: 1px solid rgba(92,184,92,.25); }
.map-type-badge--vegetation,
.map-type-badge--rvi, .map-type-badge--dvi, .map-type-badge--ndre, .map-type-badge--gndvi,
.map-type-badge--lci, .map-type-badge--mcari, .map-type-badge--mtvi2, .map-type-badge--tcari,
.map-type-badge--savi, .map-type-badge--osavi, .map-type-badge--msavi, .map-type-badge--msavi2,
.map-type-badge--vari, .map-type-badge--tgi, .map-type-badge--gli, .map-type-badge--exg, .map-type-badge--exr,
.map-type-badge--ndwi, .map-type-badge--ndmi, .map-type-badge--cwsi, .map-type-badge--pri, .map-type-badge--ari,
.map-type-badge--sipi, .map-type-badge--ipvi, .map-type-badge--rdvi, .map-type-badge--gemi, .map-type-badge--gari {
    background: rgba(92,184,92,.15); color: #7ac97a; border: 1px solid rgba(92,184,92,.25);
}
.geotiff-bar-badge--vegetation { background: rgba(92,184,92,.2); color: #7ac97a; }
.map-type-badge--rgb      { background: rgba(90,143,173,.15);  color: #7ab0d4; border: 1px solid rgba(90,143,173,.25); }
.map-type-badge--thermal  { background: rgba(220,120,60,.15);  color: #e08850; border: 1px solid rgba(220,120,60,.25); }
.map-type-badge--variable { background: rgba(201,149,106,.15); color: #e4b888; border: 1px solid rgba(201,149,106,.25); }
.map-type-badge--boundary { background: rgba(180,130,220,.15); color: #c4a0e0; border: 1px solid rgba(180,130,220,.25); }
.map-type-badge--pdf     { background: rgba(220,100,100,.15); color: #e09090; border: 1px solid rgba(220,100,100,.25); }

.map-item-info { flex: 1; min-width: 0; }
.map-item-label {
    font-size: 13px;
    font-weight: 600;
    color: #e8e3ed;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.map-item-size  { font-size: 11px; color: #9a919e; margin-top: 1px; }

.map-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Klikatelná položka mapy */
.map-item--clickable {
    cursor: pointer;
}
.map-item--clickable:hover {
    background: rgba(255,255,255,.04);
}
.map-item--loading {
    opacity: .6;
    pointer-events: none;
    cursor: wait;
}

.map-download-btn {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 5px;
    background: rgba(201,149,106,.12);
    border: 1px solid rgba(201,149,106,.3);
    border-radius: 7px;
    color: #c9956a;
    font-size: 11px; font-weight: 700; font-family: inherit;
    padding: 6px 10px; cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.map-download-btn:hover { background: #c9956a; color: #121018; }
.map-download-btn:active { transform: scale(.96); }

.map-view-btn {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 5px;
    background: rgba(90,143,173,.12);
    border: 1px solid rgba(90,143,173,.3);
    border-radius: 7px;
    color: #5a8fad;
    font-size: 11px; font-weight: 700; font-family: inherit;
    padding: 6px 10px; cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.map-view-btn:hover { background: #5a8fad; color: #121018; }
.map-view-btn:active { transform: scale(.96); }

.map-download-btn--locked {
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.08);
    color: rgba(255,255,255,.25);
    cursor: not-allowed;
}
.map-download-btn--locked:hover { background: rgba(255,255,255,.04); color: rgba(255,255,255,.25); }

.maps-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 48px 24px; gap: 10px; color: #9a919e; text-align: center;
}
.maps-empty p { font-size: 14px; font-weight: 600; color: #c8c0ce; margin: 0; }
.maps-empty span { font-size: 12px; line-height: 1.5; }

/* --- Notes Drawer --- */
.notes-drawer {
    position: absolute;
    top: 0; right: 0;
    width: 360px;
    height: calc(100% - 57px);
    background: rgba(18,16,24,.97);
    border-left: 1px solid rgba(255,255,255,.08);
    z-index: 900;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    backdrop-filter: blur(12px);
}
.notes-drawer.open  { transform: translateX(0); }
.notes-drawer.hidden { display: none; }

/* Hlavička draweru */
.notes-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.notes-drawer-title-wrap { display: flex; align-items: center; gap: 8px; }
.notes-drawer-title { font-size: 13px; font-weight: 700; color: #e8e3ed; }
.notes-drawer-field { font-size: 12px; color: #9a919e; background: rgba(255,255,255,.06); padding: 2px 8px; border-radius: 20px; }
.notes-drawer-close {
    background: none; border: none; color: rgba(255,255,255,.4);
    cursor: pointer; padding: 4px; border-radius: 6px; display: flex;
    transition: all .15s;
}
.notes-drawer-close:hover { background: rgba(255,255,255,.08); color: #fff; }

/* Seznam poznámek */
.notes-list-wrap {
    flex: 1; overflow-y: auto; min-height: 0;
    padding: 12px 14px;
    scrollbar-width: thin;
    scrollbar-color: #2e2838 transparent;
}
.notes-list-wrap::-webkit-scrollbar { width: 5px; }
.notes-list-wrap::-webkit-scrollbar-thumb { background: #2e2838; border-radius: 3px; }

.notes-list {
    list-style: none;
    display: flex; flex-direction: column; gap: 12px;
}

/* Jedna poznámka */
.note-item {
    background: #1a1624;
    border: 1px solid #2e2838;
    border-radius: 10px;
    padding: 14px 14px 10px;
    transition: border-color .15s ease;
}
.note-item:hover { border-color: #3d3650; }

.note-item-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px;
}
.note-item-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, rgba(90,143,173,.35), rgba(90,143,173,.2));
    color: #8eb8d4;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.note-item-avatar--spravce    { background: linear-gradient(135deg,rgba(90,143,173,.35),rgba(90,143,173,.2)); color:#8eb8d4; }
.note-item-avatar--zamestnanec{ background: linear-gradient(135deg,rgba(122,184,122,.3),rgba(122,184,122,.15)); color:#7ab87a; }
.note-item-avatar--superadmin { background: linear-gradient(135deg,rgba(201,149,106,.35),rgba(201,149,106,.2)); color:#e4b888; }

.note-item-author { font-size: 13px; font-weight: 600; color: #fff; }
.note-item-role {
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 10px;
    margin-left: 4px;
}
.note-item-role--spravce     { background: rgba(90,143,173,.2);  color: #8eb8d4; }
.note-item-role--zamestnanec { background: rgba(122,184,122,.2); color: #7ab87a; }
.note-item-role--superadmin  { background: rgba(201,149,106,.2); color: #e4b888; }

.note-item-date { font-size: 11px; color: #9a919e; white-space: nowrap; flex-shrink: 0; }

.note-delete-btn {
    background: none; border: none;
    color: #6a616e; cursor: pointer;
    width: 26px; height: 26px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all .15s ease;
    margin-left: 4px;
}
.note-delete-btn:hover { background: rgba(200,80,80,.15); color: #e8a0a0; }

.note-item-text {
    font-size: 13px; color: #d0cad5;
    line-height: 1.6;
    word-break: break-word;
}

/* Fotky v poznámce */
.note-item-photos {
    display: flex; flex-wrap: wrap; gap: 7px;
    margin-top: 10px;
}
.note-photo-thumb {
    width: 76px; height: 60px;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid #2e2838;
    cursor: pointer;
    transition: border-color .15s ease;
    flex-shrink: 0;
}
.note-photo-thumb:hover { border-color: #c9956a; }
.note-photo-thumb img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.note-photo-thumb--loading {
    border-color: #3d3650;
    background: rgba(255,255,255,.04);
    display: flex;
    align-items: center;
    justify-content: center;
}
.note-photo-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(201,149,106,.25);
    border-top-color: #c9956a;
    animation: notePhotoSpin .9s linear infinite;
}
@keyframes notePhotoSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Prázdný stav */
.notes-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 20px; text-align: center;
    color: #9a919e;
    gap: 10px;
}
.notes-empty p { font-size: 14px; font-weight: 600; color: #f0ebe6; }
.notes-empty span { font-size: 12px; }
.notes-empty.hidden { display: none; }

/* Formulář nové poznámky */
.notes-form-wrap {
    border-top: 1px solid #2e2838;
    padding: 14px;
    flex-shrink: 0;
    background: #1a1624;
}
.notes-textarea {
    width: 100%;
    background: #211d2c;
    border: 1px solid #2e2838;
    border-radius: 8px;
    color: #f0ebe6;
    font-size: 13px;
    font-family: "Segoe UI", system-ui, sans-serif;
    padding: 10px 12px;
    resize: none;
    line-height: 1.5;
    transition: border-color .15s ease;
    display: block;
    margin-bottom: 10px;
}
.notes-textarea:focus { outline: none; border-color: #c9956a; }
.notes-textarea::placeholder { color: #6a616e; }

/* Řada fotek před odesláním */
.notes-photos-row {
    display: flex; flex-wrap: wrap; gap: 7px;
    margin-bottom: 10px;
}
.notes-photo-preview {
    width: 64px; height: 52px;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid #3d3650;
    position: relative;
    flex-shrink: 0;
}
.notes-photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.notes-photo-remove {
    position: absolute; top: 3px; right: 3px;
    width: 18px; height: 18px;
    background: rgba(0,0,0,.65);
    border: none; border-radius: 50%;
    color: #fff; font-size: 11px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}

.notes-form-actions {
    display: flex; align-items: center; gap: 8px;
}
.notes-photo-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    background: #211d2c;
    border: 1px solid #2e2838;
    border-radius: 8px;
    color: #9a919e; font-size: 12px; font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.notes-photo-btn:hover { border-color: #c9956a; color: #c9956a; }
.hidden-input { display: none; }

.notes-submit-btn {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 14px;
    background: #c9956a; color: #121018;
    border: none; border-radius: 8px;
    font-size: 13px; font-weight: 600;
    font-family: "Segoe UI", system-ui, sans-serif;
    cursor: pointer;
    transition: background .15s ease;
}
.notes-submit-btn:hover { background: #e4b888; }
.notes-submit-btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Pin mód na mapě --- */
.map-area.pin-mode #leaflet-map { cursor: crosshair !important; }
.map-area.pin-mode .leaflet-container { cursor: crosshair !important; }
.map-area.pin-mode .geotiff-bar { display: none !important; }

.pin-mode-hint {
    position: absolute;
    top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 1700;
    background: rgba(18,16,24,.94);
    border: 1px solid rgba(201,149,106,.5);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; font-weight: 600; color: #e4b888;
    box-shadow: 0 4px 20px rgba(0,0,0,.5);
    white-space: nowrap;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: slideDown .2s ease;
    max-width: min(520px, calc(100vw - 32px));
}
.pin-mode-hint.hidden { display: none; }

.pin-mode-hint-text {
    flex: 1;
    min-width: 0;
    line-height: 1.35;
}

@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-8px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.pin-mode-cancel {
    background: rgba(201,149,106,.2);
    border: 1px solid rgba(201,149,106,.4);
    border-radius: 8px;
    color: #e4b888;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    padding: 8px 14px;
    min-height: 44px;
    min-width: 44px;
    cursor: pointer;
    transition: all .15s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.pin-mode-cancel:hover { background: #c9956a; color: #121018; }

/* --- Tlačítko umístění v poznámkovém formuláři --- */
.notes-location-row {
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}
.notes-location-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    background: #211d2c;
    border: 1px dashed #3d3650;
    border-radius: 8px;
    color: #9a919e; font-size: 12px; font-weight: 500;
    font-family: inherit; cursor: pointer;
    transition: all .15s ease;
}
.notes-location-btn:hover { border-color: #c9956a; color: #c9956a; border-style: solid; }
.notes-location-btn.active { border-color: #c9956a; color: #c9956a; border-style: solid; background: rgba(201,149,106,.1); }

.notes-location-set {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    background: rgba(92,184,92,.1);
    border: 1px solid rgba(92,184,92,.35);
    border-radius: 8px;
    color: #7ab87a; font-size: 12px; font-weight: 600;
}
.notes-location-set.hidden { display: none; }

.notes-location-clear {
    background: none; border: none;
    color: #7ab87a; font-size: 15px; line-height: 1;
    cursor: pointer; padding: 0 2px;
    opacity: .7;
    transition: opacity .15s;
}
.notes-location-clear:hover { opacity: 1; }

/* --- Marker poznámky na mapě --- */
.note-map-marker {
    position: relative;
    width: 30px; height: 36px;
    cursor: pointer;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
}
.note-map-marker-body {
    width: 30px; height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(255,255,255,.7);
}
.note-map-marker-body svg {
    transform: rotate(45deg);
}
.note-map-marker-body--spravce     { background: #5a8fad; }
.note-map-marker-body--zamestnanec { background: #7ab87a; }
.note-map-marker-body--superadmin  { background: #c9956a; }

/* Dočasný marker při výběru místa */
.note-map-marker-temp .note-map-marker-body {
    background: rgba(201,149,106,.7) !important;
    border: 2px dashed #e4b888 !important;
    animation: pulse 1.2s infinite;
}
@keyframes pulse {
    0%, 100% { transform: rotate(-45deg) scale(1); }
    50%       { transform: rotate(-45deg) scale(1.12); }
}

/* Lightbox pro fotky */
.photo-lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    animation: fadeIn .15s ease;
}
.photo-lightbox img {
    max-width: 92vw; max-height: 92vh;
    border-radius: 8px;
    box-shadow: 0 8px 48px rgba(0,0,0,.6);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Potvrzovací dialog --- */
.confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9800;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeInOverlay .15s ease;
}
.confirm-overlay.hidden { display: none; }

@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }

.confirm-dialog {
    background: #1a1624;
    border: 1px solid #3d3650;
    border-radius: 14px;
    padding: 28px 28px 24px;
    width: 100%; max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
    display: flex; flex-direction: column; align-items: center;
    text-align: center;
    animation: popIn .18s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
    from { transform: scale(.88); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.confirm-icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(217,83,79,.14);
    border: 1px solid rgba(217,83,79,.3);
    color: #e8a0a0;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.confirm-title {
    font-size: 16px; font-weight: 700; color: #fff;
    margin-bottom: 8px;
}
.confirm-message {
    font-size: 13px; color: #9a919e;
    line-height: 1.5; margin-bottom: 24px;
}
.confirm-actions {
    display: flex; gap: 10px; width: 100%;
}
.confirm-btn {
    flex: 1; padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px; font-weight: 600;
    font-family: "Segoe UI", system-ui, sans-serif;
    cursor: pointer;
    transition: all .15s ease;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.confirm-btn--cancel {
    background: #211d2c; border: 1px solid #2e2838; color: #9a919e;
}
.confirm-btn--cancel:hover { border-color: #3d3650; color: #f0ebe6; }
.confirm-btn--delete {
    background: rgba(217,83,79,.18);
    border: 1px solid rgba(217,83,79,.35);
    color: #e8a0a0;
}
.confirm-btn--delete:hover { background: #d9534f; color: #fff; border-color: #d9534f; }

/* --- Leaflet popup — tmavé téma --- */
.dronilo-popup .leaflet-popup-content-wrapper {
    background: #1a1624 !important;
    border: 1px solid #3d3650 !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,.55) !important;
    color: #f0ebe6 !important;
    padding: 0 !important;
}
.dronilo-popup .leaflet-popup-content {
    margin: 14px 16px !important;
}
.dronilo-popup .leaflet-popup-tip-container .leaflet-popup-tip {
    background: #1a1624 !important;
}
.dronilo-popup .leaflet-popup-close-button {
    color: #9a919e !important; top: 8px !important; right: 10px !important;
    font-size: 18px !important;
}
.dronilo-popup .leaflet-popup-close-button:hover { color: #f0ebe6 !important; }

/* --- Responzivita: mobil a tablet --- */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: min(320px, 92vw);
        --mobile-chrome-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
        --safe-top: env(safe-area-inset-top, 0px);
        --safe-bottom: env(safe-area-inset-bottom, 0px);
        --safe-left: env(safe-area-inset-left, 0px);
        --safe-right: env(safe-area-inset-right, 0px);
    }

    html,
    body,
    .app,
    .map-area {
        height: 100dvh;
    }

    .app {
        display: block;
    }

    .map-area {
        width: 100vw;
    }

    .sidebar-toggle {
        display: flex;
        top: calc(12px + var(--safe-top));
        left: calc(12px + var(--safe-left));
    }

    /* Drawer otevřený — hamburger schovat (zavření přes X v draweru) */
    .app:has(.map-area.drawer-open) .sidebar-toggle {
        visibility: hidden;
        pointer-events: none;
    }

    /* Sidebar otevřený — logo a text nepod hamburgerem */
    .app:has(.sidebar.open) .sidebar-header {
        padding-left: calc(64px + var(--safe-left));
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100dvh;
        padding-top: var(--safe-top);
        padding-bottom: var(--safe-bottom);
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .field-item {
        min-height: 48px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .field-edit-btn {
        width: 36px;
        height: 36px;
        padding: 0;
    }

    /* Drawery — celá šířka, nad sidebarem i spodní lištou */
    .maps-drawer,
    .notes-drawer {
        width: 100%;
        max-width: 100vw;
        height: 100%;
        top: 0;
        border-left: none;
        z-index: 1600;
        padding-top: var(--safe-top);
        padding-bottom: var(--safe-bottom);
    }

    .maps-drawer-header,
    .notes-drawer-header {
        padding-top: calc(14px + 4px);
    }

    .maps-drawer-close,
    .notes-drawer-close {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
        align-items: center;
        justify-content: center;
    }

    .maps-drawer-field,
    .notes-drawer-field {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .map-area.drawer-open .map-controls {
        right: calc(12px + var(--safe-right));
        opacity: 0;
        pointer-events: none;
    }

    .map-area.drawer-open .geotiff-bar {
        display: none !important;
    }

    .map-area:has(#geotiffBar:not(.hidden)) .map-controls {
        bottom: calc(var(--mobile-chrome-bottom) + 80px);
    }

    .map-controls {
        top: auto;
        bottom: var(--mobile-chrome-bottom);
        right: calc(12px + var(--safe-right));
    }

    .map-control-btn {
        width: 48px;
        height: 48px;
        -webkit-tap-highlight-color: transparent;
    }

    .map-info-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px calc(10px + var(--safe-bottom));
        font-size: 12px;
    }

    .map-info-primary,
    .map-info-actions {
        display: flex;
    }

    .map-info-primary {
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .map-info-primary .map-info-item {
        width: auto;
    }

    .map-info-primary .map-info-item strong {
        font-size: 14px;
        line-height: 1.3;
    }

    #activeFieldMeta {
        font-size: 11px;
        line-height: 1.35;
        color: #b8b0bc;
    }

    .map-info-divider,
    .map-info-drone {
        display: none !important;
    }

    .map-info-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .map-info-notes-btn {
        margin: 0;
        justify-content: center;
        padding: 10px 6px;
        min-height: 44px;
        font-size: 11px;
        gap: 4px;
        -webkit-tap-highlight-color: transparent;
    }

    .map-info-notes-btn svg {
        flex-shrink: 0;
    }

    .geotiff-bar {
        bottom: calc(var(--mobile-chrome-bottom) + 8px);
        left: calc(10px + var(--safe-left));
        right: calc(10px + var(--safe-right));
        transform: none;
        max-width: none;
        width: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        align-items: center;
        border-radius: 14px;
        padding: 6px 6px 6px 10px;
        gap: 6px;
    }

    .geotiff-bar-left {
        flex: 0 1 auto;
        min-width: 0;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .geotiff-bar-field {
        display: none;
    }

    .geotiff-bar-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 22vw;
        font-size: 11px;
    }

    .geotiff-bar-badge {
        flex-shrink: 0;
        padding: 3px 6px;
        font-size: 8px;
    }

    .geotiff-bar-opacity {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
        padding: 0 4px;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        border-right: none;
        min-height: 44px;
    }

    .geotiff-bar-opacity > svg {
        display: none;
    }

    .geotiff-opacity-slider {
        flex: 1 1 auto;
        width: auto;
        min-width: 48px;
        max-width: none;
        height: 8px;
    }

    .geotiff-opacity-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
        border-width: 3px;
    }

    .geotiff-opacity-slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
        border-width: 3px;
    }

    .geotiff-opacity-value {
        font-size: 11px;
        min-width: 36px;
        flex-shrink: 0;
    }

    .geotiff-bar-remove {
        width: 44px;
        height: 44px;
        border-radius: 10px;
        color: rgba(255, 255, 255, 0.65);
        background: rgba(255, 255, 255, 0.06);
    }

    .geotiff-bar-remove:active {
        background: rgba(255, 255, 255, 0.14);
        color: #fff;
    }

    .pin-mode-hint {
        top: calc(64px + var(--safe-top));
        left: calc(12px + var(--safe-left));
        right: calc(12px + var(--safe-right));
        transform: none;
        white-space: normal;
        max-width: none;
        width: auto;
        padding: 10px 12px;
        gap: 8px;
    }

    .pin-mode-hint-text {
        font-size: 12px;
        text-align: left;
    }

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

    .pin-mode-cancel {
        padding: 10px 16px;
    }

    .map-area.pin-mode .map-controls {
        opacity: 0;
        pointer-events: none;
    }

    .map-area.pin-mode .map-info-bar {
        opacity: 0;
        pointer-events: none;
    }

    .notes-form-wrap {
        padding-bottom: calc(14px + var(--safe-bottom));
    }

    .notes-location-btn,
    .notes-submit-btn {
        min-height: 44px;
    }

    .confirm-overlay {
        padding: calc(12px + var(--safe-top)) calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
        align-items: flex-end;
    }

    .confirm-dialog {
        max-width: 100%;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        padding: 22px 20px calc(20px + var(--safe-bottom));
    }

    .confirm-btn {
        min-height: 44px;
    }

    .client-field-detail-dialog {
        width: 100% !important;
        max-width: min(520px, 100%) !important;
        max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 40px);
        border-radius: 14px;
    }

    #clientFieldDetailOverlay {
        align-items: center;
        justify-content: center;
        padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
    }

    #clientFieldDetailOverlay .confirm-dialog {
        max-width: min(520px, 100%);
        border-radius: 14px;
        border-bottom-left-radius: 14px;
        border-bottom-right-radius: 14px;
    }

    .client-field-detail-grid {
        grid-template-columns: 1fr;
    }

    .client-field-detail-footer {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .client-field-detail-footer .confirm-btn,
    .client-field-detail-footer button {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        min-height: 44px;
    }

    .client-field-detail-footer .confirm-btn--cancel {
        flex: 1 1 100%;
    }

    .client-field-detail-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        top: 10px;
        right: 10px;
    }

    #editFieldOverlay .confirm-dialog input {
        font-size: 16px !important;
        min-height: 44px;
    }

    #editFieldOverlay .confirm-dialog {
        max-width: min(420px, 100%);
    }

    .client-map-popup .leaflet-popup-content {
        margin: 12px 14px !important;
        min-width: 0 !important;
        max-width: calc(100vw - 48px);
    }

    .client-map-popup-btn {
        min-height: 44px;
        padding: 10px 12px;
    }

    .leaflet-control-attribution {
        display: none !important;
    }

    /* Mapy/Poznámky jsou ve spodní liště — na mobilu skrýt duplicitu */
    .maps-toggle-btn,
    .notes-toggle-btn {
        display: none;
    }

    /* Modal změna hesla — vycentrovaný na mobilu */
    .change-password-overlay {
        padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
        align-items: center;
        justify-content: center;
    }

    .change-password-overlay .modal-box {
        width: 100%;
        max-width: min(380px, 100%);
        border-radius: 14px;
    }

    .change-password-overlay .modal-box-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .change-password-overlay .modal-box-field input {
        font-size: 16px;
        min-height: 44px;
    }

    .change-password-overlay .modal-box-actions {
        flex-direction: row;
        justify-content: flex-end;
        gap: 10px;
    }

    .change-password-overlay .cp-btn {
        min-height: 44px;
        width: auto;
        flex: 1;
    }

    .change-password-overlay .cp-btn--ghost {
        flex: 0 1 auto;
    }

    .profile-dropdown-item {
        min-height: 48px;
        padding: 12px 16px;
    }

    .calendar-nav-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .calendar-day--clickable {
        min-height: 36px;
    }

    .map-item {
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        min-height: 48px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .map-item-info {
        flex: 1 1 auto;
        min-width: 0;
    }

    .map-item-actions {
        gap: 4px;
    }

    .map-view-btn,
    .map-download-btn {
        min-height: 36px;
        padding: 6px 8px;
        font-size: 10px;
        gap: 4px;
    }

    .map-view-btn svg,
    .map-download-btn svg {
        flex-shrink: 0;
    }

    .client-field-map-row {
        flex-wrap: wrap;
    }

    .client-field-map-view,
    .client-field-map-dl {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }

    .notes-photo-btn {
        min-height: 44px;
    }

    .notes-photo-remove {
        width: 28px;
        height: 28px;
    }

    .photo-lightbox {
        padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
    }

    .map-area.pin-mode .sidebar-toggle {
        visibility: hidden;
        pointer-events: none;
    }

    .client-info--clickable {
        min-height: 48px;
    }

    #cpSuccessToast {
        bottom: calc(var(--mobile-chrome-bottom) + 8px) !important;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: calc(100vw - 24px);
    }
}

@media (max-width: 480px) {
    :root {
        --sidebar-width: 100vw;
    }

    .sidebar-section {
        padding: 14px 16px;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    :root {
        --mobile-chrome-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    }

    .map-info-bar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 8px 12px calc(8px + var(--safe-bottom));
    }

    .map-info-primary {
        flex: 1 1 180px;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 6px;
    }

    .map-info-actions {
        flex: 0 0 auto;
        display: flex;
        gap: 6px;
    }

    .map-info-notes-btn {
        min-height: 44px;
        padding: 8px 10px;
    }

    .map-area:has(#geotiffBar:not(.hidden)) .map-controls {
        bottom: calc(var(--mobile-chrome-bottom) + 68px);
    }

    .sidebar-toggle {
        top: calc(8px + var(--safe-top));
    }

    .map-controls {
        bottom: calc(var(--mobile-chrome-bottom) + 4px);
    }

    .pin-mode-hint {
        top: calc(48px + var(--safe-top));
    }
}

/* ——— Klientská mapa: popup + detail pole ——— */
.client-map-popup .leaflet-popup-content-wrapper {
    background: #1a1624;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    color: #e8e3ed;
}

.client-map-popup .leaflet-popup-tip { background: #1a1624 !important; }
.client-map-popup .leaflet-popup-content { margin: 14px 16px !important; min-width: 200px; }

.client-map-popup-title {
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    margin-bottom: 4px;
}

.client-map-popup-sub {
    font-size: 12px;
    color: #9a919e;
    margin-bottom: 10px;
}

.client-map-popup-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    margin-bottom: 12px;
}

.client-map-popup-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.client-map-popup-btn {
    width: 100%;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #e8e3ed;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.client-map-popup-btn:hover { background: rgba(255, 255, 255, 0.1); }

.client-map-popup-btn--primary {
    background: #c9956a;
    border-color: #c9956a;
    color: #121018;
}

.client-map-popup-btn--primary:hover { background: #d4a574; }

.client-field-detail-dialog {
    max-width: 520px !important;
    width: calc(100% - 32px);
    text-align: left;
    position: relative;
    max-height: min(85vh, calc(100dvh - 40px));
    overflow-y: auto;
    align-items: stretch;
}

.client-field-detail-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: #9a919e;
    cursor: pointer;
    padding: 4px;
    line-height: 0;
}

.client-field-detail-close:hover { color: #fff; }

.client-field-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 16px 0 0;
}

.client-field-detail-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9a919e;
    margin-bottom: 4px;
}

.client-field-detail-value {
    font-size: 14px;
    color: #fff;
}

.client-field-detail-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.map-fields-hint {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    max-width: min(420px, calc(100% - 32px));
    padding: 12px 16px;
    background: rgba(26, 22, 36, 0.92);
    border: 1px solid rgba(201, 149, 106, 0.35);
    border-radius: 10px;
    color: #e8e3ed;
    font-size: 13px;
    text-align: center;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
