/* ── Reset ──────────────────────────────────────────────────── */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* ── App shell ──────────────────────────────────────────────── */
#root {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── Map fills remaining space ──────────────────────────────── */
#map-container {
    flex: 1;
    position: relative;
}

.leaflet-container {
    width: 100%;
    height: 100%;
}

/* ── Search panel ───────────────────────────────────────────── */
/* One card holding search, collections and status line */
.search-panel-container {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    min-width: 230px;
    max-width: calc(100vw - 20px);
    max-height: calc(100% - 20px);
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
    font-family: sans-serif;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 0 10px;
    border-bottom: 1px solid #eee;
}

.panel-title {
    font-weight: bold;
    font-size: 14px;
}

/* [-] minimize button: 44x44 px is the recommended minimum touch target */
.panel-min {
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}
.panel-min:hover { background: #eee; }

/* Scrolls when search results plus the list are taller than the screen */
.panel-body {
    overflow-y: auto;
    min-height: 0;
}

/* Minimized: a single round button */
.panel-fab {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.search-panel {
    padding: 10px;
}

.search-panel input {
    width: 200px;
    margin-right: 4px;
}

.search-results {
    font-family: sans-serif;
    color: black;
    font-size: 75%;
    max-height: 200px;
    overflow-y: auto;
}

.search-results ul {
    margin: 4px 0 0;
    padding-left: 16px;
}

/* ── Leaflet draw handle overrides ──────────────────────────── */
.leaflet-editing-icon,
.leaflet-edit-move {
    width: 14px !important;
    height: 14px !important;
    margin-left: -7px !important;
    margin-top: -7px !important;
    background: #ff0000 !important;
    border: 2px solid white !important;
    border-radius: 50% !important;
}

/* ── Easy-button extras ─────────────────────────────────────── */
.gpx-btn {
    font-size: 11px;
    font-weight: bold;
    line-height: 12px;
}

.easy-button-button .gpx-btn {
    padding: 0;
}

/* ── Feature list ───────────────────────────────────────────── */
.feature-list {
    font-size: 13px;
    min-width: 220px;
    border-top: 1px solid #ddd;
}

/* Area / Line / Point badges in the feature list */
.feature-kind {
    display: inline-block;
    padding: 0 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: white;
    vertical-align: middle;
}
.kind-area  { background: #2e7d32; }
.kind-line  { background: #1565c0; }
.kind-point { background: #6a1b9a; }
.feature-measure { color: #444; }

.feature-list-header {
    padding: 6px 10px;
    cursor: pointer;
    font-weight: bold;
    user-select: none;
    border-bottom: 1px solid #eee;
}

.feature-list-header:hover {
    background: #f5f5f5;
}

.feature-list-empty {
    padding: 6px 10px;
    color: #888;
    margin: 0;
}

.feature-list-items {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
}

.feature-list-items li {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    gap: 4px;
}

.feature-list-items li:last-child {
    border-bottom: none;
}

.feature-list-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feature-list-items button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}

.feature-list-items button:hover {
    background: #e8e8e8;
}

/* Collections */
.feature-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.feature-list-title { flex: 1; }
.collection { border-bottom: 1px solid #eee; }
.collection-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #fafafa;
}
.collection-toggle {
    flex: 1;
    cursor: pointer;
    font-weight: bold;
    user-select: none;
}
.collection-created {
    padding: 0 10px 2px;
    color: #888;
    font-size: 11px;
}
.feature-list-header button,
.collection-header button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}
.feature-list-header button:hover,
.collection-header button:hover { background: #e8e8e8; }
.feature-list-row {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.feature-list-dates { color: #888; font-size: 11px; }
.collection { margin-left: 8px; }
.collection-header { cursor: pointer; user-select: none; }
.collection-header:hover { background: #f0f0f0; }
.collection-body { margin-left: 8px; }
.collection-download {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #f4f8ff;
    font-size: 12px;
}
.collection-download span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-download button {
    border: 1px solid #ccc;
    border-radius: 3px;
    background: white;
    cursor: pointer;
    padding: 2px 8px;
}
.collection-hidden .collection-toggle { color: #999; font-weight: normal; }
.collection-hidden .collection-body { opacity: 0.5; filter: grayscale(1); }
.collection-eye { opacity: 1; }
.collection-eye-off { opacity: 0.5; filter: grayscale(1); }
.feature-list-row { cursor: pointer; }
.feature-list-row:hover { background: #f5f5f5; }

/* Status line */
.feature-list-status {
    padding: 4px 10px;
    font-size: 12px;
    color: #555;
    border-top: 1px solid #eee;
    border-radius: 0 0 4px 4px;
}
.feature-list-status.status-saved   { color: #2a7a2a; }
.feature-list-status.status-saving  { color: #777; }
.feature-list-status.status-failed  { color: #b00020; background: #fff3f3; }

/* Feature properties popup */
.feature-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feature-dialog {
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    padding: 14px 16px;
    min-width: 280px;
    max-width: 90vw;
    font-family: sans-serif;
    font-size: 13px;
}
.feature-dialog-title { font-weight: bold; font-size: 15px; margin-bottom: 8px; }
.feature-dialog-table { border-collapse: collapse; width: 100%; }
.feature-dialog-table th,
.feature-dialog-table td {
    text-align: left;
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}
.feature-dialog-table th { background: #f5f5f5; }
.feature-dialog-table td:first-child { color: #555; white-space: nowrap; }
.feature-dialog-close { margin-top: 10px; float: right; cursor: pointer; }

/* Action bar (edit / move / draw with Back, Cancel, Save) */
.mp-actionbar {
    position: fixed;
    left: 50%;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 3000;
    max-width: 96vw;
    box-sizing: border-box;
    padding: 8px 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    font-family: sans-serif;
    font-size: 14px;
    text-align: center;
}
.mp-actionbar-title { margin-bottom: 6px; color: #333; }
.mp-actionbar-buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.mp-btn {
    min-height: 40px;
    min-width: 76px;
    padding: 6px 14px;
    border: 1px solid #bbb;
    border-radius: 6px;
    background: #f6f6f6;
    font-size: 15px;
    cursor: pointer;
}
.mp-btn-primary { background: #1a73e8; border-color: #1a73e8; color: white; }
.mp-btn-danger  { background: #fff; border-color: #c62828; color: #c62828; }

/* Name editor popup */
.mp-name-editor { display: flex; gap: 6px; align-items: center; }
.mp-name-input { flex: 1; min-width: 0; font-size: 16px; padding: 6px; }
.mp-name-editor .mp-btn { min-width: 0; min-height: 34px; padding: 4px 10px; font-size: 14px; }

/* Labels can be clicked to edit the name */
.leaflet-tooltip.leaflet-interactive { cursor: pointer; }

/* Touch screens: bigger handles for points of lines and areas */
@media (pointer: coarse) {
    .leaflet-editing-icon,
    .leaflet-edit-move,
    .leaflet-touch-icon {
        width: 26px !important;
        height: 26px !important;
        margin-left: -13px !important;
        margin-top: -13px !important;
    }
}

/* Account bar (top of the panel): Google sign-in button or "Signed in as ... / Sign out" */
.account-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}
.account-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-signout {
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #f6f6f6;
    cursor: pointer;
}
.account-signed-out { flex-direction: column; align-items: flex-start; }
.account-text { color: #444; }
.account-google-button { min-height: 32px; color: #888; font-size: 12px; }
.account-error { color: #b00020; font-size: 12px; }
.feature-list-status.status-signed-out { color: #777; }
/* Properties popup: editable name and user properties */
.feature-dialog { max-height: 90vh; overflow-y: auto; box-sizing: border-box; }
.prop-input {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;            /* 16px or more: iOS does not zoom in on focus */
    padding: 4px 6px;
    border: 1px solid #bbb;
    border-radius: 4px;
}
.prop-key { position: relative; }
.prop-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 10;
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
    background: white;
    border: 1px solid #bbb;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    max-height: 200px;
    overflow-y: auto;
}
.prop-suggestion { padding: 8px 8px; cursor: pointer; }
.prop-suggestion:hover,
.prop-suggestion-active { background: #e8f0fe; }
.prop-remove {
    min-width: 36px;
    min-height: 36px;
    border: none;
    background: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #888;
    border-radius: 4px;
}
.prop-remove:hover { background: #f0f0f0; color: #c62828; }
.prop-add {
    min-height: 36px;
    padding: 4px 10px;
    border: 1px dashed #999;
    border-radius: 4px;
    background: #fafafa;
    cursor: pointer;
}
.prop-readonly td { color: #555; }
.prop-hint { color: #999; font-size: 11px; }
.prop-errors { color: #b00020; margin: 8px 0 0; padding-left: 18px; }
.feature-dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }