/* Version: 1.0.1 (2026-05-01) - Added paired QR styles for AmneziaWG + Amnezia VPN native */
/* Version: 1.0.0 (2026-04-30) - Dark theme for Moskity VPN Panel (purple accent, anti-DPI vibes) */

/* ============================================================
   CSS Variables / palette
   ============================================================ */
:root {
    --bg:            #0a0a0f;
    --bg-card:       #15151c;
    --bg-card-hover: #1c1c26;
    --bg-input:      #0f0f15;
    --border:        #2a2a38;
    --border-strong: #3a3a4d;

    --text:        #e4e4e7;
    --text-muted:  #8a8a9a;
    --text-dim:    #5a5a6a;

    --accent:       #7c3aed;
    --accent-hover: #9333ea;
    --accent-glow:  rgba(124, 58, 237, 0.25);

    --success: #10b981;
    --warning: #f59e0b;
    --error:   #ef4444;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow:    0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 0 1px var(--border), 0 4px 16px var(--accent-glow);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans Armenian", sans-serif;
    --font-mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ============================================================
   Reset + Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

p { margin: 0 0 8px; }

pre, code, .mono { font-family: var(--font-mono); font-size: 13px; }
pre { white-space: pre-wrap; word-break: break-all; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

::selection { background: var(--accent); color: #fff; }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
    background: linear-gradient(180deg, #14141d 0%, #0e0e15 100%);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700;
}
.brand:hover { color: inherit; }
.brand-icon { font-size: 24px; filter: drop-shadow(0 0 6px var(--accent-glow)); }
.brand-name { font-size: 18px; }
.brand-sub { font-size: 11px; color: var(--text-muted); padding-left: 4px; border-left: 1px solid var(--border); margin-left: 4px; padding-left: 10px; }

.nav { display: flex; gap: 4px; flex: 1; margin-left: 24px; }
.nav-link {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.15s ease;
}
.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active {
    background: var(--accent-glow);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.user-block {
    display: flex; align-items: center; gap: 12px;
}
.user-name { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.role-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.role-badge.role-super { background: var(--accent); color: #fff; }
.role-badge.role-admin { background: var(--border-strong); color: var(--text); }

.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: flex; align-items: center;
}
.btn-logout:hover { background: var(--error); color: #fff; border-color: var(--error); }

.logout-form { margin: 0; }

/* ============================================================
   Flash messages
   ============================================================ */
.flash-container {
    max-width: 1400px;
    margin: 16px auto 0;
    padding: 0 24px;
    display: flex; flex-direction: column; gap: 8px;
}
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    animation: slideIn 0.25s ease;
}
.flash-success { border-color: var(--success); background: rgba(16, 185, 129, 0.08); }
.flash-warning { border-color: var(--warning); background: rgba(245, 158, 11, 0.08); }
.flash-error   { border-color: var(--error);   background: rgba(239, 68, 68, 0.08); }
.flash-icon    { font-size: 16px; flex-shrink: 0; }
.flash-text    { flex: 1; }
.flash-close   {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 20px; line-height: 1; padding: 0 4px;
}
.flash-close:hover { color: var(--text); }

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Main / Footer
   ============================================================ */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}
.footer {
    max-width: 1400px;
    margin: 32px auto 0;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    display: flex; gap: 8px;
}
.footer-sep   { color: var(--text-dim); }
.footer-server { font-family: var(--font-mono); }

/* ============================================================
   Login page
   ============================================================ */
.login-page {
    background: radial-gradient(circle at 30% 20%, rgba(124, 58, 237, 0.15), transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(124, 58, 237, 0.1), transparent 50%),
                var(--bg);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-glow);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo {
    font-size: 48px;
    filter: drop-shadow(0 0 12px var(--accent-glow));
    margin-bottom: 8px;
}
.login-title { font-size: 22px; margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--text-muted); margin: 0; }

.login-error {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; margin-bottom: 16px;
    border: 1px solid var(--error);
    background: rgba(239, 68, 68, 0.08);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-submit { margin-top: 8px; justify-content: center; }
.login-footer {
    text-align: center; margin-top: 20px;
    color: var(--text-dim); font-size: 11px;
}

/* ============================================================
   Sections / Cards / Empty state
   ============================================================ */
.section { margin-bottom: 28px; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 1px;
                 color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.subsection-title { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.counter {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon { font-size: 36px; margin-bottom: 8px; opacity: 0.6; }

/* ============================================================
   Forms
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--text-muted); }
.field-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}
.field-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-inline {
    display: flex; gap: 12px; align-items: flex-end;
    flex-wrap: wrap;
}
.field-inline { flex: 0 0 auto; min-width: 140px; }
.field-grow { flex: 1; min-width: 200px; }

select.field-input { cursor: pointer; }

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary, .btn-secondary, .btn-danger, .btn-mini {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-weight: 600;
    transition: all 0.15s ease;
    white-space: nowrap;
    display: inline-flex; align-items: center; gap: 6px;
}

.btn-primary {
    background: var(--accent); color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary {
    background: var(--bg-card-hover);
    border-color: var(--border);
    color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}
.btn-danger:hover { background: var(--error); color: #fff; }

.btn-danger-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
}
.btn-danger-icon:hover { background: var(--error); color: #fff; border-color: var(--error); }

.btn-mini {
    padding: 5px 10px;
    font-size: 12px;
    background: var(--bg-card-hover);
    border-color: var(--border);
    color: var(--text);
}
.btn-mini:hover { border-color: var(--accent); color: var(--accent); }

.btn-link {
    color: var(--accent);
    font-weight: 600;
}

.inline-form { margin: 0; display: inline-block; }

/* ============================================================
   Channels grid (dashboard)
   ============================================================ */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}
.channel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    transition: border-color 0.15s ease;
}
.channel-card:hover { border-color: var(--border-strong); }
.channel-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.channel-name { font-weight: 600; font-size: 14px; }
.channel-meta { display: flex; gap: 8px; font-size: 12px; color: var(--text-muted); }
.channel-port { font-family: var(--font-mono); }
.channel-mask::before { content: "·"; margin-right: 4px; }
.channel-peers-count {
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent);
}

/* ============================================================
   Status indicators
   ============================================================ */
.status-dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}
.status-on  { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-off { background: var(--error);   box-shadow: 0 0 6px rgba(239, 68, 68, 0.5); }
.status-empty { background: var(--text-dim); }

.status-pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.status-pill.status-on  { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-pill.status-off { background: rgba(239, 68, 68, 0.15);  color: var(--error); }

/* ============================================================
   Devices grid (dashboard)
   ============================================================ */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
    transition: all 0.15s ease;
}
.device-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}
.device-head { display: flex; gap: 10px; align-items: center; }
.device-icon { font-size: 28px; }
.device-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.device-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.device-name:hover { color: var(--accent); }
.device-owner { font-size: 11px; color: var(--text-muted); }

.device-channels { display: flex; gap: 6px; flex-wrap: wrap; }
.ch-pill {
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 600;
    border: 1px solid var(--border);
}
.ch-on  { background: rgba(16, 185, 129, 0.12); color: var(--success); border-color: var(--success); }
.ch-off { background: rgba(239, 68, 68, 0.08);  color: var(--error);   border-color: var(--border); }

.device-foot { display: flex; justify-content: space-between; align-items: center; }

/* ============================================================
   Device page (detail)
   ============================================================ */
.device-header { margin-bottom: 24px; }
.back-link {
    display: inline-block;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-size: 13px;
}
.back-link:hover { color: var(--accent); }
.device-header-main { display: flex; gap: 16px; align-items: flex-start; }
.device-header-icon { font-size: 48px; }
.device-header-title { font-size: 22px; margin-bottom: 4px; }
.device-header-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.meta-tag {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.device-header-desc { color: var(--text-muted); margin: 0; }

/* ----- Tabs (CSS-only via radio) ----- */
.tabs { margin-bottom: 24px; }
.tab-radio { display: none; }

.tab-headers {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    overflow-x: auto;
}
.tab-header {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 18px;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.15s ease;
    margin-bottom: -1px;
}
.tab-header:hover { color: var(--text); background: var(--bg-card); }
.tab-port { font-family: var(--font-mono); font-size: 11px; opacity: 0.7; }

.tab-panel { display: none; padding: 24px; background: var(--bg-card);
             border: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) var(--radius); }

#tab-awg0:checked ~ .tab-headers label[for="tab-awg0"],
#tab-awg1:checked ~ .tab-headers label[for="tab-awg1"],
#tab-awg2:checked ~ .tab-headers label[for="tab-awg2"],
#tab-xray:checked ~ .tab-headers label[for="tab-xray"] {
    background: var(--bg-card);
    color: var(--accent);
    border-color: var(--border);
    border-bottom-color: var(--bg-card);
}
#tab-awg0:checked ~ .tab-panel-awg0,
#tab-awg1:checked ~ .tab-panel-awg1,
#tab-awg2:checked ~ .tab-panel-awg2,
#tab-xray:checked ~ .tab-panel-xray {
    display: block;
}

/* ----- Channel detail (inside tab) ----- */
.channel-detail {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: 28px;
    align-items: flex-start;
}

/* QR block */
.qr-block { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.qr-frame {
    background: #fff;
    padding: 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: center;
}
.qr-frame-amnezia {
    box-shadow: var(--shadow), 0 0 0 2px var(--accent);
}
.qr-image { width: 100%; max-width: 280px; height: auto; display: block; }
.qr-download {
    color: var(--accent);
    font-size: 12px;
    font-family: var(--font-mono);
}
.qr-caption {
    text-align: center;
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
}
.qr-sub {
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-mono);
}

/* Pair of QR codes (AmneziaWG .conf + Amnezia VPN native) */
.qr-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    width: 100%;
}
.qr-pair-item {
    display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.qr-pair-item .qr-frame { padding: 10px; }
.qr-pair-item .qr-image { max-width: 180px; }

/* Config block */
.config-block { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.instruction h3 { margin-bottom: 8px; }
.instruction ol { padding-left: 20px; color: var(--text-muted); margin: 0; }
.instruction li { margin-bottom: 4px; }
.instruction code {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
}
.instruction-note {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.config-meta {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex; flex-direction: column; gap: 4px;
}
.meta-row {
    display: flex; justify-content: space-between; gap: 12px;
    font-size: 12px;
    padding: 3px 0;
}
.meta-key { color: var(--text-muted); }
.meta-val { color: var(--text); font-family: var(--font-mono); word-break: break-all; text-align: right; }

.config-text-wrap {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.config-text-wrap summary {
    padding: 10px 14px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    user-select: none;
}
.config-text-wrap summary:hover { color: var(--accent); }
.config-text-wrap[open] summary { border-bottom: 1px solid var(--border); }
.config-text {
    padding: 12px 14px;
    margin: 0;
    font-size: 12px;
    color: var(--text);
    max-height: 320px;
    overflow: auto;
}

.action-row { display: flex; gap: 8px; flex-wrap: wrap; }

.live-stats {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid var(--success);
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex; flex-direction: column; gap: 4px;
}

/* Danger zone */
.danger-zone {
    margin-top: 32px;
    padding: 16px;
    border: 1px solid var(--error);
    border-radius: var(--radius);
    background: rgba(239, 68, 68, 0.04);
}
.danger-zone h3 { color: var(--error); margin-bottom: 10px; font-size: 14px; }

/* ============================================================
   Tables (admins page)
   ============================================================ */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    background: var(--bg-input);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg-card-hover); }

.muted { color: var(--text-dim); font-size: 12px; }

/* Info box */
.info-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.info-box h4 { font-size: 13px; margin-bottom: 6px; }
.info-box p { color: var(--text-muted); margin-bottom: 8px; font-size: 13px; }
.code-snippet {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 0;
    font-size: 12px;
    color: var(--text);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .channel-detail { grid-template-columns: 1fr; }
    .qr-block { max-width: 480px; margin: 0 auto; }
}
@media (max-width: 520px) {
    .qr-pair { grid-template-columns: 1fr; }
    .qr-pair-item .qr-image { max-width: 240px; }
}
@media (max-width: 700px) {
    .topbar-inner { gap: 12px; padding: 10px 14px; }
    .nav { margin-left: 8px; }
    .nav-link { padding: 6px 10px; font-size: 13px; }
    .brand-sub { display: none; }
    .main-content { padding: 14px; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .field-inline { width: 100%; }
}
@media (max-width: 500px) {
    .nav-link span { display: none; }
    .user-name { display: none; }
}

/* ============================================================
   Profile page — compact info card
   ============================================================ */
.profile-card {
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 20px;
}
.profile-row {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px dashed var(--border);
}
.profile-row:last-child { border-bottom: none; }
.profile-key {
    color: var(--text-muted);
    min-width: 160px;
    flex-shrink: 0;
}
.profile-val {
    color: var(--text);
    word-break: break-all;
}