/* ── GLOBAL RESET & VARIABLES ── */
:root {
    --bg-darker: #d8be9f;
    --bg-dark: #e6d3ba;
    --bg-card: #f9f1e6;
    --border-color: #c0a17f;
    --border-glow: rgba(45, 90, 39, 0.2);
    
    --primary: #2d5a27;
    --primary-hover: #1e3c1a;
    --primary-glow: rgba(45, 90, 39, 0.4);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    
    --danger: #b91c1c;
    --danger-bg: rgba(185, 28, 28, 0.15);
    --danger-glow: rgba(185, 28, 28, 0.45);
    
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.15);
    
    --text-main: #331917;
    --text-muted: #6e4c41;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Inter', sans-serif;
    
    --transition-speed: 0.3s;
}

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

body {
    background-color: var(--bg-darker);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow-x: hidden;
    line-height: 1.5;
    cursor: none;
}

/* ── MAGNETIC TARGET CURSOR ── */
#magnetic-cursor {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9999;
}

.cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    width: 6px;
    height: 6px;
    background-color: var(--primary);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    transition: width 0.2s ease, height 0.2s ease, background-color 0.25s ease, opacity 0.2s ease;
}

.cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--primary);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width 0.35s cubic-bezier(.25,.8,.25,1),
                height 0.35s cubic-bezier(.25,.8,.25,1),
                border-color 0.3s ease,
                border-radius 0.35s cubic-bezier(.25,.8,.25,1),
                border-width 0.25s ease,
                opacity 0.25s ease;
    opacity: 0.6;
}

/* Hover state: ring morphs into a rounded rectangle and expands */
.cursor-ring.cursor-hover {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border-color: var(--danger);
    border-width: 2px;
    opacity: 0.9;
}

/* Dot shrinks on hover for a snappy feel */
.cursor-dot.cursor-hover {
    width: 4px;
    height: 4px;
    background-color: var(--danger);
}

/* Image hover: ring morphs larger and rounder */
.cursor-ring.cursor-hover-img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border-color: var(--warning);
    border-width: 2px;
    opacity: 0.7;
}

.cursor-dot.cursor-hover-img {
    width: 3px;
    height: 3px;
    background-color: var(--warning);
    opacity: 0.9;
}


/* ── LAYOUT STRUCTURE ── */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ── HERO SECTION ── */
.hero-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-darker);
    z-index: 1;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 12vw;
    font-style: italic;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    z-index: 2;
    margin: 0;
    line-height: 1;
}

.corner-leaf {
    position: absolute;
    width: 35vmin;
    height: 35vmin;
    mix-blend-mode: multiply;
    z-index: 3;
    pointer-events: none;
}

.corner-leaf img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: leaf-wiggle 4s ease-in-out infinite alternate;
}

.top-left { top: -5%; left: -5%; transform: rotate(45deg); }
.top-right { top: -5%; right: -5%; transform: rotate(-45deg) scaleX(-1); }
.bottom-left { bottom: -5%; left: -5%; transform: rotate(135deg) scaleX(-1); }
.bottom-right { bottom: -5%; right: -5%; transform: rotate(-135deg); }

@keyframes leaf-wiggle {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(5deg); }
}

/* ── TOP NAV ── */
.top-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem 0;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(to bottom, var(--bg-darker) 70%, transparent);
}

.nav-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.85rem 1.5rem;
    border-radius: 2rem;
    cursor: none;
    transition: all var(--transition-speed);
}

.nav-btn:hover {
    background-color: var(--bg-dark);
}

.nav-btn.active {
    background-color: var(--primary);
    color: #f9f1e6;
    border-color: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* ── MAIN CONTENT STYLE ── */
.main-content {
    flex-grow: 1;
    margin-left: 0;
    padding: 2rem 5%;
    min-height: 100vh;
    position: relative;
    z-index: 10;
    background-color: var(--bg-darker);
    margin-top: 100vh; /* Pushed down by hero */
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.header-titles h2 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.5px;
}

.header-titles p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-stats {
    display: flex;
    gap: 1.5rem;
}

.kpi-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.kpi-val {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.kpi-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

/* ── CARDS & PANELS ── */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    box-shadow: 0 15px 35px rgba(51, 25, 23, 0.08);
    overflow: hidden;
}

.panel {
    padding: 2rem;
}

.panel h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.panel-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* ── TAB PANE TOGGLING ── */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn var(--transition-speed) ease;
}

/* ── TAB 1: PREDICTOR GRID ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Form Styles */
.predict-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group select {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-main);
    padding: 0.75rem 1rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-speed);
}

.form-group select:focus {
    border-color: var(--primary);
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.submit-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border: none;
    color: #0b0f19;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    padding: 0.9rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.submit-btn:active {
    transform: translateY(0);
}

/* Outcome Panel & Gauge */
.outcome-panel {
    display: flex;
    flex-direction: column;
}

.risk-gauge-container {
    display: flex;
    align-items: center;
    gap: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.risk-gauge {
    position: relative;
    width: 200px;
    height: 100px;
}

.gauge-svg {
    width: 100%;
    height: 100%;
}

.gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 10;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: var(--success);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 251.2; /* pi * 2 * R = 3.14 * 2 * 40 = 251.2 */
    stroke-dashoffset: 251.2; /* initial empty */
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1), stroke var(--transition-speed);
}

.gauge-center {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gauge-pct {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
}

.gauge-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

.risk-badge-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.risk-badge {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    padding: 0.25rem 1rem;
    border-radius: 0.5rem;
    background-color: rgba(255, 255, 255, 0.03);
    text-align: center;
    border: 1px solid var(--border-color);
}

.historical-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Ranger Actions Card */
.ranger-actions-card {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    flex-grow: 1;
    transition: all var(--transition-speed);
}

.ranger-actions-card.high-risk {
    border-color: rgba(244, 63, 94, 0.4);
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.05) 0%, rgba(244, 63, 94, 0.01) 100%);
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.05);
}

.ranger-actions-card.medium-risk {
    border-color: rgba(251, 191, 36, 0.4);
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.05) 0%, rgba(251, 191, 36, 0.01) 100%);
}

.actions-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.action-item {
    font-size: 0.85rem;
    position: relative;
    padding-left: 1.5rem;
}

.action-item::before {
    content: "•";
    position: absolute;
    left: 0.5rem;
    color: var(--primary);
    font-weight: bold;
}

.ranger-actions-card.high-risk .action-item::before {
    color: var(--danger);
}

.ranger-actions-card.medium-risk .action-item::before {
    color: var(--warning);
}

/* ── MOVEMENT PREDICTIONS TABLE ── */
.movement-card {
    padding: 1.75rem 2rem;
}

.movement-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}

.movement-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 0.25rem;
}

.info-badge {
    background-color: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.table-container {
    overflow-x: auto;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.movement-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.movement-table th {
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-muted);
}

.movement-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.movement-table tbody tr:last-child td {
    border-bottom: none;
}

.movement-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.01);
}

.empty-table {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 2rem !important;
}

.table-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
}

.table-badge.agree {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.table-badge.ml-only {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.agreement-explanation {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.01);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── TAB 2: HOTSPOT MAP LAYOUT ── */
.map-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.map-controls {
    padding: 1.5rem;
}

.filter-row {
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.filter-row .form-group {
    flex-grow: 1;
    min-width: 200px;
}

.map-btn {
    background-color: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.7rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.map-btn:hover {
    background-color: var(--primary);
    color: #0b0f19;
    box-shadow: 0 0 15px var(--primary-glow);
}

.legend-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
}

.legend-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.legend-items {
    display: flex;
    gap: 1.25rem;
}

.legend-item {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.red { background-color: #ff6b6b; }
.dot.green { background-color: #10b981; }
.dot.grey { background-color: #4b5563; }

.map-display {
    padding: 1.25rem;
    min-height: 680px;
    display: block;
}

#leaflet-map {
    width: 100%;
    height: 680px;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-darker);
}

#leaflet-map .leaflet-container {
    background-color: var(--bg-darker);
    border-radius: 0.75rem;
}

/* ── LEAFLET CUSTOM POPUP & CONTROL STYLES ── */
.leaflet-popup-content-wrapper {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
    font-family: var(--font-body) !important;
    padding: 0.25rem !important;
}

.leaflet-popup-tip {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.map-popup h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}

.map-popup p {
    font-size: 0.85rem;
    margin: 0.25rem 0;
    color: var(--text-muted);
}

.map-popup strong {
    color: var(--text-main);
}

.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-bar a {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border-bottom: 1px solid var(--border-color) !important;
    transition: background-color var(--transition-speed);
}

.leaflet-bar a:hover {
    background-color: var(--border-color) !important;
    color: var(--primary) !important;
}

.leaflet-bar a.leaflet-disabled {
    background-color: var(--bg-darker) !important;
    color: var(--text-muted) !important;
    opacity: 0.5;
}

.map-image-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    border-radius: 0.5rem;
    overflow: hidden;
    background-color: #111827;
}

.map-placeholder {
    padding: 6rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.dynamic-map-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    transition: opacity 0.5s ease-in-out;
}

.dynamic-map-img.hidden {
    opacity: 0;
}

/* ── TAB 3: GALLERY GRID ── */
.gallery-intro {
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.gallery-item {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.gallery-item h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.chart-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.gallery-item img {
    width: 100%;
    height: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    object-fit: contain;
    background-color: #00000020;
}

.side-images {
    display: flex;
    gap: 1rem;
    justify-content: space-around;
    flex-wrap: wrap;
}

.side-images img {
    width: 48%;
}

/* ── UTILITY STYLES ── */
.loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(11, 15, 25, 0.2);
    border-top: 2px solid #0b0f19;
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
}

.loader.hidden {
    display: none;
}

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

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}

@keyframes sway {
    0% { transform: rotate(-5deg); }
    100% { transform: rotate(5deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVENESS ── */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 1.5rem;
    }
    
    .nav-links {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .logo-area {
        margin-bottom: 1.5rem;
    }
    
    .ranger-status {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}
