/* ============================================
   VPN Admin Panel — Dark Glassmorphism Theme
   ============================================ */

:root {
    --bg-primary: #0f0d1a;
    --bg-secondary: #1a1730;
    --bg-card: rgba(30, 27, 46, 0.7);
    --bg-card-hover: rgba(40, 36, 60, 0.8);
    --glass-border: rgba(167, 139, 250, 0.15);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    --text-primary: #f0eef6;
    --text-secondary: #9d95b8;
    --text-muted: #6b6280;

    --accent: #a78bfa;
    --accent-hover: #c4b5fd;
    --accent-dim: rgba(167, 139, 250, 0.15);

    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #60a5fa;

    --cpu-color: #a78bfa;
    --ram-color: #60a5fa;
    --disk-color: #34d399;
    --net-color: #f472b6;

    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 220px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

/* Background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 600px 400px at 20% 30%, rgba(109, 40, 217, 0.12), transparent),
        radial-gradient(ellipse 500px 350px at 80% 70%, rgba(96, 165, 250, 0.08), transparent),
        radial-gradient(ellipse 400px 300px at 50% 50%, rgba(167, 139, 250, 0.05), transparent);
    pointer-events: none;
    z-index: 0;
}

/* Glass */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
}

/* ===== SCREENS ===== */
.screen {
    display: none;
}

.screen.active {
    display: flex;
}

/* ===== LOGIN ===== */
#login-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    z-index: 1;
}

.login-card {
    padding: 48px 36px;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    margin-bottom: 16px;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: rgba(15, 13, 26, 0.5);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

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

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
    box-shadow: 0 4px 15px rgba(109, 40, 217, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 6px 20px rgba(109, 40, 217, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(167, 139, 250, 0.2);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.2);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--accent-dim);
}

.error-msg {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--radius-xs);
    color: var(--danger);
    font-size: 13px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* ===== APP LAYOUT ===== */
#app-screen {
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    border-radius: 0;
    border-right: 1px solid var(--glass-border);
    border-left: none;
    border-top: none;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 20px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 16px;
}

.sidebar-title {
    font-weight: 600;
    font-size: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-list {
    list-style: none;
    flex: 1;
}

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

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

.nav-item.active {
    color: var(--accent);
    background: var(--accent-dim);
}

.sidebar-footer {
    border-top: 1px solid var(--glass-border);
    padding-top: 12px;
    display: flex;
    justify-content: center;
}

/* ===== CONTENT ===== */
.content {
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    height: 100vh;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
}

/* Xray badge */
.xray-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.2);
    color: var(--success);
}

.xray-status.offline {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.2);
    color: var(--danger);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: blink 2s ease-in-out infinite;
}

.xray-status.offline .status-dot {
    background: var(--danger);
    animation: none;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.stats-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.stat-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpu-icon {
    background: rgba(167, 139, 250, 0.12);
    color: var(--cpu-color);
}

.ram-icon {
    background: rgba(96, 165, 250, 0.12);
    color: var(--ram-color);
}

.disk-icon {
    background: rgba(52, 211, 153, 0.12);
    color: var(--disk-color);
}

.uptime-icon {
    background: rgba(251, 191, 36, 0.12);
    color: var(--warning);
}

.net-icon {
    background: rgba(244, 114, 182, 0.12);
    color: var(--net-color);
}

.clients-icon {
    background: rgba(167, 139, 250, 0.12);
    color: var(--accent);
}

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

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
}

.stat-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0;
}

.cpu-bar {
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
}

.ram-bar {
    background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.disk-bar {
    background: linear-gradient(90deg, #059669, #34d399);
}

.net-stats {
    display: flex;
    gap: 20px;
    font-size: 15px;
}

.net-stats span {
    color: var(--text-secondary);
}

.net-stats b {
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== CLIENTS LIST ===== */
.clients-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.client-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    transition: var(--transition);
}

.client-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.client-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.client-name {
    font-size: 16px;
    font-weight: 600;
}

.client-id {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.client-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.client-actions {
    display: flex;
    gap: 8px;
}

/* ===== LOGS ===== */
.logs-container {
    padding: 20px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

#logs-content {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 440px;
    padding: 32px;
    animation: scaleIn 0.3s ease;
}

.modal-wide {
    max-width: 520px;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    font-size: 24px;
    line-height: 1;
}

/* Link modal */
.link-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.qr-container {
    padding: 16px;
    background: rgba(15, 13, 26, 0.6);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
}

.qr-container img {
    display: block;
    width: 200px;
    height: 200px;
    image-rendering: pixelated;
}

.link-text-container {
    width: 100%;
}

.link-code {
    display: block;
    padding: 14px;
    background: rgba(15, 13, 26, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--accent);
    word-break: break-all;
    margin-bottom: 12px;
    max-height: 100px;
    overflow-y: auto;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--glass-shadow);
    font-size: 14px;
    color: var(--text-primary);
    z-index: 300;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(167, 139, 250, 0.4);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        width: 64px;
        padding: 16px 8px;
    }

    .sidebar-title,
    .nav-item span {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-header {
        justify-content: center;
        padding: 8px 0 16px;
    }

    .content {
        margin-left: 64px;
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid.cols-2 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .content {
        padding: 16px 12px;
    }

    .modal-content {
        padding: 24px 20px;
    }
}

/* === Protocol Badges === */
.protocol-badges {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.protocol-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 16px;
    position: relative;
    transition: all 0.3s ease;
}

.protocol-badge svg {
    opacity: 0.8;
    flex-shrink: 0;
}

.protocol-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.protocol-name {
    font-weight: 600;
    font-size: 14px;
}

.protocol-status {
    font-size: 12px;
    opacity: 0.7;
}

.protocol-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    margin-left: auto;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    animation: pulse-dot 2s infinite;
}

.protocol-badge.offline .protocol-dot {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    animation: none;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.hysteria-accent {
    border-left: 3px solid #06b6d4;
}

.vless-accent {
    border-left: 3px solid #a78bfa;
}

/* === Tags === */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.hysteria-tag {
    background: rgba(6, 182, 212, 0.2);
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.vless-tag {
    background: rgba(167, 139, 250, 0.2);
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.clients-count-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

/* === Hysteria Button === */
.btn-hysteria {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: #fff;
    border: none;
}

.btn-hysteria:hover {
    background: linear-gradient(135deg, #22d3ee, #06b6d4);
    transform: translateY(-1px);
}

/* === Log Tabs === */
.logs-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 4px;
}

.logs-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.logs-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.logs-tab.active {
    background: rgba(167, 139, 250, 0.15);
    color: var(--accent);
    box-shadow: 0 2px 8px rgba(167, 139, 250, 0.1);
}

.logs-tab[data-log="hysteria"].active {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.1);
}

/* === IKEv2 + Jackett Accents === */
.ikev2-accent {
    border-left: 3px solid #10b981;
}

.jackett-accent {
    border-left: 3px solid #f97316;
}

.ikev2-tag {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.jackett-tag {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.tag-valid {
    background: rgba(52, 211, 153, 0.2);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.tag-revoked {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn-ikev2 {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border: none;
}

.btn-ikev2:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border: none;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.btn-config {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-config:hover {
    background: rgba(167, 139, 250, 0.15);
    color: var(--accent);
    border-color: rgba(167, 139, 250, 0.3);
}

/* === Info Card === */
.info-card {
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
}

.info-card h3 {
    margin: 0 0 16px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 120px;
    flex-shrink: 0;
}

.mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-all;
}

.copyable {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.copyable:hover {
    background: rgba(167, 139, 250, 0.15);
}

.copyable:active {
    background: rgba(167, 139, 250, 0.3);
}

/* === Logs Box (inline) === */
.logs-box {
    border-radius: 16px;
    padding: 20px 24px;
    border: 1px solid var(--glass-border);
}

.logs-box h3 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.client-status {
    margin-top: 4px;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    border-radius: 16px;
    opacity: 0.7;
}

.empty-state p {
    font-size: 15px;
}

@media (max-width: 768px) {
    .protocol-badges {
        grid-template-columns: 1fr;
    }
}