/**
 * IIB GeoGlobe — Frontend CSS
 * Realistischer Globus mit Dark-Theme, Filter-Menue, Puls-Effekte
 */

:root {
    --globe-bg: #070b18;
    --panel-bg: #ffffff;
    --panel-border: #e2e8f0;
    --panel-text: #1e293b;
    --panel-text-muted: #64748b;
    --panel-accent: #2563eb;
    --panel-width: 400px;
}

/* ========================================================================
   Globe Container
   ======================================================================== */
#iib-globe-container {
    position: relative;
    overflow: hidden;
    background: var(--globe-bg) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#iib-globe-container * { box-sizing: border-box; }

#iib-globe-viz {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
}

#iib-globe-viz canvas {
    display: block;
}

/* ========================================================================
   Filter-Menue (links)
   ======================================================================== */
.iib-globe-filters {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
}

.iib-filter-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    background: rgba(10, 15, 30, 0.8);
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.iib-filter-toggle:hover {
    background: rgba(20, 30, 50, 0.9);
    color: #e2e8f0;
    border-color: rgba(255,255,255,0.3);
}

.iib-filter-panel {
    position: absolute;
    top: 48px;
    right: 0;
    width: 220px;
    padding: 14px;
    border-radius: 12px;
    background: rgba(10, 15, 30, 0.92);
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.25s ease;
    pointer-events: none;
}

.iib-filter-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.iib-filter-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    margin-bottom: 12px;
}

.iib-filter-group {
    margin-bottom: 12px;
}

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

.iib-filter-group-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    margin-bottom: 6px;
}

.iib-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    color: #cbd5e1;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.iib-filter-item:hover {
    color: #f1f5f9;
}

.iib-filter-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.iib-filter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ========================================================================
   Tooltip
   ======================================================================== */
.iib-globe-tooltip {
    position: absolute;
    z-index: 30;
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(10, 15, 30, 0.92);
    border: 1px solid rgba(255,255,255,0.12);
    color: #e2e8f0;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.iib-globe-tooltip.visible { opacity: 1; transform: translateY(0); }
.iib-globe-tooltip .tooltip-name { font-weight: 600; margin-right: 8px; }

.iib-globe-tooltip .tooltip-badge {
    display: inline-block; padding: 2px 8px;
    border-radius: 10px; font-size: 11px; font-weight: 600; vertical-align: middle;
}

.iib-globe-tooltip .badge-war  { background: rgba(239,68,68,0.25); color: #fca5a5; }
.iib-globe-tooltip .badge-risk { background: rgba(249,115,22,0.25); color: #fed7aa; }

/* ========================================================================
   Datenpanel (Slide-In rechts) — Helles Panel auf dunklem Globe
   ======================================================================== */
.iib-globe-panel {
    position: absolute;
    top: 0; right: 0;
    width: var(--panel-width);
    height: 100%;
    background: var(--panel-bg);
    border-left: 1px solid var(--panel-border);
    color: var(--panel-text);
    z-index: 25;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, visibility 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    box-shadow: none;
    visibility: hidden;
}

.iib-globe-panel.open {
    transform: translateX(0);
    box-shadow: -8px 0 30px rgba(0,0,0,0.3);
    visibility: visible;
}

.iib-globe-panel::-webkit-scrollbar { width: 5px; }
.iib-globe-panel::-webkit-scrollbar-track { background: transparent; }
.iib-globe-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.panel-header {
    position: sticky; top: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--panel-border);
    padding: 18px 20px; z-index: 1;
}

.panel-header-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.panel-country-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: #0f172a; }

.panel-close {
    width: 30px; height: 30px;
    border: 1px solid #e2e8f0; border-radius: 50%;
    background: transparent; color: #94a3b8; font-size: 16px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s ease; flex-shrink: 0;
}
.panel-close:hover { background: #f1f5f9; color: #475569; }

.panel-conflict-status {
    display: inline-block; padding: 3px 10px;
    border-radius: 10px; font-size: 12px; font-weight: 600; margin-bottom: 6px;
}
.panel-conflict-status.status-war    { background: rgba(239,68,68,0.10); color: #dc2626; border: 1px solid rgba(239,68,68,0.25); }
.panel-conflict-status.status-risk   { background: rgba(249,115,22,0.10); color: #ea580c; border: 1px solid rgba(249,115,22,0.25); }
.panel-conflict-status.status-normal { background: rgba(34,197,94,0.10);  color: #16a34a; border: 1px solid rgba(34,197,94,0.20); }

.panel-conflict-note { font-size: 13px; color: var(--panel-text-muted); line-height: 1.5; margin-top: 4px; }

.panel-section { padding: 14px 20px; border-bottom: 1px solid #f1f5f9; }
.panel-section:last-child { border-bottom: none; }

.panel-section-title {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--panel-accent); margin-bottom: 10px;
}

.panel-source { display: flex; justify-content: flex-end; margin-top: 8px; gap: 8px; }
.panel-source-link {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10px; color: #94a3b8; text-decoration: none;
    padding: 2px 6px; border: 1px solid #e2e8f0; border-radius: 4px;
    transition: all 0.15s ease; white-space: nowrap;
}
.panel-source-link:hover { color: var(--panel-accent); border-color: var(--panel-accent); }

.conflict-party { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.conflict-party-name { font-weight: 500; color: var(--panel-text); cursor: pointer; }
.conflict-party-name:hover { color: var(--panel-accent); text-decoration: underline; }
.conflict-party-role { color: var(--panel-text-muted); font-size: 12px; }

.econ-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; }
.econ-label { color: var(--panel-text-muted); }
.econ-value { font-weight: 600; display: flex; align-items: center; gap: 5px; color: #0f172a; }
.econ-trend-up { color: #16a34a; }
.econ-trend-down { color: #dc2626; }
.econ-trend-neutral { color: #d97706; }
.econ-timestamp { font-size: 11px; color: #94a3b8; }

.industry-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.industry-label { color: var(--panel-text); }
.industry-importance { color: var(--panel-accent); letter-spacing: 2px; }
.industry-gdp { color: var(--panel-text-muted); font-size: 12px; margin-left: 5px; }

.field-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.field-label { display: flex; align-items: center; gap: 6px; color: var(--panel-text); }
.field-value-true { color: #16a34a; font-weight: 600; }
.field-value-false { color: #cbd5e1; }

.commodity-category { margin-bottom: 10px; }
.commodity-category-title { font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 4px; }
.commodity-item { display: flex; justify-content: space-between; align-items: center; padding: 3px 0 3px 12px; font-size: 12px; color: var(--panel-text-muted); }
.commodity-dots { color: var(--panel-accent); letter-spacing: 2px; font-weight: 700; }
.commodity-info { font-size: 11px; color: #94a3b8; }

/* ========================================================================
   Popups (Chokepoints, Airports)
   ======================================================================== */
.iib-globe-popup {
    position: absolute; z-index: 30; width: 300px; padding: 16px;
    border-radius: 12px;
    background: rgba(10, 15, 30, 0.94);
    border: 1px solid rgba(255,255,255,0.12);
    color: #e2e8f0; font-size: 13px;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    pointer-events: auto;
}

.popup-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.popup-title { font-size: 15px; font-weight: 700; color: #f1f5f9; }
.popup-type { font-size: 11px; color: #64748b; margin-top: 2px; }
.popup-close { width: 24px; height: 24px; border: none; background: transparent; color: #64748b; font-size: 18px; cursor: pointer; line-height: 1; }
.popup-close:hover { color: #e2e8f0; }

.popup-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.popup-stat { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); padding: 8px; border-radius: 6px; }
.popup-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; margin-bottom: 2px; }
.popup-stat-value { font-size: 16px; font-weight: 700; color: #60a5fa; }
.popup-description { font-size: 12px; line-height: 1.5; color: #94a3b8; margin-top: 8px; }

.popup-risk { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; margin-top: 8px; }
.popup-risk.risk-1 { background: rgba(34,197,94,0.15); color: #86efac; }
.popup-risk.risk-2 { background: rgba(234,179,8,0.15); color: #fde68a; }
.popup-risk.risk-3 { background: rgba(239,68,68,0.15); color: #fca5a5; }

/* ========================================================================
   Ladebildschirm
   ======================================================================== */
.iib-globe-loader {
    position: absolute; inset: 0; z-index: 50;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    background: var(--globe-bg);
    pointer-events: none;
}

.iib-globe-loader.hidden { display: none; }

.iib-globe-loader-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(100, 116, 139, 0.3);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: iib-loader-spin 0.9s linear infinite;
}

.iib-globe-loader-text {
    font-size: 14px; font-weight: 500; color: #64748b; letter-spacing: 0.01em;
}

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

#iib-globe-viz.loading canvas { visibility: hidden !important; }
#iib-globe-container.loading .iib-globe-filters { opacity: 0; pointer-events: none; }

/* ========================================================================
   Responsive
   ======================================================================== */
@media (max-width: 768px) {
    .iib-globe-panel { width: 100%; }
    .iib-globe-filters { top: 8px; right: 8px; }
    .iib-filter-panel { width: 200px; }
    .iib-globe-popup { width: 260px; }
}

@media (max-width: 480px) {
    .panel-country-name { font-size: 17px; }
    .panel-section { padding: 12px 16px; }
}
