/* --- DETAIL SECTIONS & ROWS --- */
.detail-section {
    margin-bottom: 20px;
}

.detail-section h3 {
    color: #333;
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 5px;
    margin-bottom: 12px;
    font-size: 16px;
}

.detail-section h3.subheader-with-button {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 15px;
}

/* FIXED: Added gap: 12px and line-height so long labels never collide with text */
.detail-row {
    display: flex;
    margin-bottom: 8px;
    gap: 12px;
    align-items: baseline;
}

/* FIXED: Added flex-shrink: 0 and margin so wide titles stay separated from values */
.detail-label {
    font-weight: bold;
    min-width: 155px;
    max-width: 220px;
    flex-shrink: 0;
    color: #444;
    line-height: 1.45;
}

.detail-value {
    flex: 1;
    color: #333;
    line-height: 1.45;
    word-break: break-word;
}

.list-value {
    color: #333;
}

.number-value {
    color: #2c7fb8;
    font-weight: 500;
}

.peak-highlight-value {
    color: #d35400;
    font-weight: bold;
}

/* RESTORED: Green bold highlight for Major Crops and Flagship Species */
.crop-highlight-value {
    color: #1b5e20 !important;
    font-weight: 600 !important;
}

/* --- POI LISTS --- */
.poi-list {
    margin-top: 15px;
}

.poi-list h3 {
    color: #333;
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-size: 16px;
}

.poi-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.poi-items li {
    padding: 8px 12px;
    margin: 4px 0;
    background: #f0f7ff;
    border-left: 3px solid var(--primary-blue);
    border-radius: 4px;
    font-size: 14px;
    color: #333;
}

.poi-items li:nth-child(odd) {
    background: #f8fbff;
}

.poi-no-items {
    padding: 18px;
    text-align: center;
    color: #666;
    font-style: italic;
    background: #f4f6fa;
    border-radius: 8px;
    margin-top: 15px;
    line-height: 1.5;
}

/* --- SOIL TYPES & REGIONAL INTERACTIVE GRID --- */
.soil-interactive-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 15px 0 20px 0;
}

.soil-legend-card {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: white;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.soil-legend-card:hover {
    transform: translateX(4px);
    border-color: var(--primary-blue);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.soil-legend-card.active {
    border-color: #1a237e;
    background: #f0f4ff;
    box-shadow: 0 2px 8px rgba(26, 35, 126, 0.2);
}

.soil-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    margin-right: 14px;
    border: 1px solid rgba(0,0,0,0.25);
    flex-shrink: 0;
}

.soil-legend-info {
    display: flex;
    flex-direction: column;
}

.soil-legend-title {
    font-weight: bold;
    font-size: 14px;
    color: #222;
}

.soil-legend-subtitle {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* --- CHOROPLETH LEGEND --- */
.choropleth-legend {
    margin-top: 20px;
}

.choropleth-legend h3 {
    color: #333;
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 14px;
}

.legend-color-box {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 1px solid rgba(0,0,0,0.2);
}

.legend-color-box.dark_green { background-color: var(--color-dark-green); }
.legend-color-box.medium_green { background-color: var(--color-medium-green); }
.legend-color-box.yellow_green { background-color: var(--color-yellow-green); }
.legend-color-box.yellow { background-color: var(--color-yellow); }
.legend-color-box.orange { background-color: var(--color-orange); }
.legend-color-box.reddish_orange { background-color: var(--color-reddish-orange); }
.legend-color-box.red { background-color: var(--color-red); }
.legend-color-box.no_data { background-color: var(--color-no-data); }

.legend-label {
    color: #333;
}

/* --- COMPARISON MODE UI & TABLES --- */
.comparison-selection-area {
    text-align: center;
    padding: 20px 0;
}

.comparison-prompt {
    font-size: 1.2em;
    font-weight: 500;
    color: #333;
    margin-bottom: 20px;
}

.comparison-state-display {
    font-size: 1.1em;
    margin-bottom: 15px;
    background-color: #e9ecef;
    padding: 10px 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.deselect-state-btn {
    font-size: 1.2em;
    font-weight: bold;
    color: #dc3545;
    cursor: pointer;
    padding: 0 5px;
}

.comparison-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 25px;
    margin-bottom: 15px;
    padding-bottom: max(45px, calc(30px + env(safe-area-inset-bottom, 0px)));
    width: 100%;
}

#show-comparison-btn {
    background-color: #007bff;
    border-color: #007bff;
    color: white;
    padding: 8px 18px;
    font-size: 15px;
    border-radius: 20px;
    cursor: pointer;
}
#show-comparison-btn:hover {
    background-color: #0069d9;
}
#show-comparison-btn:disabled {
    background-color: #ced4da;
    border-color: #ced4da;
    cursor: not-allowed;
}

.comparison-table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 15px;
    -webkit-overflow-scrolling: touch;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; 
}

.comparison-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.comparison-table th {
    background-color: #e9ecef;
    font-size: 1.1em;
}

.comparison-table th, .comparison-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.comparison-table td:first-child {
    font-weight: bold;
    color: #495057;
    width: 1%; 
    white-space: nowrap; 
    background-color: #f8f9fa;
}

.comparison-table .section-header th {
    background-color: #007bff;
    color: white;
    text-align: center;
    font-size: 1.2em;
    padding: 8px;
}

.winner-cell {
    background-color: #d4edda !important;
    font-weight: bold;
}

/* --- DETAILS PANEL LOADING OVERLAY --- */
.details-loading-overlay {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(248, 248, 248, 0.8);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
    pointer-events: none;
}

.details-loading-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.details-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0;
    border-top: 5px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.bottom-nav-container {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: center;
    padding-bottom: max(45px, calc(30px + env(safe-area-inset-bottom, 0px)));
}

@media (orientation: portrait) and (max-width: 480px) {
    #details { 
        padding: 10px; 
        font-size: 14px; 
    }
    .detail-label { 
        min-width: 120px; 
        font-size: 13px; 
    }
    #details h2, .detail-section h3 { 
        font-size: 16px; 
    }
    .detail-section { 
        margin-bottom: 15px; 
    }
    .poi-items li {
        padding: 6px 10px;
        font-size: 13px;
    }
    .comparison-actions {
        padding-bottom: max(60px, calc(45px + env(safe-area-inset-bottom, 0px)));
    }
    .bottom-nav-container {
        padding-bottom: max(60px, calc(45px + env(safe-area-inset-bottom, 0px)));
    }
}