/* ============================================
   CyberEdu - Threat Map Module Styles
   ============================================ */

/* -- Live Pulse Indicator -- */
.tm-pulse-live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #EF4444;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.tm-pulse-live .tm-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #EF4444;
    animation: tm-pulse-glow 1.5s ease-in-out infinite;
    box-shadow: 0 0 6px #EF4444, 0 0 12px rgba(239,68,68,0.5);
}

@keyframes tm-pulse-glow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.4); }
}

/* -- Stats Cards -- */
.tm-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.tm-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}
.tm-stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.tm-stat-card .tm-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}
.tm-stat-card .tm-stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
    font-family: 'JetBrains Mono', monospace;
}
.tm-stat-card .tm-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tm-stat-card .tm-stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 10px;
}
.tm-stat-change.up { background: rgba(239,68,68,0.1); color: #EF4444; }
.tm-stat-change.down { background: rgba(34,197,94,0.1); color: #22C55E; }

/* -- Map Container -- */
.tm-map-wrapper {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #050816;
}
.tm-map-container {
    width: 100%;
    height: 500px;
    position: relative;
    z-index: 1;
}
#threat-map-leaflet {
    width: 100%;
    height: 100%;
    background: #050816;
}

/* Leaflet Dark Theme Overrides */
.tm-dark-map .leaflet-tile-pane { filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7); }
.tm-dark-map .leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}
.tm-dark-map .leaflet-control-zoom a:hover { background: var(--bg-hover) !important; }
.tm-dark-map .leaflet-control-attribution { display: none !important; }

/* Map Legend */
.tm-map-legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 1000;
    background: rgba(5, 8, 22, 0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    backdrop-filter: blur(12px);
    min-width: 160px;
}
.tm-map-legend h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.tm-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.tm-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* -- Tab Navigation -- */
.tm-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}
.tm-tab {
    flex: 1;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
}
.tm-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.tm-tab.active {
    background: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.3);
}

/* -- Tab Content -- */
.tm-tab-content { display: none; animation: tm-fadeIn 0.3s ease; }
.tm-tab-content.active { display: block; }

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

/* -- Threat Cards Grid -- */
.tm-threats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}
.tm-threat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    overflow: hidden;
}
.tm-threat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}
.tm-threat-card.severity-critical::before { background: #EF4444; }
.tm-threat-card.severity-high::before { background: #F59E0B; }
.tm-threat-card.severity-medium::before { background: #00E5FF; }
.tm-threat-card.severity-low::before { background: #22C55E; }
.tm-threat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.tm-threat-card .tm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.tm-threat-card .tm-card-icon { font-size: 28px; }
.tm-threat-card .tm-card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tm-threat-card .tm-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tm-threat-card .tm-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.tm-threat-card .tm-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* -- Severity Badge -- */
.tm-severity-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tm-severity-badge.critical { background: rgba(239,68,68,0.15); color: #EF4444; border: 1px solid rgba(239,68,68,0.3); }
.tm-severity-badge.high { background: rgba(245,158,11,0.15); color: #F59E0B; border: 1px solid rgba(245,158,11,0.3); }
.tm-severity-badge.medium { background: rgba(0,229,255,0.15); color: #00E5FF; border: 1px solid rgba(0,229,255,0.3); }
.tm-severity-badge.low { background: rgba(34,197,94,0.15); color: #22C55E; border: 1px solid rgba(34,197,94,0.3); }

/* -- Live Feed -- */
.tm-feed-container {
    position: relative;
    max-height: 600px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.tm-feed-container::-webkit-scrollbar { width: 4px; }
.tm-feed-container::-webkit-scrollbar-track { background: transparent; }
.tm-feed-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.tm-feed-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
    animation: tm-slideIn 0.4s ease;
}
.tm-feed-item:hover { background: var(--bg-hover); }
.tm-feed-item.new-item { animation: tm-feed-flash 1s ease; }

@keyframes tm-slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes tm-feed-flash {
    0% { background: rgba(239,68,68,0.15); }
    100% { background: transparent; }
}

.tm-feed-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
    position: relative;
}
.tm-feed-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: tm-feed-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.tm-feed-dot.critical { background: #EF4444; }
.tm-feed-dot.critical::after { background: rgba(239,68,68,0.4); }
.tm-feed-dot.high { background: #F59E0B; }
.tm-feed-dot.high::after { background: rgba(245,158,11,0.4); }
.tm-feed-dot.medium { background: #00E5FF; }
.tm-feed-dot.medium::after { background: rgba(0,229,255,0.4); }
.tm-feed-dot.low { background: #22C55E; }
.tm-feed-dot.low::after { background: rgba(34,197,94,0.4); }

@keyframes tm-feed-ping {
    75%, 100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.tm-feed-content { flex: 1; min-width: 0; }
.tm-feed-desc { font-size: 13px; color: var(--text-primary); line-height: 1.4; margin-bottom: 6px; }
.tm-feed-meta { display: flex; gap: 16px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.tm-feed-meta span { display: flex; align-items: center; gap: 4px; }
.tm-feed-time { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* -- Type Distribution Bars -- */
.tm-type-bar {
    margin-bottom: 14px;
}
.tm-type-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
.tm-type-bar-label { font-size: 13px; font-weight: 600; }
.tm-type-bar-count { font-size: 12px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.tm-type-bar-track {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}
.tm-type-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
    background: linear-gradient(90deg, #EF4444, #F59E0B);
}
.tm-type-bar-sub { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

/* -- Country List -- */
.tm-country-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}
.tm-country-item:last-child { border-bottom: none; }
.tm-country-rank {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    width: 24px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}
.tm-country-name { flex: 1; font-size: 13px; font-weight: 500; }
.tm-country-bar {
    width: 100px;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}
.tm-country-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00E5FF, #A855F7);
    border-radius: 2px;
    transition: width 0.6s ease;
}
.tm-country-count {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    min-width: 50px;
    text-align: right;
}

/* -- Detail Page -- */
.tm-detail-header {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}
.tm-detail-main { flex: 1; min-width: 300px; }
.tm-detail-sidebar { width: 320px; flex-shrink: 0; }
.tm-detail-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.2;
}
.tm-detail-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 20px;
}
.tm-detail-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.tm-detail-meta-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
}
.tm-detail-meta-item .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.tm-detail-meta-item .value { font-size: 16px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }

/* -- IOC Table -- */
.tm-ioc-table {
    width: 100%;
    border-collapse: collapse;
}
.tm-ioc-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.tm-ioc-table td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.tm-ioc-table tr:hover td { background: var(--bg-hover); }
.tm-ioc-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: var(--bg-input);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: inline-block;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.2s ease;
}
.tm-ioc-value:hover { border-color: var(--primary); }

/* -- Timeline -- */
.tm-timeline { position: relative; padding-left: 24px; }
.tm-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.tm-timeline-item { position: relative; padding-bottom: 20px; }
.tm-timeline-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid;
}
.tm-timeline-dot.detected { background: #EF4444; border-color: #EF4444; }
.tm-timeline-dot.escalated { background: #F59E0B; border-color: #F59E0B; }
.tm-timeline-dot.mitigated { background: #F59E0B; border-color: #F59E0B; }
.tm-timeline-dot.resolved { background: #22C55E; border-color: #22C55E; }
.tm-timeline-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
}
.tm-timeline-time { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; font-family: 'JetBrains Mono', monospace; }
.tm-timeline-text { font-size: 13px; color: var(--text-primary); line-height: 1.5; }

/* -- Analytics Charts Area -- */
.tm-chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}
.tm-chart-container h3 {
    font-size: 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tm-mini-chart {
    width: 100%;
    height: 200px;
    position: relative;
}

/* -- Filter Bar -- */
.tm-filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}
.tm-filter-select, .tm-filter-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}
.tm-filter-select:focus, .tm-filter-input:focus { border-color: var(--primary); }
.tm-filter-select option { background: var(--bg-card); }

/* -- Top Bar -- */
.tm-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.tm-top-bar-left { display: flex; align-items: center; gap: 12px; }
.tm-top-bar-right { display: flex; align-items: center; gap: 10px; }

/* -- Search Box -- */
.tm-search-box {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 14px;
    gap: 8px;
    transition: border-color 0.2s ease;
}
.tm-search-box:focus-within { border-color: var(--primary); }
.tm-search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: 8px 0;
    outline: none;
    width: 200px;
}
.tm-search-box input::placeholder { color: var(--text-muted); }
.tm-search-box svg { color: var(--text-muted); flex-shrink: 0; }

/* -- Scan Line Effect -- */
.tm-scanline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0,229,255,0.3), transparent);
    animation: tm-scanline 4s linear infinite;
    z-index: 2;
    pointer-events: none;
}
@keyframes tm-scanline {
    0% { top: 0; }
    100% { top: 100%; }
}

/* -- Connection Lines (Canvas) -- */
#tm-attack-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 450;
    pointer-events: none;
}

/* -- Responsive -- */
@media (max-width: 1024px) {
    .tm-detail-header { flex-direction: column; }
    .tm-detail-sidebar { width: 100%; }
    .tm-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .tm-threats-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .tm-stats-grid { grid-template-columns: 1fr; }
    .tm-map-container { height: 300px; }
    .tm-tabs { flex-wrap: wrap; }
    .tm-tab { font-size: 12px; padding: 8px 12px; }
    .tm-filter-bar { flex-direction: column; align-items: stretch; }
}