/* Reset & Base */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    color: #333;
}

/* Map */
#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Attribution control styling */
.maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.8) !important;
    font-size: 10px;
}

/* Panels */
.panel {
    position: absolute;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
    z-index: 10;
}

.panel.hidden {
    display: none;
}

.panel h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #d73f3f; /* HOT red */
}

.panel h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
}

.panel .subtitle {
    margin: 4px 0 0 0;
    font-size: 12px;
    color: #666;
}

/* Header */
#header {
    top: 10px;
    left: 10px;
}

/* Controls */
#controls {
    top: 80px;
    left: 10px;
    width: 220px;
}

.control-group {
    margin-bottom: 12px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group > label {
    display: block;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 4px;
    color: #555;
}

.input-row {
    display: flex;
    gap: 6px;
}

.input-row input {
    flex: 1;
    min-width: 0;
}

input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: #d73f3f;
}

button {
    background: #d73f3f;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #b83232;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.checkbox-row label {
    font-weight: normal;
    font-size: 13px;
    cursor: pointer;
}

/* Legend */
#legend {
    bottom: 220px;
    right: 10px;
    min-width: 120px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Zoom Warning */
#zoom-warning {
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 20px;
    transition: opacity 0.3s;
}

#zoom-warning.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Imagery Loading Indicator */
#imagery-loading {
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(215, 63, 63, 0.9);
    color: white;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#imagery-loading .loading {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

#imagery-loading.hidden {
    display: none;
}

/* Label note */
.label-note {
    font-weight: normal;
    color: #888;
    font-size: 10px;
}

/* Info Panel */
#info-panel {
    top: 10px;
    right: 10px;
    width: 300px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

.close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 24px;
}

.close-btn:hover {
    color: #333;
    background: none;
}

#info-content {
    font-size: 13px;
    line-height: 1.5;
}

#info-content .info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #eee;
}

#info-content .info-row:last-child {
    border-bottom: none;
}

#info-content .info-label {
    color: #666;
}

#info-content .info-value {
    font-weight: 500;
    text-align: right;
}

#info-content a {
    color: #d73f3f;
    text-decoration: none;
}

#info-content a:hover {
    text-decoration: underline;
}

#info-content .btn-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 12px;
    background: #d73f3f;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
}

#info-content .btn-link:hover {
    background: #b83232;
    text-decoration: none;
}

/* Stats Panel */
#stats-panel {
    bottom: 40px;
    right: 10px;
    min-width: 200px;
}

#stats-content {
    font-size: 13px;
}

#stats-content .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

#stats-content .stat-label {
    color: #666;
}

#stats-content .stat-value {
    font-weight: 600;
}

#stats-content .stat-value.fresh {
    color: #22c55e;
}

#stats-content .stat-value.medium {
    color: #eab308;
}

#stats-content .stat-value.old {
    color: #f97316;
}

#stats-content .stat-value.very-old {
    color: #ef4444;
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #d73f3f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Popup styling */
.maplibregl-popup-content {
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    max-width: 280px;
}

.maplibregl-popup-content h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #333;
}

.maplibregl-popup-content .popup-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

.maplibregl-popup-content .popup-label {
    color: #666;
}

.maplibregl-popup-content .popup-value {
    font-weight: 500;
}

.maplibregl-popup-close-button {
    font-size: 18px;
    padding: 4px 8px;
}

/* Recent Projects List */
.recent-projects-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 6px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.recent-project-item {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s;
}

.recent-project-item:last-child {
    border-bottom: none;
}

.recent-project-item:hover {
    background: #f5f5f5;
}

.recent-project-item .project-id {
    font-weight: 600;
    font-size: 12px;
    color: #d73f3f;
}

.recent-project-item .project-name {
    font-size: 11px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.recent-project-item .project-status {
    font-size: 10px;
    text-transform: uppercase;
    margin-top: 2px;
}

.recent-project-item .status-published {
    color: #22c55e;
}

.recent-project-item .status-draft {
    color: #9ca3af;
}

.recent-project-item .status-archived {
    color: #6b7280;
}

.loading-text {
    padding: 10px;
    text-align: center;
    color: #999;
    font-size: 12px;
}

/* OAM Info Panel */
#oam-info-panel {
    top: 10px;
    right: 10px;
    width: 300px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

#oam-info-content {
    font-size: 13px;
    line-height: 1.5;
}

#oam-info-content .info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #eee;
}

#oam-info-content .info-row:last-child {
    border-bottom: none;
}

#oam-info-content .info-label {
    color: #666;
}

#oam-info-content .info-value {
    font-weight: 500;
    text-align: right;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#oam-info-content a {
    color: #00838f;
    text-decoration: none;
}

#oam-info-content a:hover {
    text-decoration: underline;
}

#oam-info-content .btn-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 12px;
    background: #00838f;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
}

#oam-info-content .btn-link:hover {
    background: #006064;
    text-decoration: none;
}

.oam-thumbnail-preview {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    border-radius: 4px;
    margin: 8px 0;
    border: 1px solid #eee;
}

/* OAM Loading Indicator */
#oam-loading {
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 131, 143, 0.9);
    color: white;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#oam-loading .oam-spinner {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

#oam-loading.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 600px) {
    #controls {
        width: calc(100% - 20px);
        max-width: 300px;
    }

    #info-panel {
        width: calc(100% - 20px);
        max-width: 320px;
        left: 10px;
        right: 10px;
    }

    .recent-projects-list {
        max-height: 150px;
    }
}
