/* Block Detail Grid */
.block-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* 40/60 layout (LEAF-54 / LEAF-67): map on the left ~40%, info cards on
 * the right ~60%. The right column hosts a 2-col card grid, so each card
 * gets ~30% of the viewport instead of the 25% it had under the original
 * 50/50 split - enough headroom for variable name + value to fit on most
 * blocks without the horizontal scroll Faiz flagged on 2026-05-29. The
 * <=1200px breakpoint below collapses everything to a single column. */
.block-detail-grid.detail-5050 {
    grid-template-columns: 2fr 3fr;
    align-items: start;
}
.detail-5050 .detail-left {
    position: sticky;
    top: 1rem;
}
.detail-5050 .detail-right {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}
/* Tall spatial map on the left, filling the column height */
.detail-5050 .detail-card-map .detail-card-body {
    height: calc(100vh - 250px);
    min-height: 380px;
    padding-bottom: 1rem;
}
.detail-5050 .detail-card-map .mini-map {
    height: 100%;
}
/* Cluster cards (LEAF-53) fill the right panel and lay out in 2 columns */
.cluster-cards {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    align-content: start;
}

/* Detail Card */
.detail-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

.detail-card-header {
    background: var(--iwmi-dark-blue);
    color: white;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.detail-card-header span:first-child {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-card-header i {
    font-size: 1rem;
}

.header-right-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.block-gp-dropdown {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    max-width: 160px;
}

.block-gp-dropdown option {
    background: #28537D;
    color: white;
}

.detail-card-body {
    padding: 1rem;
    padding-bottom: 0;
    /* #17: keep a fixed-ish box but let long metric lists scroll vertically
     * with a visible scrollbar instead of being clipped. */
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Vertical and horizontal scroll area */
.detail-card-body .metrics-scroll-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: scroll;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(2, 151, 166, 0.3) transparent;
}

/* #17: show a visible vertical scrollbar on the wrapper; horizontal scroll
 * still handled by the separate .metrics-h-scroll bar below */
.detail-card-body .metrics-scroll-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 0;
}

.detail-card-body .metrics-scroll-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.detail-card-body .metrics-scroll-wrapper::-webkit-scrollbar-thumb {
    background: rgba(2, 151, 166, 0.3);
    border-radius: 2px;
}

/* Content with natural width */
.detail-card-body .metrics-content {
    min-width: max-content;
}

/* Horizontal scroll bar container - always at bottom of card */
.detail-card-body .metrics-h-scroll {
    height: 14px;
    padding: 3px 0;
    margin-top: auto;
    flex-shrink: 0;
    overflow-x: scroll;
    overflow-y: hidden;
    background: #f0f0f0;
    border-radius: 0 0 8px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--iwmi-teal) #e0e0e0;
    display: none; /* Hidden by default, shown by JS if needed */
}

.detail-card-body .metrics-h-scroll.visible {
    display: block;
}

.detail-card-body .metrics-h-scroll::-webkit-scrollbar {
    height: 8px;
}

.detail-card-body .metrics-h-scroll::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

.detail-card-body .metrics-h-scroll::-webkit-scrollbar-thumb {
    background: var(--iwmi-teal);
    border-radius: 4px;
}

.detail-card-body .metrics-h-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--iwmi-dark-blue);
}

/* Spacer element that matches content width */
.detail-card-body .metrics-h-scroll .scroll-spacer {
    height: 1px;
    background: transparent;
}

/* No scrollbar - remove extra space */
.detail-card-body .metrics-scroll-wrapper.no-h-scroll {
    padding-bottom: 1rem;
}

/* Mini Map */
.mini-map {
    height: 200px;
    border-radius: 8px;
    border: 1px solid var(--iwmi-light-grey);
}

/* Mini-map feasibility legend */
.mini-map-legend {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    border-radius: 6px;
    padding: 5px 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.6rem;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    display: flex;
    flex-wrap: wrap;
    gap: 3px 6px;
    max-width: 160px;
}
.mini-legend-title {
    width: 100%;
    font-weight: 600;
    font-size: 0.6rem;
    color: var(--iwmi-dark-blue);
    margin-bottom: 1px;
}
.mini-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #444;
    white-space: nowrap;
}
.mini-legend-item i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
}

/* GP Detail View */
.gp-basic-info {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--iwmi-light-grey);
}

.gp-info-item {
    padding: 0.25rem 0;
    font-size: 0.9rem;
    color: var(--iwmi-dark-blue);
}

.gp-info-item strong {
    color: #666;
    font-weight: 500;
}

/* Metric rows for detail views */
.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
    gap: 1rem;
    min-width: max-content;
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-row .metric-label {
    font-size: 0.85rem;
    color: #333;
    line-height: 1.3;
    /* #16: allow long variable names to wrap instead of forcing a wide row */
    white-space: normal;
    overflow-wrap: break-word;
    max-width: 220px;
}

.metric-row .metric-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--iwmi-dark-blue);
    text-align: right;
    white-space: nowrap;
}

/* Consistent font in metric items */
.metric-item {
    font-size: 0.85rem;
}

.metric-item .metric-label {
    font-size: 0.85rem;
}

.metric-item .metric-value {
    font-size: 0.85rem;
}

/* Metric Item in Detail Card */
.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 1rem;
    min-width: max-content;
}

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

.metric-item .metric-label {
    font-size: 0.85rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* #16: allow long variable names to wrap instead of forcing a wide row */
    white-space: normal;
    overflow-wrap: break-word;
    max-width: 220px;
}

.metric-item .metric-label i {
    color: var(--iwmi-teal);
    font-size: 0.9rem;
}

.metric-item .metric-value {
    font-weight: 600;
    color: var(--iwmi-dark-blue);
    font-size: 0.9rem;
    white-space: nowrap;
}

.metric-item .metric-unit {
    font-size: 0.75rem;
    color: #888;
    margin-left: 0.25rem;
}

/* ============================================
   Variable Infotip - Instant hover tooltip
   ============================================ */
[data-infotip] {
    cursor: default;
}

#infotip-el {
    position: fixed;
    background: #1e293b;
    color: #f1f5f9;
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.5;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    white-space: pre-line;
    max-width: 320px;
    min-width: 120px;
    width: max-content;
    pointer-events: none;
    opacity: 0;
    z-index: 99999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    transition: opacity 0.06s ease;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* ============================================
   Variable Map Toggle (inline in filters table)
   ============================================ */
.var-toggle-cell {
    width: 34px;
    text-align: center;
    padding: 0.3rem 0.2rem !important;
}

.var-map-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: rgba(255,255,255,0.08);
    border: 1.5px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    font-size: 0.8rem;
    border-radius: 50%;
    transition: all 0.18s ease;
    line-height: 1;
}

.var-map-toggle:hover {
    color: white;
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.4);
}

.var-map-toggle.active {
    color: white;
    background: var(--iwmi-green);
    border-color: var(--iwmi-green);
    box-shadow: 0 0 8px rgba(34, 173, 122, 0.5);
}

.var-map-toggle.active:hover {
    background: #1de27a;
    border-color: #1de27a;
    box-shadow: 0 0 10px rgba(34, 173, 122, 0.65);
}

/* Highlight the entire row when its variable is active on the map */
.filters-table tbody tr.var-row-active td {
    background: rgba(34, 173, 122, 0.18) !important;
    border-bottom-color: rgba(34, 173, 122, 0.25);
}

/* No Data State */
.no-data {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

