/**
 * OCServ Panel - Styles
 * استایل‌های پنل مدیریت
 */

/* ========== Local Fonts - Vazirmatn (no external requests) ========== */
@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/fonts/vazirmatn-300.ttf') format('truetype');
}

@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/vazirmatn-400.ttf') format('truetype');
}

@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/fonts/vazirmatn-500.ttf') format('truetype');
}

@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/fonts/vazirmatn-600.ttf') format('truetype');
}

@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/fonts/vazirmatn-700.ttf') format('truetype');
}

/* ========== CSS Variables ========== */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #0f0f14;
    --bg-secondary: #16161d;
    --bg-tertiary: #1c1c26;
    --bg-card: #1a1a24;
    --bg-hover: #22222e;

    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --border-color: #27272a;
    --border-light: #3f3f46;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* Sizing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-light: #cbd5e1;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* ========== Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    direction: rtl;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-secondary);
}

/* ========== App Layout ========== */
#app {
    display: flex;
    min-height: 100vh;
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition-normal);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar.collapsed .logo-text {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.nav-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.sidebar.collapsed .nav-item span:not(.nav-icon) {
    display: none;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.server-status.online .status-dot {
    background: var(--success);
}

.server-status.offline .status-dot {
    background: var(--danger);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: margin var(--transition-normal);
}

.main-content.expanded {
    margin-right: var(--sidebar-collapsed);
}

.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.moon-icon {
    display: none;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon {
    display: block;
}

.user-name {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.content-wrapper {
    padding: 24px;
}

/* ========== Cards ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ========== Stats Grid ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stats-grid.small {
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.stat-card.mini {
    flex-direction: column;
    text-align: center;
    gap: 8px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: white;
}

.stat-icon.users {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.stat-icon.online {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.stat-icon.traffic {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.stat-icon.connections {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ========== Dashboard Grid ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.chart-card .card-body {
    height: 300px;
}

/* ========== Tables ========== */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.loading-cell,
.empty-cell {
    text-align: center !important;
    padding: 40px !important;
    color: var(--text-muted);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon.danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.btn-icon.warning:hover {
    background: var(--warning);
    border-color: var(--warning);
    color: white;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-link {
    font-size: 0.85rem;
    color: var(--accent-primary);
}

/* Connection Badge */
.conn-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-right: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent-primary);
    color: white;
    border-radius: 9px;
}

/* Expandable IP List */
.user-ip-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-expand {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
}

.btn-expand:hover {
    text-decoration: underline;
}

.ip-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--border-color);
}

.ip-list.hidden {
    display: none;
}

.extra-ip {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Last Seen Badge */
.last-seen {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
    margin-top: 4px;
}

/* Modal Toggle */
.modal-toggle {
    margin-top: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.input-with-unit {
    display: flex;
    gap: 8px;
}

.input-with-unit input {
    flex: 1;
}

.input-with-unit select {
    width: 80px;
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    position: relative;
    transition: all var(--transition-fast);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    right: 2px;
    transition: all var(--transition-fast);
}

.toggle-label input:checked+.toggle-switch {
    background: var(--accent-primary);
}

.toggle-label input:checked+.toggle-switch::after {
    right: 22px;
}

/* New Toggle Container */
.toggle-container {
    display: flex;
    align-items: center;
    padding: 8px 0;
}

.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-wrapper input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    width: 48px;
    height: 26px;
    background: var(--border-color);
    border-radius: 13px;
    position: relative;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    right: 2px;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-wrapper input:checked+.toggle-slider {
    background: var(--success);
}

.toggle-wrapper input:checked+.toggle-slider::after {
    right: 24px;
}

.toggle-text {
    font-weight: 500;
    color: var(--text-primary);
}

/* ========== Search & Filters ========== */
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-box input {
    padding-right: 40px;
}

.filter-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.select-mini {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.page-ellipsis {
    color: var(--text-muted);
}

/* ========== Modal ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-content form {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ========== Toast ========== */
#toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.fade-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

.toast.success {
    border-right: 3px solid var(--success);
}

.toast.error {
    border-right: 3px solid var(--danger);
}

.toast.warning {
    border-right: 3px solid var(--warning);
}

.toast.info {
    border-right: 3px solid var(--info);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

/* ========== Status Badges ========== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.status-badge.online {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

/* ========== Progress Bar ========== */
.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width var(--transition-normal);
}

.progress-fill.warning {
    background: var(--warning);
}

.progress-fill.danger {
    background: var(--danger);
}

.traffic-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.traffic-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ========== User Cell ========== */
.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-avatar.online {
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--success);
}

.user-name {
    font-weight: 500;
}

.user-note {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ========== Action Buttons ========== */
.action-buttons {
    display: flex;
    gap: 8px;
}

/* ========== Online Users List ========== */
.online-users-list {
    max-height: 300px;
    overflow-y: auto;
}

.online-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.online-user-item:hover {
    background: var(--bg-hover);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-ip {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ========== Alerts ========== */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.alert-item.warning {
    border-right: 3px solid var(--warning);
}

.alert-item.critical {
    border-right: 3px solid var(--danger);
}

.alert-icon svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.alert-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.alert-user {
    font-weight: 500;
}

.alert-message {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ========== Badge ========== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--danger);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* ========== Empty State ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state.small {
    padding: 20px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ========== Loading ========== */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 20px auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== Settings ========== */
.server-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.server-status-big {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 500;
}

.status-indicator.online .status-dot {
    background: var(--success);
}

.status-indicator.offline .status-dot {
    background: var(--danger);
}

.control-buttons {
    display: flex;
    gap: 12px;
}

.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    background: var(--bg-hover);
}

.tab-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    gap: 24px;
}

.setting-info {
    flex: 1;
}

.setting-info label {
    font-weight: 500;
    font-family: monospace;
    color: var(--accent-primary);
}

.setting-description {
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.setting-input {
    min-width: 120px;
}

.setting-input input,
.setting-input select {
    min-width: 100px;
}

/* ========== Logs ========== */
.traffic-mini {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
}

.traffic-in {
    color: var(--success);
}

.traffic-out {
    color: var(--accent-primary);
}

/* ========== Recent Items ========== */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.recent-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.recent-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.bg-animation {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 50%);
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(var(--border-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.3;
}

.login-container {
    position: relative;
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    padding: 40px 40px 30px;
}

.login-logo {
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-muted);
}

.login-form {
    padding: 0 40px 40px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.input-wrapper input {
    padding-right: 44px;
}

.toggle-password {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.toggle-password svg {
    width: 18px;
    height: 18px;
}

.eye-off-icon {
    display: none;
}

.password-visible .eye-icon {
    display: none;
}

.password-visible .eye-off-icon {
    display: block;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-secondary);
}

.checkbox-label input {
    display: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.checkbox-label input:checked+.checkbox-custom {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-label input:checked+.checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 12px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    position: relative;
}

.login-btn.loading .btn-text {
    opacity: 0;
}

.login-btn.loading .btn-loader {
    display: block;
}

.btn-loader {
    display: none;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.login-footer {
    text-align: center;
    padding: 16px;
    background: var(--bg-tertiary);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-footer code {
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
}

/* ========== Helper Classes ========== */
.text-danger {
    color: var(--danger) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .menu-toggle {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: none;
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .server-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-buttons {
        flex-wrap: wrap;
    }
}

/* ========== Blocked IPs ========== */
.blocked-ips-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.blocked-ip-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border-right: 3px solid var(--danger);
}

.ip-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ip-address {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.ip-user {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.ip-remaining {
    font-size: 0.75rem;
    color: var(--warning);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ========== System Logs ========== */
.system-logs-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.log-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.log-tab {
    padding: 10px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.log-tab:hover {
    background: var(--bg-tertiary);
}

.log-tab.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.log-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.log-filter input {
    width: 300px;
    max-width: 100%;
}

.log-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.log-stats {
    display: flex;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.log-viewer {
    background: #0d1117;
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    height: 500px;
    overflow-y: auto;
    direction: ltr;
    text-align: left;
}

.log-line {
    padding: 2px 8px;
    border-radius: 2px;
    white-space: pre-wrap;
    word-break: break-all;
    color: #c9d1d9;
}

.log-line.log-error {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
}

.log-line.log-warning {
    background: rgba(210, 153, 34, 0.15);
    color: #d29922;
}

.log-line.log-info {
    color: #58a6ff;
}

.log-loading,
.log-empty,
.log-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 12px;
}

/* ========== Live Traffic Monitor ========== */
.live-traffic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 8px;
}

.live-user-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.live-user-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.live-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.2rem;
}

.live-user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.live-user-info strong {
    color: var(--text-primary);
}

.live-conn-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.live-status-dot {
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.live-speeds {
    display: flex;
    justify-content: space-around;
    margin-bottom: 12px;
}

.speed-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
}

.speed-item.download .speed-arrow {
    color: #22c55e;
}

.speed-item.upload .speed-arrow {
    color: #3b82f6;
}

.speed-value {
    color: var(--text-primary);
}

.live-traffic-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.traffic-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.3s ease;
}

.live-traffic-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.live-ips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.live-ip {
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-muted);
}

/* ========== Rules Page ========== */
.add-domain-form {
    margin-bottom: 16px;
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input {
    flex: 1;
}

.bulk-section {
    margin: 8px 0;
}

.bulk-section summary {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
}

.domain-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border-right: 3px solid var(--danger);
    transition: all var(--transition-fast);
}

.domain-item:hover {
    background: var(--bg-hover);
}

.domain-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.domain-name {
    font-weight: 500;
    font-family: monospace;
    direction: ltr;
}

.domain-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    direction: ltr;
}

/* ========== Groups Page ========== */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.group-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-fast);
}

.group-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.group-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.group-card-stats {
    display: flex;
    gap: 24px;
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
}

.group-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.group-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.group-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.group-domains-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.domain-tag {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-radius: 12px;
    font-size: 0.75rem;
    font-family: monospace;
    direction: ltr;
}

.domain-tag.more {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

/* Group Badge in Users Table */
.group-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    border-right: 3px solid;
}

/* Group Color Dot */
.group-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Group Rule Item */
.group-rule-item {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.group-rule-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-rule-header .badge {
    font-size: 0.7rem;
}

/* ========== Login Page Fix ========== */
.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    position: relative;
    margin-top: 8px;
}

/* System Resources CSS */
.sys-resources-wrapper {
    margin-bottom: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}
.sys-grid {
    display: flex;
    gap: 2rem;
    justify-content: space-around;
}
.sys-meter {
    text-align: center;
    flex: 1;
}
.sys-meter p {
    margin-top: 8px;
    font-weight: 600;
    color: var(--text-secondary);
}
.sys-meter small {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}
.sys-dial {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: conic-gradient(var(--accent-primary) var(--val), var(--bg-tertiary) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    position: relative;
    transition: background 0.3s ease;
}
.sys-dial::before {
    content: "";
    position: absolute;
    inset: 8px;
    background: var(--bg-card);
    border-radius: 50%;
}
.sys-dial span {
    position: relative;
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--text-primary);
}