@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* --- DESIGN SYSTEM TOKENS --- */
:root {
    /* Color Palette */
    --bg-main: #0B0C0E;
    --bg-card: #141619;
    --bg-card-hover: #1C1E22;
    --bg-subtle: rgba(255, 255, 255, 0.02);
    --bg-hover-subtle: rgba(255, 255, 255, 0.01);
    --border-color: #272A30;
    --border-focus: #FF9933;
    
    /* Text Colors */
    --text-primary: #F4F4F5;
    --text-secondary: #9F9FAD;
    --text-muted: #5C5E69;
    
    /* Accents (Saffron Colors) */
    --saffron: #FF9933;
    --saffron-hover: #FFB366;
    --saffron-dark: #CC7A29;
    --saffron-glow: rgba(255, 153, 51, 0.15);
    --saffron-glow-heavy: rgba(255, 153, 51, 0.4);
    
    /* Semantic Colors */
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #EF4444;
    --info: #3B82F6;
    
    /* Fonts */
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;
    
    /* Border Radius & Transitions */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables Override */
body.light-theme {
    --bg-main: #F3F4F6;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F9FAFB;
    --bg-subtle: rgba(0, 0, 0, 0.02);
    --bg-hover-subtle: rgba(0, 0, 0, 0.015);
    --border-color: #E5E7EB;
    --border-focus: #D97706;
    
    /* Text Colors */
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    
    /* Accents (Saffron Colors - adjusted for contrast) */
    --saffron: #D97706;
    --saffron-hover: #F59E0B;
    --saffron-dark: #B45309;
    --saffron-glow: rgba(217, 119, 6, 0.08);
    --saffron-glow-heavy: rgba(217, 119, 6, 0.25);
    
    /* Semantic Colors */
    --success: #059669;
    --warning: #D97706;
    --danger: #DC2626;
    --info: #2563EB;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    letter-spacing: -0.01em;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--saffron);
}

/* --- APP LAYOUT --- */
.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.brand-icon {
    font-size: 1.75rem;
    color: var(--saffron);
    filter: drop-shadow(0 0 8px var(--saffron-glow-heavy));
}

.brand-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 40%, var(--saffron) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    font-size: 0.7rem;
    background: var(--saffron-glow);
    border: 1px solid var(--saffron);
    color: var(--saffron);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-weight: 600;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-fast);
}

.nav-item i {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.nav-item.active {
    border-left: 3px solid var(--saffron);
    padding-left: calc(1rem - 3px);
    background: linear-gradient(90deg, var(--saffron-glow), transparent);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

/* Main Content Wrapper */
.main-content {
    margin-left: 280px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 2rem 3rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 2rem;
}

.header-title h1 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

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

.search-container {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.5rem 0.4rem 1rem;
    width: 450px;
    transition: var(--transition-normal);
}

.search-container:focus-within {
    border-color: var(--saffron);
    box-shadow: 0 0 15px var(--saffron-glow);
}

.search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-input-wrapper i {
    color: var(--text-muted);
}

.search-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.95rem;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    background: var(--saffron);
    color: var(--bg-main);
    border: none;
    outline: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: var(--transition-fast);
}

.search-btn:hover {
    background: var(--saffron-hover);
    box-shadow: 0 0 10px rgba(255, 153, 51, 0.4);
}

/* --- TAB LAYOUTS --- */
.tab-content {
    display: none;
    animation: fadeIn var(--transition-normal);
}

.tab-content.active {
    display: block;
}

/* --- DASHBOARD VIEW --- */
.quick-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--saffron-dark);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 153, 51, 0.08);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--saffron);
    font-size: 1.25rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font-heading);
}

/* Dashboard Panel Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-col-2 {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Panel Design */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

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

.panel-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title i {
    color: var(--saffron);
}

.panel-action {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.panel-action:hover {
    color: var(--saffron);
}

/* Details List */
.details-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--bg-subtle);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-label i {
    width: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.detail-val {
    font-weight: 500;
    font-size: 0.95rem;
    text-align: right;
}

.detail-val.badge {
    background: var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.detail-val.saffron-text {
    color: var(--saffron);
    font-weight: 600;
}

/* Map Styling */
.map-container-wrapper {
    height: 380px;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Custom dark/light Leaflet filter to match Saffron and Gray theme */
.leaflet-container {
    background-color: var(--bg-main) !important;
    transition: filter var(--transition-normal);
}

body:not(.light-theme) .leaflet-container {
    filter: grayscale(100%) invert(95%) sepia(8%) brightness(90%) contrast(90%);
}

body.light-theme .leaflet-container {
    filter: grayscale(100%) brightness(102%) contrast(95%);
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-content {
    font-family: var(--font-body);
    font-size: 0.85rem;
}

/* Threat Card custom styles */
.threat-meter-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 0;
    gap: 0.75rem;
}

.threat-radial {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.threat-circle-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.threat-circle-val {
    fill: none;
    stroke: var(--success);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dasharray var(--transition-normal);
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.threat-score {
    position: absolute;
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.threat-score span {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.threat-label-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--success);
}

.threat-indicators-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    margin-top: 1rem;
}

.threat-ind-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    text-align: center;
}

.threat-ind-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.threat-ind-val {
    font-size: 0.85rem;
    font-weight: 600;
}

.threat-ind-val.yes {
    color: var(--danger);
}

.threat-ind-val.no {
    color: var(--success);
}

/* --- BULK LOOKUP VIEW --- */
.bulk-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
}

.bulk-input-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bulk-textarea {
    width: 100%;
    height: 300px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    transition: var(--transition-normal);
}

.bulk-textarea:focus {
    border-color: var(--saffron);
    box-shadow: 0 0 10px var(--saffron-glow);
}

.progress-bar-container {
    background: var(--border-color);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    display: none;
}

.progress-bar-fill {
    background: var(--saffron);
    height: 100%;
    width: 0%;
    transition: width 0.1s ease;
}

.bulk-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.bulk-results-panel {
    display: flex;
    flex-direction: column;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

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

.bulk-table th, .bulk-table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.bulk-table th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    font-family: var(--font-heading);
}

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

.bulk-table tbody tr:hover {
    background: var(--bg-hover-subtle);
}

/* --- NETWORK TOOLS / MY NETWORK --- */
.network-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.5rem;
}

.latency-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.latency-row {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.latency-host {
    display: flex;
    flex-direction: column;
}

.host-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.host-url {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.latency-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.latency-indicator {
    width: 80px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.latency-indicator-fill {
    background: var(--success);
    height: 100%;
    width: 0%;
    transition: width var(--transition-normal);
}

.latency-val {
    font-family: monospace;
    font-weight: 600;
    font-size: 0.9rem;
    width: 65px;
    text-align: right;
}

/* User Agent Parser widget */
.ua-box {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    word-break: break-all;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

/* --- HISTORY QUEUE --- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
}

.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-fast);
}

.history-item:hover {
    border-color: var(--saffron);
}

.history-info {
    display: flex;
    flex-direction: column;
}

.history-ip {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-loc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.history-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--saffron);
    border-color: var(--saffron);
}

.btn-icon.delete:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Empty placeholder state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
    gap: 1rem;
}

.empty-state i {
    font-size: 3rem;
}

/* --- ANIMATIONS & KEYFRAMES --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* Pulse animation for map pin locator */
.map-marker-pulse {
    width: 12px;
    height: 12px;
    background: var(--saffron);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--saffron);
    position: relative;
}

.map-marker-pulse::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid var(--saffron);
    border-radius: 50%;
    top: -8px;
    left: -8px;
    animation: markerPulse 1.5s infinite ease-out;
}

@keyframes markerPulse {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* Loading skeleton styles */
.skeleton {
    animation: skeleton-loading 1.5s infinite linear alternate;
    border-radius: 4px;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 6px;
    width: 100%;
    background-color: var(--border-color);
}

.skeleton-text-short {
    width: 60%;
}

@keyframes skeleton-loading {
    0% { background-color: var(--border-color); opacity: 0.6; }
    100% { background-color: #2E323A; opacity: 1; }
}

/* --- RESPONSIVE MEDIA QUERIES --- */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .bulk-container {
        grid-template-columns: 1fr;
    }
    
    .network-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .sidebar {
        width: 80px;
        padding: 2rem 0.5rem;
        align-items: center;
    }
    
    .brand-name, .brand-badge, .sidebar-footer, .nav-item span {
        display: none;
    }
    
    .brand-section {
        justify-content: center;
        margin-bottom: 2rem;
    }
    
    .nav-item {
        justify-content: center;
        padding: 1rem;
    }
    
    .main-content {
        margin-left: 80px;
        padding: 2rem;
    }
    
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .search-container {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .main-content {
        padding: 1rem;
    }
    
    .quick-stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .panel {
        padding: 1rem;
    }
}
