:root {
    --jkr-yellow: #FFD100;
    --jkr-black: #111111;
    --dpi-blue: #005A9C;
    --site-green: #2E8B57;
    --amber-discrepancy: #FF8C00;
    --red-risk: #D32F2F;
    
    --panel-bg: rgba(255, 255, 255, 0.92);
    --panel-border: rgba(0, 0, 0, 0.1);
    --text-main: #222222;
    --text-muted: #555555;
    
    --radius: 8px;
    --shadow: 0 8px 24px rgba(0,0,0,0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-panel > * {
    opacity: 0;
    animation: fadeInUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.animate-panel > *:nth-child(1) { animation-delay: 0.05s; }
.animate-panel > *:nth-child(2) { animation-delay: 0.1s; }
.animate-panel > *:nth-child(3) { animation-delay: 0.15s; }
.animate-panel > *:nth-child(4) { animation-delay: 0.2s; }
.animate-panel > *:nth-child(5) { animation-delay: 0.25s; }
.animate-panel > *:nth-child(6) { animation-delay: 0.3s; }

/* Header */
.app-header {
    background-color: #ffffff;
    border-bottom: 2px solid var(--jkr-yellow);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.logos {
    display: flex;
    gap: 12px;
}

.logo-placeholder {
    background-color: #eeeeee;
    border: 1px solid #cccccc;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.header-text h1 {
    font-size: 1.1rem;
    color: var(--jkr-black);
    margin-bottom: 4px;
}

.context-line {
    font-size: 0.8rem;
    color: var(--dpi-blue);
    font-weight: 600;
    margin-bottom: 2px;
}

.thesis {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Layout */
.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.report-nav {
    width: 250px;
    background-color: #ffffff;
    border-right: 1px solid var(--panel-border);
    overflow-y: auto;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.nav-btn {
    padding: 12px 20px;
    text-align: left;
    background: none;
    border: none;
    border-left: 4px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0;
    background-color: var(--dpi-blue);
    opacity: 0.05;
    transition: width 0.3s ease;
    z-index: -1;
}

.nav-btn:hover::before {
    width: 100%;
}

.nav-btn.active {
    border-left-color: var(--dpi-blue);
    color: var(--dpi-blue);
    font-weight: 600;
    transform: translateX(4px);
}

.nav-btn.active::before {
    width: 100%;
    opacity: 0.1;
}

.nav-badge {
    background-color: #e0e0e0;
    color: #555;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.nav-btn.active .nav-badge {
    background-color: var(--dpi-blue);
    color: white;
    transform: scale(1.1);
}

/* Content Area */
.content-area {
    flex: 1;
    position: relative;
    display: flex;
}

.map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Overlay Panels */
.overlay-panels {
    position: relative;
    z-index: 2;
    padding: 24px;
    display: flex;
    gap: 24px;
    width: 100%;
    pointer-events: none; /* Let clicks pass to map */
    justify-content: space-between;
}

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    pointer-events: auto; /* Enable clicks on panels */
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    transition: all 0.3s ease;
}

.panel:hover {
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}

.main-panel {
    width: 420px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.side-panels {
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Main Panel specific */
.section-badge {
    display: inline-block;
    background-color: var(--dpi-blue);
    color: white;
    width: 28px;
    height: 28px;
    text-align: center;
    line-height: 28px;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 4px;
    box-shadow: 0 2px 8px rgba(0,90,156,0.4);
}

#section-title {
    font-size: 1.5rem;
    color: var(--jkr-black);
    letter-spacing: -0.02em;
}

.section-ref {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
    background-color: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    align-self: flex-start;
}

.claim-box {
    background-color: #f8fafc;
    border-left: 4px solid var(--site-green);
    padding: 16px;
    border-radius: 0 8px 8px 0;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.fmav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.fmav-card {
    background-color: #ffffff;
    border: 1px solid #eef0f2;
    border-radius: var(--radius);
    padding: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fmav-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.fmav-card h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

.fmav-card p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #444;
}

.fmav-card.action h3 { color: var(--jkr-black); border-color: var(--jkr-yellow); border-bottom-width: 2px; }
.fmav-card.fact h3 { color: var(--site-green); border-color: var(--site-green); border-bottom-width: 2px; }

/* Basis Panel */
.basis-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
    letter-spacing: -0.01em;
}

.basis-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.basis-item {
    background: #fff;
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid #eef0f2;
    transition: all 0.2s ease;
}

.basis-item:hover {
    background: #fafbfc;
}

.basis-item h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin-bottom: 6px;
}

.basis-item p {
    font-size: 0.95rem;
    line-height: 1.4;
    color: #333;
}

.basis-item.consultant { border-left: 3px solid var(--dpi-blue); }
.basis-item.ice { border-left: 3px solid var(--site-green); }
.basis-item.discrepancy { 
    border-left: 4px solid var(--amber-discrepancy); 
    background-color: #fffaf0;
    border-color: #ffe4c4;
}
.basis-item.discrepancy h4 { color: #d97700; }

/* Metrics Panel */
.metrics-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-card {
    background: #fff;
    border: 1px solid #eef0f2;
    padding: 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    transition: transform 0.2s ease;
}

.metric-card:hover {
    transform: scale(1.02);
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--dpi-blue);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.metric-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* Custom Controls for Map */

/* Custom Basemap Switcher */
.custom-basemap-ctrl {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    gap: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.05);
}
.basemap-btn {
    border: none;
    background: transparent;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--text-muted);
}
.basemap-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-main);
}
.basemap-btn.active {
    background: var(--dpi-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 90, 156, 0.4);
}

/* Coordinate & Elevation Control */
.coord-elev-ctrl {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.05);
    color: var(--text-main);
    display: flex;
    gap: 16px;
    align-items: center;
}
.coord-elev-ctrl .divider {
    width: 1px;
    height: 14px;
    background-color: #ddd;
}
.coord-elev-ctrl span {
    display: flex;
    align-items: center;
    gap: 6px;
}
.coord-elev-ctrl strong {
    color: var(--dpi-blue);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

/* Leaflet Overrides */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.leaflet-control-geocoder {
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
    overflow: hidden;
}
.leaflet-control-geocoder-form input {
    font-family: inherit;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
    }
    
    .report-nav {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
        padding: 8px 0;
    }
    
    .nav-btn {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
        transform: none !important;
    }
    
    .nav-btn::before {
        display: none;
    }
    
    .nav-btn.active {
        border-bottom-color: var(--dpi-blue);
    }
    
    .overlay-panels {
        flex-direction: column;
        padding: 12px;
        overflow-y: auto;
        pointer-events: auto;
    }
    
    .panel {
        width: 100%;
        max-height: none;
    }

    .coord-elev-ctrl {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
    .coord-elev-ctrl .divider {
        display: none;
    }
}
