/* Root Variables & Colors */
:root {
    --bg-base: #060913;
    --bg-surface: rgba(13, 20, 38, 0.45);
    --bg-surface-hover: rgba(22, 33, 62, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 162, 255, 0.15);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-red: #ff4a5a;
    --accent-red-glow: rgba(255, 74, 90, 0.25);
    --accent-blue: #00a2ff;
    --accent-blue-glow: rgba(0, 162, 255, 0.25);
    --accent-yellow: #ffb800;
    --accent-yellow-glow: rgba(255, 184, 0, 0.25);
    
    --sidebar-width: 260px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Atmospheric Glows */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0, 162, 255, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    top: -100px;
    left: -100px;
    z-index: -1;
    pointer-events: none;
}

.bg-glow-secondary {
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 74, 90, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
    bottom: 10%;
    right: -100px;
    z-index: -1;
    pointer-events: none;
}

/* Utility Utilities */
.bg-glass {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    transition: all var(--transition-normal);
}

.bg-glass:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.text-glow {
    text-shadow: 0 0 12px var(--accent-blue);
}

.text-right {
    text-align: right;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(8, 12, 26, 0.85);
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: rgba(0, 162, 255, 0.1);
    border: 1px solid var(--accent-blue);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo i {
    font-size: 24px;
    color: var(--accent-blue);
}

.brand-info h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand-info span {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: 12px;
    transition: all var(--transition-fast);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--text-primary);
    background: rgba(0, 162, 255, 0.15);
    border: 1px solid rgba(0, 162, 255, 0.25);
    box-shadow: 0 0 15px rgba(0, 162, 255, 0.1);
}

.nav-item i {
    font-size: 20px;
}

.sidebar-footer {
    margin-top: auto;
}

.endpoint-info {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.endpoint-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.endpoint-url {
    display: block;
    font-family: monospace;
    font-size: 12px;
    color: var(--accent-blue);
    background: rgba(0, 162, 255, 0.05);
    padding: 6px;
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 162, 255, 0.1);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    max-width: calc(100vw - var(--sidebar-width));
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.header-search {
    position: relative;
    width: 320px;
}

.header-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
}

.header-search input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px 12px 42px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
}

.header-search input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(0, 162, 255, 0.1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.refresh-indicator {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.refresh-indicator:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    transform: rotate(45deg);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #0077ff 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 162, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 162, 255, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red) 0%, #d62839 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 74, 90, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 74, 90, 0.4);
}

.btn-copy {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    width: 100%;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-export {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-export:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Sections management */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* Metrics Dashboard Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.metric-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.metric-icon.val-danger {
    background: rgba(255, 74, 90, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(255, 74, 90, 0.2);
}

.metric-icon.val-warning {
    background: rgba(255, 184, 0, 0.1);
    color: var(--accent-yellow);
    border: 1px solid rgba(255, 184, 0, 0.2);
}

.metric-icon.val-info {
    background: rgba(0, 162, 255, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(0, 162, 255, 0.2);
}

.metric-details h3 {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.metric-glow {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    filter: blur(40px);
    right: -20px;
    top: -20px;
    opacity: 0.15;
    z-index: 0;
}

.glow-danger { background: var(--accent-red); }
.glow-warning { background: var(--accent-yellow); }
.glow-info { background: var(--accent-blue); }

/* Dashboard Grid for Charts */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.grid-col-2 {
    grid-column: span 2;
}

.chart-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.card-header {
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.card-header span {
    font-size: 12px;
    color: var(--text-muted);
}

.chart-container {
    position: relative;
    height: 240px;
    width: 100%;
}

/* Recent Bans & Table Panel */
.recent-bans-panel {
    padding: 24px;
    margin-bottom: 32px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.panel-title-area h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.panel-title-area p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Export Dropdown */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 200px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border-radius: 12px;
    z-index: 10;
    overflow: hidden;
}

.dropdown-content a {
    color: var(--text-secondary);
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.dropdown-content a:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

.export-dropdown:hover .dropdown-content {
    display: block;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: 12px;
}

.form-input {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.form-input:focus {
    border-color: var(--accent-blue);
}

select.form-input {
    cursor: pointer;
}

select.form-input option {
    background: #0f172a;
    color: var(--text-primary);
}

.records-counter {
    font-size: 13px;
    color: var(--text-muted);
}

/* Modern Data Table */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.ip-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.ip-table th {
    padding: 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ip-table td {
    padding: 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.ip-table tr:hover td {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.015);
}

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

.ip-table tr {
    cursor: pointer;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.badge-danger {
    background: rgba(255, 74, 90, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(255, 74, 90, 0.2);
}

.badge-date {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.flag-icon {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 6px;
    display: inline-block;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Loading & Empty states */
.table-loading {
    text-align: center;
    padding: 40px !important;
    color: var(--text-muted);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 12px;
}

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

/* Threat Locations Layout (Map Section) */
.map-view-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 180px);
    overflow: hidden;
}

.map-sidebar {
    padding: 24px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.map-sidebar h2 {
    font-size: 18px;
    margin-bottom: 6px;
}

.map-sidebar p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.threat-locations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.threat-location-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.threat-location-card:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--accent-blue);
}

.threat-location-card.active {
    background: rgba(0,162,255,0.05);
    border-color: var(--accent-blue);
}

.threat-location-card h4 {
    font-size: 14px;
    margin-bottom: 4px;
}

.threat-location-card span {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
}

.map-area-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#threat-map {
    width: 100%;
    height: 100%;
    border-radius: 0 16px 16px 0;
}

/* Forms (Ban IP Tool) */
.form-card {
    max-width: 600px;
    margin: 0 auto;
    padding: 32px;
}

.form-header {
    margin-bottom: 24px;
}

.form-header h2 {
    font-size: 22px;
    margin-bottom: 6px;
}

.form-header p {
    font-size: 14px;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group textarea, 
.form-group input {
    width: 100%;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Modals */
.modal-overlay,
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 6, 15, 0.7);
    backdrop-filter: blur(8px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.modal-overlay.active,
.drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.ban-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 440px;
    max-width: 90vw;
    padding: 28px;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-normal);
}

.ban-modal.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close,
.drawer-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.modal-close:hover,
.drawer-close:hover {
    color: var(--text-primary);
}

/* Details Drawer Sliding Panel */
.detail-drawer {
    position: fixed;
    right: -460px;
    top: 0;
    width: 440px;
    height: 100vh;
    z-index: 999;
    border-radius: 20px 0 0 20px;
    border-right: none;
    padding: 32px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: -10px 0 40px rgba(0,0,0,0.6);
    transition: right var(--transition-normal);
}

.detail-drawer.active {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.drawer-title-area h2 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.drawer-badges {
    display: flex;
    gap: 8px;
}

.drawer-map-container {
    height: 180px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

#drawer-map {
    width: 100%;
    height: 100%;
}

.drawer-section {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.drawer-section:last-of-type {
    border-bottom: none;
}

.drawer-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.drawer-section h3 i {
    font-size: 18px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.detail-item label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.detail-item p {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.ua-text {
    font-family: monospace;
    font-size: 12px !important;
    color: var(--text-secondary) !important;
    background: rgba(255,255,255,0.02);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    max-height: 80px;
    overflow-y: auto;
    word-break: break-all;
}

.drawer-actions {
    margin-top: auto;
    padding-top: 16px;
}

/* Leaflet Overrides for Dark Mode Map Styling */
.leaflet-container {
    background: #0d121f !important;
}

.leaflet-tile {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.leaflet-bar a {
    background-color: #1e293b !important;
    color: #fff !important;
    border-bottom-color: var(--border-color) !important;
}

.leaflet-bar a:hover {
    background-color: #334155 !important;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(0.95); opacity: 0.5; }
}

.pulse-red {
    animation: pulse 2s infinite;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive Styling */
@media(max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        margin-bottom: 16px;
    }
    
    .sidebar-footer {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 24px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .grid-col-2 {
        grid-column: span 1;
    }
    
    .map-view-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .map-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 250px;
    }
    
    #threat-map {
        height: 350px;
        border-radius: 0 0 16px 16px;
    }
}

@media(max-width: 640px) {
    .top-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .header-search {
        width: 100%;
    }
    
    .header-actions {
        justify-content: space-between;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .detail-drawer {
        width: 100%;
        right: -100%;
    }
}
