/* xNeog Dashboard — Unified Admin Design System */
/* Extracted from admin/allowlist.html + admin/dashboard.html */

:root {
    --primary: #007AFF;
    --primary-dark: #0056b3;
    --secondary: #34C759;
    --accent: #FF9500;
    --danger: #FF3B30;
    --purple: #AF52DE;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-bg-hover: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-border-hover: rgba(255, 255, 255, 0.2);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --sidebar-width: 260px;
    --header-height: 70px;
}

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

html {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%);
    color: var(--text-primary);
    -webkit-touch-callout: none;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(10, 10, 10, 0.95);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-logo .x { color: var(--primary); }

.sidebar-logo svg { width: 28px; height: 28px; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section { margin-bottom: 24px; }

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 8px 12px;
}

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

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

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item svg { width: 20px; height: 20px; }

.nav-item .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--glass-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--glass-bg);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-info:hover { background: var(--glass-bg-hover); }

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 12px; color: var(--text-muted); }

/* ============================================
   HEADER
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.header {
    height: var(--header-height);
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-left h1 { font-size: 20px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 18px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.show { display: block; }

/* Header buttons */
.header-btn {
    width: 40px;
    height: 40px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover { background: var(--glass-bg-hover); color: var(--text-primary); }
.header-btn svg { width: 20px; height: 20px; }

.logout-btn {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: 12px;
    color: var(--danger);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover { background: var(--danger); color: white; }

/* Status badge in header */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online { background: var(--secondary); box-shadow: 0 0 8px var(--secondary); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-dot.degraded { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
    padding: 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

.welcome-section { margin-bottom: 32px; }
.welcome-section h2 { font-size: 28px; font-weight: 600; margin-bottom: 8px; }
.welcome-section p { color: var(--text-secondary); font-size: 15px; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.btn-secondary:hover { background: var(--glass-bg-hover); }

.btn-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-danger:hover { background: var(--danger); color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

/* ============================================
   STAT CARDS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--glass-border-hover);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.blue { background: linear-gradient(135deg, var(--primary), #5856D6); color: white; }
.stat-icon.green { background: linear-gradient(135deg, var(--secondary), #30B0C7); color: white; }
.stat-icon.orange { background: linear-gradient(135deg, var(--accent), #FF2D55); color: white; }
.stat-icon.purple { background: linear-gradient(135deg, var(--purple), #5856D6); color: white; }

.stat-trend {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
}

.stat-trend.up { background: rgba(52, 199, 89, 0.15); color: var(--secondary); }
.stat-trend.down { background: rgba(255, 59, 48, 0.15); color: var(--danger); }

.stat-value { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

.stat-card-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card-value { font-size: 28px; font-weight: 700; }
.stat-card-value.blue { color: var(--primary); }
.stat-card-value.green { color: var(--secondary); }
.stat-card-value.purple { color: var(--purple); }
.stat-card-value.orange { color: var(--accent); }

/* ============================================
   CONTENT GRID
   ============================================ */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

/* ============================================
   SECTIONS / GLASS CARDS
   ============================================ */
.section-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
}

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

.section-title { font-size: 18px; font-weight: 600; }

.section-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
   FILTERS & SEARCH
   ============================================ */
.filters { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
}

.search-input:focus { outline: none; border-color: var(--primary); }
.search-input::placeholder { color: var(--text-muted); }

.filter-select {
    padding: 10px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
}

.filter-select:focus { outline: none; border-color: var(--primary); }
.filter-select option { background: #1a1a2e; color: var(--text-primary); }

/* ============================================
   TABLE
   ============================================ */
.table-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
}

.table-container table { width: 100%; border-collapse: collapse; }

.table-container th {
    text-align: left;
    padding: 14px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--glass-border);
}

.table-container td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.table-container tr:last-child td { border-bottom: none; }
.table-container tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ============================================
   BADGES & STATUS
   ============================================ */
.type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
}

.type-badge.person { background: rgba(0, 122, 255, 0.15); color: var(--primary); }
.type-badge.group { background: rgba(175, 82, 222, 0.15); color: var(--purple); }

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show { display: flex; }

.modal-content {
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 { font-size: 20px; }

.close-btn {
    width: 36px;
    height: 36px;
    background: var(--glass-bg);
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover { background: var(--glass-bg-hover); }

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

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

.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.modal-actions .btn { flex: 1; }

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    background: var(--secondary);
    color: white;
    border-radius: 12px;
    font-size: 14px;
    z-index: 2000;
    animation: slideUp 0.3s ease;
    display: none;
}

.toast.show { display: block; }
.toast.error { background: var(--danger); }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 16px;
}

.pagination button {
    padding: 8px 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.pagination button:hover { background: var(--glass-bg-hover); color: var(--text-primary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; fill: currentColor; }
.empty-state p { margin-top: 12px; }

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.5;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* ============================================
   LOADING
   ============================================ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 122, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.hidden { display: none !important; }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0, 122, 255, 0.35); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 122, 255, 0.5); }

/* ============================================
   RESPONSIVE — 900px (Tablet)
   ============================================ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
    .header { padding: 0 20px; }
    .page-content { padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content-grid { grid-template-columns: 1fr; }
    .table-container { overflow-x: auto; }
}

/* ============================================
   RESPONSIVE — 600px (Phone)
   ============================================ */
@media (max-width: 600px) {
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 24px; }
    .stat-card-value { font-size: 22px; }
    .filters { flex-direction: column; gap: 10px; }
    .search-input, .filter-select { width: 100%; min-width: 0; }
    .modal-content { max-width: 95vw; padding: 24px 20px; }
    .welcome-section h2 { font-size: 22px; }
    .section-title { font-size: 16px; }
}

/* ============================================
   RESPONSIVE — 480px (Small phone)
   ============================================ */
@media (max-width: 480px) {
    .page-content { padding: 12px; }
    .header { padding: 0 12px; }
    .header-left h1 { font-size: 16px; }
    .btn { min-height: 44px; font-size: 15px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }
    .stat-card-value { font-size: 20px; }
    .stat-icon { width: 40px; height: 40px; }
    .welcome-section h2 { font-size: 20px; }
    .welcome-section p { font-size: 14px; }
    .logout-btn { padding: 8px 14px; font-size: 13px; }
    .header-btn { width: 36px; height: 36px; }
}

/* ============================================
   RESPONSIVE — 375px (XS)
   ============================================ */
@media (max-width: 375px) {
    .page-content { padding: 10px; }
    .stats-grid { gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }
    .stat-icon { width: 40px; height: 40px; }
    .section-card { padding: 16px; }
}

/* ============================================
   PWA SAFE AREAS
   ============================================ */
@supports (padding: env(safe-area-inset-top)) {
    .header { padding-top: env(safe-area-inset-top); }
    .sidebar { padding-top: env(safe-area-inset-top); }
}
