/*
    Theme Name: Unified Dark Professional
    Author: Gemini
    Version: 3.0
    Description: A complete and unified dark theme inspired by modern UI designs.
*/

/* 1. New Unified Color Palette & Base Styles */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-header: #161b22;
    --bg-card: #21262d;
    --text-primary: #e6edf3;
    --text-muted: #7d8590;
    --border-subtle: #30363d;
    --accent-primary: #2ea043;
    --accent-primary-hover: #238636;
    --danger-primary: #da3633;
    --danger-secondary: rgba(218, 54, 51, 0.15);
    --radius: 8px;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Keyframes for animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

/* 2. Layout Styling */
.top-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1100;
    min-height: 64px;
}
.top-header .page-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.user-badge {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.btn-icon {
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius);
    transition: color 0.2s ease, background-color 0.2s ease;
}
.btn-icon:hover {
    color: var(--text-primary);
    background-color: var(--bg-card);
}

.sidebar-wrap {
    display: flex;
    min-height: calc(100vh - 64px);
}
.sidebar {
    background-color: var(--bg-secondary);
    width: 250px;
    flex-shrink: 0;
    padding: 1.5rem 1rem;
    border-left: 1px solid var(--border-subtle);
    overflow-y: auto;
}
.main-content {
    flex: 1;
    min-width: 0;
    padding: clamp(1rem, 2.5vw, 1.75rem);
    overflow-y: auto;
}
.admin-page .container-fluid {
    padding-left: 0;
    padding-right: 0;
}

/* 3. Sidebar Navigation */
.sidebar .brand h1 { font-size: 1.5rem; font-weight: 600; }
.sidebar .nav-link {
    color: var(--text-muted);
    border-radius: var(--radius);
    font-weight: 500;
    transition: all 0.2s ease;
}
.sidebar .nav-link:hover { background-color: var(--bg-card); color: var(--text-primary); }
.sidebar .nav-link.active { background-color: var(--accent-primary); color: #ffffff !important; font-weight: 600; }

/* 4. Card, Table, and General Components */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    color: var(--text-primary);
}
.card-header { background-color: transparent; border-bottom: 1px solid var(--border-subtle); font-weight: 600; }
.table { color: var(--text-primary); }
.table > :not(caption) > * > * { background-color: transparent; border-color: var(--border-subtle); }
.table thead th { color: var(--text-primary); font-weight: 600; font-size: 0.9rem; border-bottom: 2px solid var(--border-subtle); } /* Increased contrast */
.table-hover > tbody > tr:hover > * { color: var(--text-primary); background-color: var(--bg-secondary); }
.list-group-item {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

/* Soft Buttons */
.btn-soft-primary, .btn-soft-info, .btn-soft-danger {
    border: 1px solid var(--border-subtle);
}
.btn-soft-primary { background-color: rgba(46, 160, 67, 0.15); color: var(--accent-primary); }
.btn-soft-primary:hover { background-color: rgba(46, 160, 67, 0.25); border-color: var(--accent-primary); }
.btn-soft-info { background-color: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.btn-soft-info:hover { background-color: rgba(56, 189, 248, 0.25); border-color: #38bdf8; }
.btn-soft-danger { background-color: rgba(218, 54, 51, 0.15); color: var(--danger-primary); }
.btn-soft-danger:hover { background-color: rgba(218, 54, 51, 0.25); border-color: var(--danger-primary); }

/* 5. Buttons and Forms */
.btn { border-radius: var(--radius); font-weight: 600; border: 1px solid transparent; transition: all 0.2s ease-in-out; }
.btn-primary { background-color: var(--accent-primary); border-color: var(--accent-primary); color: #fff; }
.btn-primary:hover { background-color: var(--accent-primary-hover); border-color: var(--accent-primary-hover); color: #fff; }
.nav-tabs .nav-link { color: var(--text-muted); border-bottom-color: transparent; }
.nav-tabs .nav-link.active { color: var(--text-primary); background-color: var(--bg-card); border-color: var(--border-subtle); border-bottom-color: var(--bg-card); }
.form-control, .form-select {
    background-color: var(--bg-secondary); /* Changed from --bg-primary */
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
}
.form-control:focus, .form-select:focus { background-color: var(--bg-primary); border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(46, 160, 67, 0.3); }
.form-switch .form-check-input { width: 48px; height: 24px; background-color: var(--border-subtle); border-color: var(--border-subtle); }
.form-switch .form-check-input:checked { background-color: var(--accent-primary); border-color: var(--accent-primary); }

/* 6. Typography & Links */
h1, h2, h3, h4, h5, h6 { font-weight: 600; }
label { color: #9ca3af; font-weight: 500; margin-bottom: 0.5rem; }
.text-muted, .form-text {
    color: #9ca3af !important;
}
a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-primary-hover); }

/* Profile page layout */
.profile-page {
    max-width: 1200px;
}
.profile-avatar-card {
    height: 100%;
}
.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 20%, #22c55e, #0f172a);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    color: #e5e7eb;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.4);
}
.profile-avatar-initials {
    font-weight: 700;
}
.profile-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.text-primary { color: #3b82f6 !important; }
.text-success { color: #22c55e !important; }
.text-info { color: #0ea5e9 !important; }
.text-warning { color: #f97316 !important; }
.text-danger { color: #da3633 !important; }

/* 7. Alerts & Badges */
.alert { border-radius: var(--radius); border-width: 1px; border-style: solid; font-weight: 500; }
.alert-danger { color: var(--danger-primary); background-color: var(--danger-secondary); border-color: rgba(218, 54, 51, 0.3); }
.badge.bg-soft-secondary { background-color: var(--border-subtle); color: var(--text-muted); font-weight: 600; }
.text-success { color: var(--accent-primary) !important; }
.text-danger { color: var(--danger-primary) !important; }

/* 8. Animations & Dashboard Widgets */
.card, .stat-card-pro, .quick-access-card, .chart-card {
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
}
.row > [class*='col-']:nth-child(1) .card, .row > [class*='col-']:nth-child(1) .stat-card-pro, .row > [class*='col-']:nth-child(1) .quick-access-card { animation-delay: 0.1s; }
.row > [class*='col-']:nth-child(2) .card, .row > [class*='col-']:nth-child(2) .stat-card-pro, .row > [class*='col-']:nth-child(2) .quick-access-card { animation-delay: 0.2s; }
.row > [class*='col-']:nth-child(3) .card, .row > [class*='col-']:nth-child(3) .stat-card-pro, .row > [class*='col-']:nth-child(3) .quick-access-card { animation-delay: 0.3s; }
.row > [class*='col-']:nth-child(4) .card, .row > [class*='col-']:nth-child(4) .stat-card-pro, .row > [class*='col-']:nth-child(4) .quick-access-card { animation-delay: 0.4s; }
.row > [class*='col-']:nth-child(5) .card, .row > [class*='col-']:nth-child(5) .quick-access-card { animation-delay: 0.5s; }

.quick-access-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
.quick-access-card:hover {
    transform: translateY(-5px);
    background-color: var(--bg-secondary);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.quick-access-card .icon { color: var(--accent-primary); }
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.card-link:hover {
    color: inherit;
}

/* Stat cards (dashboard, financial reports, panel monitor) */
.stat-card-pro,
.stat-card-v2,
.stat-card.gradient-pink,
.stat-card.gradient-purple,
.stat-card.gradient-cyan,
.stat-card.gradient-orange {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.25rem;
    height: 100%;
    box-shadow: var(--shadow-card);
}
.stat-card-pro .stat-icon,
.stat-card-v2 .stat-icon,
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.stat-card-pro .stat-label,
.stat-card-v2 .stat-info h5,
.stat-card .card-title {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}
.stat-card-pro .stat-value,
.stat-card-v2 .stat-info p,
.stat-card .card-value {
    color: var(--text-primary);
    font-weight: 700;
    margin: 0;
}
.stat-card-v2 {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-card-v2 .stat-icon.icon-primary { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.stat-card-v2 .stat-icon.icon-success { background: rgba(34, 197, 94, 0.15); color: #22c55e; }

.bg-soft-primary { background-color: rgba(59, 130, 246, 0.12) !important; }
.bg-soft-success { background-color: rgba(34, 197, 94, 0.12) !important; }
.bg-soft-info { background-color: rgba(14, 165, 233, 0.12) !important; }
.bg-soft-warning { background-color: rgba(249, 115, 22, 0.12) !important; }
.bg-soft-danger { background-color: rgba(218, 54, 51, 0.12) !important; }

/* Legacy Bootstrap bright stat cards → unified dark */
.admin-page .card.text-white.bg-primary,
.admin-page .card.text-white.bg-success,
.admin-page .card.text-white.bg-info,
.admin-page .card.text-white.bg-warning,
.admin-page .card.text-white.bg-danger {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-subtle);
}
.admin-page .card.text-white .card-title {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.admin-page .card.text-white h2 {
    color: var(--text-primary);
}

.admin-page .card-header .card-title,
.admin-page .card-header h3.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
}
.admin-page .card-header h5.mb-0 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

/* Tables: neutralize Bootstrap light/dark table headers */
.admin-page .table thead.table-dark,
.admin-page .table thead.table-light,
.admin-page .table thead {
    background-color: var(--bg-secondary) !important;
}
.admin-page .table thead th {
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}
.admin-page .table tbody tr.table-light {
    --bs-table-bg: var(--bg-secondary);
    --bs-table-color: var(--text-primary);
}
.admin-page .btn-light {
    background-color: var(--bg-secondary);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}
.admin-page .btn-light:hover {
    background-color: var(--bg-card);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}
.admin-page .bg-light {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

.admin-page .page-title-box,
.admin-page .page-local-title {
    display: none;
}

.panel-monitor-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.panel-monitor-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
    animation: pulse-dot 2s infinite;
}
.status-dot.online { background: var(--accent-primary); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.error { background: var(--danger-primary); }
.status-dot.inactive { background: #d29922; }
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* 9. Login Page */
.login-card { background: var(--bg-card); border: 1px solid var(--border-subtle); }
.login-card h2 { background: none; -webkit-background-clip: unset; -webkit-text-fill-color: unset; background-clip: unset; color: var(--text-primary); }
.btn-login { background: var(--accent-primary); }

/* 9.5 Global Modal (popup) styling to match dark theme */
.modal-backdrop.show {
    opacity: 0.7;
}
.modal-content {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
}
.modal-header {
    border-bottom-color: rgba(148, 163, 184, 0.35);
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.12), transparent);
}
.modal-title {
    font-size: 0.95rem;
    font-weight: 600;
}
.modal-body {
    background-color: rgba(15, 23, 42, 0.9);
}
.modal-footer {
    border-top-color: rgba(148, 163, 184, 0.35);
    background-color: var(--bg-secondary);
}
.modal .form-control,
.modal .form-select {
    background-color: #020617;
}
.btn-close {
    filter: invert(80%);
}
.btn-close:focus {
    box-shadow: none;
}

/* 10. Representative Users – X-UI style table */
.card-xui {
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), transparent 55%),
                radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.1), transparent 55%),
                var(--bg-card);
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: var(--shadow-card);
}
.card-xui .card-header {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    border-bottom-color: rgba(148, 163, 184, 0.25);
}
.card-xui .card-header h5 {
    font-size: 0.98rem;
}
.card-xui .card-header .badge {
    border-radius: 999px;
    font-size: 0.72rem;
}

.table-xui {
    font-size: 0.85rem;
    border-collapse: separate;
    border-spacing: 0 6px;
}
.table-xui thead th {
    border-bottom-color: rgba(148, 163, 184, 0.35);
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.table-xui tbody tr {
    background-color: rgba(15, 23, 42, 0.8);
    transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.table-xui tbody tr:hover {
    background-color: rgba(30, 64, 175, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}
.table-xui tbody td {
    border-top: none;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
    vertical-align: middle;
}

.user-ident-xui {
    font-weight: 600;
    color: var(--text-primary);
}
.traffic-cell-xui {
    min-width: 220px;
}
.traffic-used-xui {
    display: inline-block;
    min-width: 70px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
}
.traffic-bar-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.15rem;
}
.progress-xui {
    flex: 1;
    height: 6px;
    background-color: #020617;
    border-radius: 999px;
    overflow: hidden;
}
.progress-xui .progress-bar {
    border-radius: 999px;
}
.traffic-limit {
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 40px;
    text-align: center;
}
.traffic-bar-unlimited {
    background: linear-gradient(90deg, #22c55e, #0ea5e9);
}

.date-cell-xui {
    white-space: nowrap;
    font-size: 0.8rem;
}
.date-cell-xui .date-relative {
    color: var(--text-muted);
}

.badge-xui {
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.72rem;
}

.badge-duration {
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
}
.badge-duration-inf {
    background-color: rgba(56, 189, 248, 0.16);
    color: #38bdf8;
}
.badge-duration-left {
    background-color: rgba(52, 211, 153, 0.16);
    color: #34d399;
}
.badge-duration-past {
    background-color: rgba(248, 113, 113, 0.18);
    color: #f87171;
}

.actions-xui {
    display: flex;
    gap: 0.3rem;
}
.btn-action-xui {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background-color: rgba(15, 23, 42, 0.8);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.16s ease;
}
.btn-action-xui:hover {
    color: #ffffff;
    border-color: var(--accent-primary);
    background-color: rgba(34, 197, 94, 0.16);
    transform: translateY(-1px);
}
.btn-action-xui.btn-del:hover {
    border-color: var(--danger-primary);
    background-color: var(--danger-secondary);
    color: var(--danger-primary);
}
.btn-action-xui.btn-qr i {
    color: #a855f7;
}
.btn-action-xui.btn-tg i {
    color: #0ea5e9;
}
.btn-action-xui.btn-edit i {
    color: #22c55e;
}
.btn-action-xui.btn-info i {
    color: #facc15;
}

/* Online users progress & status dots */
.xui-progress {
    height: 18px;
    background-color: rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    overflow: hidden;
}
.xui-progress .progress-bar {
    min-width: 2%;
    transition: width 0.3s ease;
}
.xui-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
}
.xui-dot.online { background: var(--accent-primary); }
.xui-dot.offline { background: var(--text-muted); }
.xui-dot.limit-exceeded { background: var(--danger-primary); }
.badge-validity { min-width: 3.5em; }
.badge-validity.infinite {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
}
.table-users td { vertical-align: middle; }
.traffic-mini { font-size: 0.85rem; }
