/**
 * GEOINT Dashboard v4.0 - UI/UX Enhancements
 * Advanced animations, Midnight Blue theme, improved responsiveness
 */

/* ===== MIDNIGHT BLUE THEME ===== */
[data-theme="midnight"] {
    --bg-primary: #020817;
    --bg-secondary: #0a1628;
    --bg-tertiary: #0d1f3c;
    --bg-card: rgba(10, 22, 40, 0.92);
    --bg-card-solid: #0a1628;
    --bg-hover: rgba(20, 40, 80, 0.4);
    --bg-glass: rgba(10, 22, 40, 0.85);
    --border: rgba(30, 58, 100, 0.5);
    --border-light: rgba(40, 70, 120, 0.4);
    --border-glow: rgba(56, 189, 248, 0.2);
    --text-primary: #e8f0fe;
    --text-secondary: #8baac4;
    --text-muted: #456b8a;
    --accent: #38bdf8;
    --accent-dim: rgba(56, 189, 248, 0.1);
    --accent2: #818cf8;
    --accent-gradient: linear-gradient(135deg, #38bdf8, #818cf8);
    --shadow: 0 4px 30px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 30px rgba(56, 189, 248, 0.06);
    --shadow-card: 0 4px 20px rgba(0,0,0,0.3), 0 0 40px rgba(56, 189, 248, 0.03);
}

[data-theme="midnight"] body { background: var(--bg-primary); }
[data-theme="midnight"] .topbar { background: rgba(10, 22, 40, 0.95); border-bottom: 1px solid var(--border); backdrop-filter: blur(16px); }
[data-theme="midnight"] .nav-tabs { background: rgba(10, 22, 40, 0.9); border-bottom: 1px solid var(--border); }
[data-theme="midnight"] .nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
[data-theme="midnight"] .panel { background: var(--bg-card); border-color: var(--border); }
[data-theme="midnight"] .stat-card { background: var(--bg-card); border-color: var(--border); }
[data-theme="midnight"] .status-bar { background: rgba(10, 22, 40, 0.95); border-top: 1px solid var(--border); }

/* ===== ADVANCED ANIMATIONS ===== */

/* Smooth page transition */
.tab-content {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.tab-content.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* Staggered card entry */
@keyframes fadeSlideIn {
    0% { opacity: 0; transform: translateY(16px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 0 rgba(0, 212, 255, 0); }
    50% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.1); }
}

@keyframes borderGlow {
    0%, 100% { border-color: rgba(0, 212, 255, 0.15); }
    50% { border-color: rgba(0, 212, 255, 0.4); }
}

@keyframes criticalPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes scanline {
    0% { top: -2px; }
    100% { top: 100%; }
}

/* Stat card hover effects */
.stat-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 212, 255, 0.05);
    border-color: var(--border-glow);
}

.stat-card:hover::before {
    opacity: 1;
}

/* Panel hover enhancement */
.panel {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel:hover {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2), var(--shadow-glow);
}

/* Critical items get animated border */
.feed-item.breaking {
    animation: criticalPulse 2s ease-in-out infinite;
    border-left: 3px solid #ef4444;
}

/* Toast entrance animation */
.toast {
    animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toastSlideIn {
    0% { opacity: 0; transform: translateX(100px) scale(0.8); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.leaving {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideOut {
    0% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(120px); }
}

/* ===== LOADING SKELETON ===== */
.skeleton {
    background: linear-gradient(90deg, rgba(30,41,59,0.3) 25%, rgba(30,41,59,0.5) 50%, rgba(30,41,59,0.3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.long { width: 95%; }

/* ===== ENHANCED NAV TABS ===== */
.nav-tab {
    position: relative;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent-gradient);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
}

.nav-tab:hover::after {
    width: 60%;
}

.nav-tab.active::after {
    width: 100%;
}

.nav-tab:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

/* Badge pulse for active items */
.badge.red {
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== ENHANCED MAP OVERLAY STYLES ===== */

/* Conflict zone pulsing effect */
.conflict-zone-pulse {
    animation: conflictPulse 3s ease-in-out infinite;
}

@keyframes conflictPulse {
    0%, 100% { stroke-opacity: 0.3; }
    50% { stroke-opacity: 0.7; }
}

.conflict-pulse-marker {
    animation: markerPulse 2s ease-in-out infinite;
}

@keyframes markerPulse {
    0%, 100% { r: 5; opacity: 0.8; }
    50% { r: 8; opacity: 0.4; }
}

/* Military base markers */
.military-marker {
    background: none !important;
    border: none !important;
}

.mil-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 9, 17, 0.85);
    border: 2px solid var(--mil-color, #3b82f6);
    border-radius: 4px;
    font-size: 12px;
    box-shadow: 0 0 12px color-mix(in srgb, var(--mil-color, #3b82f6) 30%, transparent);
    transition: all 0.3s;
}

.mil-icon:hover {
    transform: scale(1.3);
    box-shadow: 0 0 20px color-mix(in srgb, var(--mil-color, #3b82f6) 50%, transparent);
}

/* Trade route labels */
.route-label {
    background: none !important;
    border: none !important;
    text-align: center;
}

/* Trade route animation */
.trade-route-line {
    animation: dashMove 20s linear infinite;
}

@keyframes dashMove {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 100; }
}

/* ===== IMPROVED SCROLLBARS ===== */
.panel-body.scrollable::-webkit-scrollbar {
    width: 5px;
}

.panel-body.scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body.scrollable::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 10px;
}

.panel-body.scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

/* ===== GLASSMORPHISM ENHANCEMENTS ===== */
.topbar {
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
}

.modal {
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.modal-overlay.show .modal {
    animation: modalEnter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalEnter {
    0% { opacity: 0; transform: scale(0.9) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== ENHANCED BUTTON STYLES ===== */
.btn-primary {
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.btn-primary:hover::after {
    width: 200%;
    height: 200%;
}

.btn-primary:active {
    transform: scale(0.96);
}

/* ===== MAP PANEL ENHANCED ===== */
.map-panel {
    position: relative;
}

.map-panel .panel-header {
    position: relative;
    z-index: 2;
}

.map-hud-stats {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.map-hud-card {
    transition: all 0.3s;
}

.map-hud-card:hover {
    transform: scale(1.05);
    background: rgba(10, 15, 30, 0.9);
}

/* ===== IMPROVED CHART CONTAINERS ===== */
.chart-container {
    position: relative;
}

.chart-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--bg-card-solid));
    pointer-events: none;
    opacity: 0.5;
}

/* ===== RESPONSIVE ENHANCEMENTS ===== */

/* Large desktop */
@media (min-width: 1800px) {
    .stats-row { grid-template-columns: repeat(6, 1fr); }
    .dashboard-grid { gap: 18px; }
}

/* Standard desktop */
@media (max-width: 1400px) {
    .nav-tab { font-size: 11px; padding: 8px 10px; }
    .nav-tab .badge { font-size: 8px; padding: 1px 4px; }
}

/* Tablet landscape */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: 1fr !important; }
    .map-panel { grid-column: span 1 !important; }
    .stats-row { grid-template-columns: repeat(3, 1fr); }
    .nav-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .nav-tabs::-webkit-scrollbar { display: none; }
}

/* Tablet portrait */
@media (max-width: 900px) {
    .topbar-center { display: none; }
    .search-box { max-width: 180px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .analytics-stat-row { grid-template-columns: repeat(2, 1fr); }
    .stats-row-compact { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile */
@media (max-width: 640px) {
    .topbar { padding: 6px 10px; }
    .topbar-brand h1 { font-size: 14px; }
    .topbar-brand .subtitle { display: none; }
    .topbar-right { gap: 4px; }
    .btn-icon { width: 30px; height: 30px; font-size: 13px; }
    .search-box { display: none; }
    .stats-row { grid-template-columns: 1fr 1fr; gap: 6px; }
    .stat-card { padding: 10px; }
    .stat-value { font-size: 20px; }
    .panel { margin-bottom: 8px; }
    .panel-header { padding: 10px 12px; }
    .panel-body { padding: 8px; }
    .nav-tab { padding: 8px 8px; font-size: 10px; white-space: nowrap; }
    .main-content { padding: 6px; }
    .financial-ticker-strip { font-size: 10px; }
    .map-container { min-height: 300px; }
    .map-hud-stats { flex-direction: column; gap: 4px; }
    .map-legend-modern { flex-wrap: wrap; gap: 4px; }
    .osint-tools-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-grid-2 { grid-template-columns: 1fr; }
    .dashboard-grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ===== FOCUS VISIBLE ACCESSIBILITY ===== */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.nav-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.btn:focus-visible,
.btn-icon:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--accent-dim);
}

/* ===== SMOOTH SCROLL ===== */
.panel-body.scrollable {
    scroll-behavior: smooth;
}

/* ===== SELECTION STYLES ===== */
::selection {
    background: rgba(0, 212, 255, 0.3);
    color: #fff;
}

/* ===== ENHANCED THREAT BAR ===== */
.threat-bar {
    position: relative;
    overflow: hidden;
}

.threat-bar-fill {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.threat-bar-fill.critical::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15));
    animation: shimmer 2s infinite;
}

/* ===== NOTIFICATION PANEL ENHANCEMENT ===== */
.toast-container {
    z-index: 10000;
}

.toast {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 3px solid;
    transition: all 0.3s;
}

.toast.critical { border-left-color: #ef4444; }
.toast.high { border-left-color: #f97316; }
.toast.medium { border-left-color: #f59e0b; }
.toast.low { border-left-color: #10b981; }
.toast.info { border-left-color: #3b82f6; }
.toast.success { border-left-color: #10b981; }

/* ===== PRINT STYLES ===== */
@media print {
    .topbar, .nav-tabs, .status-bar, .toast-container,
    .shortcuts-panel, .modal-overlay, .btn, .btn-icon,
    .search-box, .sim-btn, .filter-bar { display: none !important; }
    .main-content { padding: 0; }
    .tab-content { display: block !important; opacity: 1 !important; transform: none !important; }
    .panel { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
    body { background: #fff; color: #000; }
}
