/* ISCAN - Live Monitoring Dashboard Styles - Enhanced Edition */
:root {
    --bg-primary: #0a0e14;
    --bg-secondary: #12161e;
    --bg-card: #1a1f2b;
    --bg-input: #151920;
    --border-color: #2a3040;
    --text-primary: #e1e4eb;
    --text-secondary: #8b95a8;
    --accent: #4fc3f7;
    --accent2: #81c784;
    --accent3: #ff8a65;
    --danger: #ef5350;
    --success: #66bb6a;
    --warning: #ffa726;
    --sidebar-width: 240px;
    --topbar-height: 64px;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(79, 195, 247, 0.3); }
    50% { box-shadow: 0 0 20px rgba(79, 195, 247, 0.6); }
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes countUp {
    from { opacity: 0.5; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.fade-in { animation: fadeIn 0.5s ease forwards; }
.slide-up { animation: slideUp 0.6s ease forwards; }
.pulse { animation: pulse 2s infinite; }
.spin-on-click:active { animation: spin 0.6s ease; }

/* ─── Login Page ─── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at center, #1a1f2b 0%, #0a0e14 70%);
}
.login-container {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.6s ease;
}
.login-header { text-align: center; margin-bottom: 32px; }
.logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.logo-icon { font-size: 40px; }
.logo-text { font-family: var(--font-mono); font-size: 32px; font-weight: 700; color: var(--accent); letter-spacing: 4px; }
.login-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 8px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.form-group input {
    width: 100%; padding: 14px 16px; background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius); color: var(--text-primary); font-size: 15px; font-family: var(--font-sans);
    transition: var(--transition);
}
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.1); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 24px; border: none; border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer; transition: var(--transition); text-decoration: none; }
.btn-primary { background: var(--accent); color: #000; width: 100%; }
.btn-primary:hover { background: #81d4fa; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(79, 195, 247, 0.3); }
.btn-arrow { font-size: 18px; }
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }
.alert-error { background: rgba(239, 83, 80, 0.15); border: 1px solid rgba(239, 83, 80, 0.3); color: var(--danger); }
.login-footer { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; font-size: 13px; color: var(--text-secondary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(102, 187, 106, 0.6); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 8px rgba(239, 83, 80, 0.6); }

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

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transition: transform var(--transition);
}
.sidebar-header { padding: 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-color); }
.sidebar-header .logo-icon { font-size: 28px; }
.sidebar-header .logo-text { font-size: 22px; letter-spacing: 3px; }
.sidebar-badge {
    background: rgba(102, 187, 106, 0.2); color: var(--success); font-size: 10px; font-weight: 700;
    padding: 3px 8px; border-radius: 4px; letter-spacing: 1px; animation: pulse 2s infinite;
}
.sidebar-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius);
    color: var(--text-secondary); text-decoration: none; font-size: 13px; font-weight: 500;
    transition: var(--transition); position: relative; overflow: hidden;
}
.nav-item::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 0; background: var(--accent); border-radius: 0 3px 3px 0;
    transition: height var(--transition);
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.nav-item.active { background: rgba(79, 195, 247, 0.1); color: var(--accent); }
.nav-item.active::before { height: 60%; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; }
.user-info { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-avatar { font-size: 20px; }
.btn-logout { background: none; border: 1px solid var(--border-color); color: var(--text-secondary); width: 36px; height: 36px; border-radius: var(--radius); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ─── Main Content ─── */
.main-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; }
.topbar {
    height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px; border-bottom: 1px solid var(--border-color); background: var(--bg-secondary);
    position: sticky; top: 0; z-index: 50; backdrop-filter: blur(10px);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.page-title { font-size: 18px; font-weight: 600; transition: opacity 0.3s; }
.engine-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.last-update { font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono); }
.btn-refresh {
    background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-primary);
    width: 40px; height: 40px; border-radius: var(--radius); cursor: pointer; font-size: 20px;
    display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.btn-refresh:hover { border-color: var(--accent); color: var(--accent); }
.connection-indicator { font-size: 10px; color: var(--success); transition: color 0.3s; }
.connection-indicator.disconnected { color: var(--danger); }

/* ─── Sections ─── */
.section { display: none; padding: 32px; animation: fadeIn 0.4s ease; }
.section.active { display: block; }
.section-title { font-size: 20px; font-weight: 600; margin-bottom: 24px; color: var(--text-primary); display: flex; align-items: center; gap: 10px; }

/* ─── Badges ─── */
.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 4px; letter-spacing: 0.5px; }
.badge-live { background: rgba(102, 187, 106, 0.2); color: var(--success); animation: pulse 2s infinite; }
.badge-red { background: rgba(239, 83, 80, 0.2); color: var(--danger); }

/* ─── Stats Grid ─── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 32px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: 24px; transition: all 0.3s ease; position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    transition: left 0.5s;
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3); }
.stat-card:hover::after { left: 100%; }
.stat-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.stat-value { font-size: 36px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); transition: all 0.3s ease; }
.stat-value.highlight-red { color: var(--danger); }
.stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ─── Charts ─── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: 24px; height: 350px; display: flex; flex-direction: column;
    transition: border-color var(--transition);
}
.chart-card:hover { border-color: var(--accent); }
.chart-card canvas { flex: 1; max-height: 280px; }
.chart-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; color: var(--text-primary); }

/* ─── Timeline ─── */
.timeline-container { max-height: 600px; overflow-y: auto; }
.timeline-item {
    display: flex; align-items: flex-start; gap: 16px; padding: 14px 16px;
    border-left: 2px solid var(--border-color); margin-left: 12px; position: relative;
    transition: var(--transition); animation: fadeIn 0.4s ease;
}
.timeline-item:hover { border-left-color: var(--accent); background: rgba(79, 195, 247, 0.03); }
.timeline-item::before {
    content: ''; position: absolute; left: -6px; top: 20px; width: 10px; height: 10px;
    border-radius: 50%; background: var(--border-color); transition: background var(--transition);
}
.timeline-item:hover::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.timeline-time { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); min-width: 70px; }
.timeline-service { font-size: 12px; font-weight: 600; color: var(--accent); min-width: 80px; }
.timeline-ip { font-size: 12px; color: var(--text-primary); font-family: var(--font-mono); }
.timeline-detail { font-size: 11px; color: var(--text-secondary); flex: 1; word-break: break-all; }

/* ─── Tables ─── */
.table-container { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.table-container.glow-border { transition: box-shadow var(--transition); }
.table-container.glow-border:hover { box-shadow: 0 0 15px rgba(79, 195, 247, 0.1); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead { background: rgba(255, 255, 255, 0.03); position: sticky; top: 0; }
.data-table th { padding: 12px 16px; text-align: left; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; font-size: 11px; letter-spacing: 1px; border-bottom: 1px solid var(--border-color); }
.data-table td { padding: 10px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.03); font-family: var(--font-mono); font-size: 12px; }
.data-table tr { transition: background var(--transition); }
.data-table tr:hover td { background: rgba(79, 195, 247, 0.05); }

/* ─── Progress Bar ─── */
.progress-container { padding: 20px 0; }
.progress-bar-wrapper { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.progress-bar {
    flex: 1; height: 24px; background: var(--bg-primary); border-radius: 12px; overflow: hidden;
    border: 1px solid var(--border-color);
}
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent), #81d4fa);
    border-radius: 12px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; overflow: hidden;
}
.progress-fill::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}
.progress-text { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--accent); min-width: 60px; }
.progress-stats { display: flex; gap: 40px; }
.progress-stat-label { display: block; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.progress-stat-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; color: var(--text-primary); }

/* ─── System Cards ─── */
.sys-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.sys-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 24px; transition: var(--transition); }
.sys-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.sys-card h4 { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.sys-value { font-size: 20px; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); }

/* ─── Loading & States ─── */
.loading-spinner {
    text-align: center; padding: 40px; color: var(--text-secondary); font-size: 14px;
}
.loading-spinner::before {
    content: '⟳'; display: block; font-size: 32px; margin-bottom: 10px; animation: spin 1s linear infinite;
}
.no-data { text-align: center; padding: 40px; color: var(--text-secondary); font-size: 14px; }

/* ─── Logs ─── */
.log-controls { display: flex; gap: 12px; margin-bottom: 16px; }
.select-input { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius); color: var(--text-primary); padding: 10px 14px; font-size: 13px; font-family: var(--font-sans); cursor: pointer; transition: var(--transition); }
.select-input:focus { outline: none; border-color: var(--accent); }
.log-viewer {
    background: #0a0e14; border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: 20px; font-family: var(--font-mono); font-size: 11px; line-height: 1.7;
    color: var(--text-secondary); max-height: 600px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ─── Responsive ─── */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-grid { grid-template-columns: 1fr; }
    .sys-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
}

/* Copy button for target IPs */
.btn-copy {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    transition: all 0.2s;
}
.btn-copy:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(79, 195, 247, 0.1);
}

/* ─── Heatmap Map Container ─── */
.map-container {
    width: 100%;
    height: 550px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    position: relative;
}
.map-legend {
    font-family: var(--font-sans) !important;
}

/* ─── Enhanced Heatmap UI ─── */
.map-container-enhanced {
    width: 100%;
    height: 550px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    position: relative;
}

.heatmap-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.heatmap-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.heatmap-search {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 13px;
    width: 200px;
    transition: var(--transition);
}
.heatmap-search:focus {
    outline: none;
    border-color: var(--accent);
}

.heatmap-filter {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
}
.heatmap-filter:focus {
    outline: none;
    border-color: var(--accent);
}

.heatmap-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.heatmap-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}
.heatmap-btn.active {
    background: rgba(79, 195, 247, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.heatmap-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.heatmap-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    transition: var(--transition);
}
.heatmap-stat.critical .hs-value { color: var(--danger); }
.heatmap-stat.high .hs-value { color: var(--warning); }
.heatmap-stat.medium .hs-value { color: var(--accent); }
.heatmap-stat .hs-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.heatmap-stat .hs-value {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.section-subtitle {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    margin-top: 24px;
}
