/* Kartta — Mobile Map App */
:root {
    --sidebar-width: 280px;
    --toolbar-height: 48px;
    --nav-height: 44px;
    --color-primary: #2a6fb5;
    --color-bg: #ffffff;
    --color-text: #333333;
    --color-muted: #888888;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#map {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
}

/* Area Navigation */
#area-nav {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 4px;
    background: var(--color-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    padding: 4px;
}

.area-btn {
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--color-text);
    transition: all 0.2s;
    min-height: 44px;
}

.area-btn.active {
    background: var(--color-primary);
    color: white;
}

/* Hamburger */
#sidebar-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: var(--color-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 20px;
    cursor: pointer;
}

/* Sidebar */
#sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    background: var(--color-bg);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 12px rgba(0,0,0,0.15);
    transition: transform 0.3s ease;
    transform: translateX(0);
}

#sidebar.hidden {
    transform: translateX(calc(-1 * var(--sidebar-width) - 20px));
}

#sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

#sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
}

#sidebar-close {
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

#sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

#sidebar-footer button {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: var(--color-bg);
    cursor: pointer;
    font-size: 13px;
    min-height: 44px;
}

#sidebar-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1999;
}

#sidebar-overlay.hidden { display: none; }

/* Layer sections */
.layer-section {
    margin: 0 0 4px 0;
}

.layer-section-header {
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13px;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    min-height: 44px;
}

.layer-item:hover { background: #f5f5f5; }

.layer-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary);
}

.layer-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.layer-label {
    flex: 1;
    font-size: 14px;
}

.layer-count {
    font-size: 12px;
    color: var(--color-muted);
}

/* Draw Toolbar */
#draw-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 4px;
    background: var(--color-bg);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    padding: 4px;
}

.draw-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.draw-btn:hover { background: #f0f0f0; }
.draw-btn.active { background: var(--color-primary); }
.draw-btn.active span { color: white; }

/* Annotation Modal */
#annotation-modal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#annotation-modal.hidden { display: none; }

.modal-content {
    background: var(--color-bg);
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 360px;
}

.modal-content h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.modal-content label {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: var(--color-muted);
}

.modal-content input,
.modal-content select {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    min-height: 44px;
}

#ann-save {
    background: var(--color-primary);
    color: white;
}

#ann-cancel {
    background: #f0f0f0;
    color: var(--color-text);
}

/* Popups */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    max-width: 280px;
}

.leaflet-popup-content {
    margin: 10px 14px;
    font-size: 14px;
    line-height: 1.4;
}

.popup-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
}

.popup-field {
    margin: 4px 0;
}

.popup-field-label {
    font-size: 12px;
    color: var(--color-muted);
}

.popup-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-conifer { background: #d4edda; color: #155724; }
.badge-deciduous { background: #cce5ff; color: #004085; }
.badge-sign { background: #fff3cd; color: #856404; }
.badge-interest { background: #d1ecf1; color: #0c5460; }
.badge-note { background: #e2e3e5; color: #383d41; }

.popup-url {
    display: inline-block;
    margin-top: 6px;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 13px;
}

/* Annotation markers */
.annotation-marker {
    background: #ff6b6b;
    border: 2px solid #fff;
    border-radius: 50%;
}

/* Desktop adjustments */
@media (min-width: 768px) {
    :root { --sidebar-width: 320px; }

    #draw-toolbar {
        bottom: auto;
        top: 10px;
        right: 10px;
        left: auto;
        transform: none;
        flex-direction: column;
    }

    #area-nav {
        left: 60px;
        transform: none;
    }
}
