/* ============================================================
   ADMIN COMMAND CENTER — Premium Neon Glassmorphism UI
   ============================================================ */

:root {
    --neon-cyan: #00ffff;
    --neon-purple: #bd00ff;
    --neon-blue: #0077ff;
    --neon-pink: #ff4d6a;
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-dim: #94a3b8;
}

/* --- Global Reset & Scrollbar --- */
#adminDashboard {
    background: radial-gradient(circle at top right, #0f172a, #020617);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    position: fixed; inset: 0;
    z-index: 100000; display: none; overflow-y: auto;
}
#adminDashboard.visible { display: block; }

#adminDashboard::-webkit-scrollbar { width: 6px; }
#adminDashboard::-webkit-scrollbar-track { background: #020617; }
#adminDashboard::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 10px; }

/* --- Password Security Overlay --- */
.admin-pw-overlay {
    position: fixed; inset: 0; background: rgba(1, 2, 5, 0.95);
    backdrop-filter: blur(25px); z-index: 110000;
    display: none; align-items: center; justify-content: center;
}
.admin-pw-overlay.visible { display: flex; }

.admin-pw-box {
    background: var(--glass-bg); border: 1px solid var(--neon-cyan);
    border-radius: 24px; padding: 45px 40px; width: 400px; max-width: 90%;
    text-align: center; box-shadow: 0 0 50px rgba(0, 255, 255, 0.15);
    animation: slideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes slideIn { from { transform: scale(0.9) translateY(40px); opacity: 0; } }

.pw-icon { font-size: 3.5rem; color: var(--neon-cyan); margin-bottom: 20px; filter: drop-shadow(0 0 15px var(--neon-cyan)); }
.admin-pw-box h3 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; letter-spacing: 2px; text-transform: uppercase; }
.admin-pw-box p { color: var(--text-dim); margin-bottom: 30px; font-size: 0.9rem; }

.pw-input-wrap { position: relative; margin-bottom: 30px; }
.admin-pw-box input {
    width: 100%; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--glass-border);
    border-radius: 15px; padding: 18px; color: #fff; font-size: 1.5rem;
    text-align: center; letter-spacing: 12px; outline: none; transition: 0.3s;
}
.admin-pw-box input:focus { border-color: var(--neon-cyan); box-shadow: 0 0 20px rgba(0, 255, 255, 0.2); }

/* --- Stats Architecture --- */
.admin-container { max-width: 1400px; margin: 0 auto; padding: 40px 25px; }

.admin-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 40px;
}
.header-title h1 { 
    font-size: 2.2rem; font-weight: 900; letter-spacing: -1px;
    background: linear-gradient(to right, var(--neon-cyan), var(--neon-purple));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px; margin-bottom: 40px;
}

.stat-card {
    background: var(--glass-bg); backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border); border-radius: 24px;
    padding: 30px; position: relative; overflow: hidden;
    transition: 0.4s;
}
.stat-card:hover { transform: translateY(-10px); border-color: var(--neon-cyan); box-shadow: 0 15px 40px rgba(0, 255, 255, 0.1); }

.stat-icon { font-size: 2.2rem; margin-bottom: 20px; color: var(--neon-cyan); }
.stat-value { font-size: 2.5rem; font-weight: 800; line-height: 1; margin-bottom: 8px; }
.stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; }

/* --- Panel Card --- */
.panel-card {
    background: var(--glass-bg); backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border); border-radius: 30px;
    padding: 30px; margin-bottom: 30px;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.panel-title { font-size: 1.2rem; font-weight: 700; color: var(--neon-cyan); display: flex; align-items: center; gap: 12px; }

/* --- Neon Table --- */
.table-wrap { overflow-x: auto; border-radius: 20px; border: 1px solid var(--glass-border); }
.admin-table { width: 100%; border-collapse: collapse; background: rgba(0, 0, 0, 0.2); }
.admin-table th { background: rgba(255, 255, 255, 0.03); padding: 18px 20px; text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); }
.admin-table td { padding: 18px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.02); font-size: 0.9rem; }
.admin-table tr:hover td { background: rgba(0, 255, 255, 0.03); }

/* --- Badges --- */
.badge { padding: 4px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge-active { background: rgba(0, 255, 128, 0.1); color: #00ff80; border: 1px solid rgba(0, 255, 128, 0.3); }
.badge-device { background: rgba(0, 119, 255, 0.1); color: var(--neon-blue); border: 1px solid rgba(0, 119, 255, 0.3); }

/* --- Buttons --- */
.btn-premium {
    background: linear-gradient(45deg, var(--neon-blue), var(--neon-cyan));
    color: #000; border: none; padding: 14px 28px; border-radius: 12px;
    font-weight: 800; cursor: pointer; transition: 0.3s;
}
.btn-premium:hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(0, 255, 255, 0.4); }
.btn-close { background: rgba(255, 77, 106, 0.1); color: var(--neon-pink); border: 1px solid rgba(255, 77, 106, 0.3); }

/* --- Map Layout --- */
.map-layout {
    display: flex; 
    flex-wrap: wrap;
    height: 500px;
    border-top: 1px solid var(--glass-border);
}

/* Search box spans full width on top */
.search-box-wrap {
    width: 100%;
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    order: 1;
    background: rgba(0, 0, 0, 0.2);
}
.search-box-wrap i { position: absolute; left: 25px; top: 50%; transform: translateY(-50%); color: var(--neon-cyan); }
.search-box-wrap input {
    width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border);
    border-radius: 10px; padding: 10px 10px 10px 35px; color: #fff; font-size: 0.85rem; outline: none;
}
.search-box-wrap input:focus { border-color: var(--neon-cyan); }

/* Map takes remaining space on the left */
#visitorMap { 
    flex: 1; 
    min-height: 0;
    height: auto !important;
    border-radius: 0; 
    border: none; 
    border-right: 1px solid var(--glass-border);
    background: #010205;
    order: 2;
}

/* Visitor list on the right */
.visitor-search-list { 
    width: 320px; 
    overflow-y: auto; 
    background: rgba(0, 0, 0, 0.3);
    order: 3;
}
.visitor-search-list::-webkit-scrollbar { width: 4px; }
.visitor-search-list::-webkit-scrollbar-thumb { background: var(--glass-border); }

.visitor-item {
    padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    transition: 0.2s;
}
.visitor-item:hover { background: rgba(0, 255, 255, 0.05); }
.visitor-item .city-name { font-weight: 600; color: var(--neon-cyan); font-size: 0.9rem; }
.visitor-item .visitor-meta { font-size: 0.7rem; color: var(--text-dim); }
.visitor-item i { color: var(--text-dim); font-size: 0.8rem; }
.visitor-item:hover i { color: var(--neon-cyan); }

.pulse-dot {
    width: 8px; height: 8px; background: #00ff80; border-radius: 50%;
    box-shadow: 0 0 10px #00ff80; margin-right: 10px;
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }

/* --- Enhanced Popup --- */
.custom-popup .leaflet-popup-content-wrapper {
    background: #0f172a; color: #fff; border-radius: 15px; padding: 0; overflow: hidden;
    border: 1px solid var(--neon-cyan); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.custom-popup .leaflet-popup-content { margin: 0; width: 100% !important; }
.custom-popup .leaflet-popup-tip { background: #0f172a; border: 1px solid var(--neon-cyan); }

.visitor-popup .popup-img {
    height: 120px; background-size: cover; background-position: center;
    position: relative; display: flex; align-items: flex-end; padding: 15px;
}
.visitor-popup .popup-img::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(15,23,42,1), transparent);
}
.visitor-popup .popup-city { position: relative; z-index: 1; font-weight: 800; font-size: 1.2rem; color: var(--neon-cyan); }

.visitor-popup .popup-details { padding: 15px; }
.detail-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.8rem; color: var(--text-dim); }
.detail-row i { color: var(--neon-blue); width: 16px; }

.btn-popup {
    width: 100%; margin-top: 10px; padding: 8px; border-radius: 8px;
    background: rgba(0, 255, 255, 0.1); color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan); font-weight: 700; font-size: 0.75rem;
    cursor: pointer; transition: 0.3s;
}
.btn-popup:hover { background: var(--neon-cyan); color: #000; }

/* --- Responsive --- */
@media (max-width: 1024px) {
    .map-layout { 
        flex-direction: column; 
        height: auto; 
    }
    .search-box-wrap {
        order: 1;
        width: 100%;
    }
    #visitorMap { 
        height: 350px !important; 
        order: 2;
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }
    .visitor-search-list {
        width: 100%;
        max-height: 300px;
        order: 3;
    }
}

@media (max-width: 768px) {
    .admin-container { padding: 25px 15px; }
    .admin-header { flex-direction: column; text-align: center; gap: 20px; }
    .admin-header h1 { font-size: 1.8rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 20px; border-radius: 18px; }
    .stat-icon { font-size: 1.8rem; margin-bottom: 12px; }
    .stat-value { font-size: 1.8rem; }
    .stat-label { font-size: 0.65rem; }
    .panel-card { padding: 20px; border-radius: 20px; }
    .admin-table th, .admin-table td { padding: 12px 15px; font-size: 0.8rem; }

    #visitorMap { height: 300px !important; }
    .visitor-search-list { max-height: 250px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .admin-header .btn-premium { padding: 10px 15px; font-size: 0.75rem; }
    .admin-header div { flex-wrap: wrap; justify-content: center; }
    #visitorMap { height: 250px !important; }
    .visitor-search-list { max-height: 200px; }
}
