/* =====================================================
   NAHID IPTV — Admin Panel Styles
   ===================================================== */

:root {
    --bg: #0a0b0d;
    --bg-2: #111317;
    --bg-card: #1a1d24;
    --bg-hover: #222730;
    --primary: #3b82f6;
    --primary-h: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --teal: #14b8a6;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --border: #262b35;
    --sidebar-w: 240px;
    --topbar-h: 64px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* ========== LOADER ========== */
.app-loader {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 9000;
    transition: opacity .3s;
}
.app-loader.hidden { opacity: 0; pointer-events: none; visibility: hidden; display: flex !important; }
.loader-inner { text-align: center; }
.spinner {
    width: 44px; height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loader-text { font-size: 13px; color: var(--text-muted); }

/* ========== LOGIN ========== */
.login-screen {
    position: fixed; inset: 0;
    background: radial-gradient(ellipse at center, var(--bg-2) 0%, var(--bg) 100%);
    display: flex; align-items: center; justify-content: center;
    z-index: 8000;
}
.login-screen.hidden { display: none !important; }
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.login-brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 22px; font-weight: 700;
    color: var(--primary);
    margin-bottom: 24px;
    justify-content: center;
}
.login-card h1 { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

/* ========== ADMIN SHELL ========== */
.admin-shell {
    display: flex; width: 100vw; height: 100vh; overflow: hidden;
}
.admin-shell.hidden { display: none !important; }

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    flex-shrink: 0;
    z-index: 200;
    transition: transform .3s;
}
.sidebar-brand {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    font-size: 16px; font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}
.sidebar-brand i { font-size: 22px; }
.sidebar-nav {
    flex: 1; padding: 16px 10px;
    display: flex; flex-direction: column; gap: 4px;
    overflow-y: auto;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    background: none; border: none;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer; font-size: 13px; font-weight: 500;
    width: 100%; text-align: left;
    font-family: inherit;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-item i { font-size: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-hover); color: var(--text); border-left-color: var(--primary); }
.sidebar-footer {
    padding: 14px; border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px;
}
.admin-info {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-muted);
    overflow: hidden;
}
.admin-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: none; border: none;
    color: var(--danger); font-size: 13px; font-weight: 500;
    border-radius: 8px; cursor: pointer; font-family: inherit;
    width: 100%; transition: background .15s;
}
.logout-btn:hover { background: rgba(239,68,68,.1); }

/* ========== MAIN WRAP ========== */
.main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ========== TOPBAR ========== */
.topbar {
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
    display: flex; align-items: center;
    padding: 0 28px; gap: 16px;
    flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.realtime-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}
.realtime-dot.offline { background: var(--text-dim); box-shadow: none; }
.current-time { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.mobile-only { display: none !important; }

/* ========== CONTENT AREA ========== */
.content-area { flex: 1; overflow-y: auto; padding: 28px; }
.view { display: none; }
.view.active { display: block; }

/* ========== STAT CARDS ========== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(59,130,246,.15); color: #3b82f6; }
.stat-icon.green  { background: rgba(16,185,129,.15); color: #10b981; }
.stat-icon.orange { background: rgba(245,158,11,.15);  color: #f59e0b; }
.stat-icon.purple { background: rgba(139,92,246,.15);  color: #8b5cf6; }
.stat-icon.pink   { background: rgba(236,72,153,.15);  color: #ec4899; }
.stat-icon.teal   { background: rgba(20,184,166,.15);  color: #14b8a6; }
.stat-body { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }

/* ========== DASHBOARD PANELS ========== */
.dashboard-panels {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.panel-header h3 {
    font-size: 14px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.panel-header h3 i { color: var(--primary); }
.panel-body { padding: 20px; }
.recent-list { display: flex; flex-direction: column; }
.recent-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    font-size: 13px;
}
.recent-item:last-child { border-bottom: none; }
.recent-item .ri-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-hover); display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--text-muted); flex-shrink: 0; }
.recent-item .ri-main { flex: 1; min-width: 0; }
.recent-item .ri-email { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .ri-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.recent-item .ri-time { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ========== TOOLBAR ========== */
.view-toolbar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.search-bar {
    display: flex; align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 14px;
    gap: 8px; flex: 1; min-width: 200px;
}
.search-bar i { color: var(--text-dim); flex-shrink: 0; }
.search-bar input {
    background: none; border: none; outline: none;
    color: var(--text); font-size: 13px;
    padding: 10px 0; width: 100%; font-family: inherit;
}
.search-bar input::placeholder { color: var(--text-dim); }

/* ========== TABLE ========== */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 12px 16px;
    background: var(--bg-card);
    text-align: left; font-size: 11px; font-weight: 600;
    color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 13px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { background: var(--bg-card); transition: background .15s; }
.data-table tbody tr:hover { background: var(--bg-hover); }

/* ========== STATUS BADGES ========== */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
}
.badge-active   { background: rgba(16,185,129,.15); color: #10b981; }
.badge-suspended{ background: rgba(245,158,11,.15);  color: #f59e0b; }
.badge-banned   { background: rgba(239,68,68,.15);   color: #ef4444; }
.badge-premium  { background: rgba(139,92,246,.15);  color: #8b5cf6; }
.badge-free     { background: rgba(107,114,128,.15); color: #9ca3af; }
.badge-url      { background: rgba(59,130,246,.15);  color: #3b82f6; }
.badge-file     { background: rgba(16,185,129,.15);  color: #10b981; }

/* ========== ACTION BUTTONS ========== */
.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.action-btn {
    padding: 6px 10px; font-size: 11px; font-weight: 500;
    border-radius: 6px; cursor: pointer; border: 1px solid;
    font-family: inherit; transition: all .15s; display: inline-flex; align-items: center; gap: 4px;
}
.action-btn-edit    { background: rgba(59,130,246,.1);  border-color: rgba(59,130,246,.3);  color: #3b82f6; }
.action-btn-suspend { background: rgba(245,158,11,.1);  border-color: rgba(245,158,11,.3);  color: #f59e0b; }
.action-btn-ban     { background: rgba(239,68,68,.1);   border-color: rgba(239,68,68,.3);   color: #ef4444; }
.action-btn-activate{ background: rgba(16,185,129,.1);  border-color: rgba(16,185,129,.3);  color: #10b981; }
.action-btn-delete  { background: rgba(239,68,68,.1);   border-color: rgba(239,68,68,.3);   color: #ef4444; }
.action-btn-assign  { background: rgba(139,92,246,.1);  border-color: rgba(139,92,246,.3);  color: #8b5cf6; }
.action-btn-pw      { background: rgba(107,114,128,.1); border-color: rgba(107,114,128,.3); color: #9ca3af; }
.action-btn:hover   { filter: brightness(1.2); }

/* ========== PAGINATION ========== */
.pagination-bar {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 16px 0;
}
.page-btn {
    padding: 7px 12px; border-radius: 6px;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted); font-size: 13px; cursor: pointer;
    font-family: inherit; transition: all .15s;
}
.page-btn:hover { background: var(--bg-hover); color: var(--text); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 10px 20px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; border: none; font-family: inherit;
    transition: all .2s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ========== ICON BUTTON ========== */
.icon-btn {
    background: none; border: none; color: var(--text); font-size: 20px;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: var(--bg-hover); }

/* ========== FORMS ========== */
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-control {
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text);
    padding: 10px 14px; font-size: 13px; outline: none;
    font-family: inherit; width: 100%;
    transition: border-color .2s;
}
.form-control:focus { border-color: var(--primary); }
textarea.form-control { resize: vertical; line-height: 1.6; }
select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-card); }
.input-icon-wrap { position: relative; display: flex; align-items: center; }
.input-icon-wrap i { position: absolute; left: 14px; color: var(--text-dim); pointer-events: none; }
.input-icon-wrap input {
    width: 100%; padding: 11px 12px 11px 40px;
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 14px;
    outline: none; font-family: inherit; transition: border-color .2s;
}
.input-icon-wrap input:focus { border-color: var(--primary); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.help-text { font-size: 11px; color: var(--text-dim); line-height: 1.5; margin-top: 4px; }
.required { color: var(--danger); }

/* ========== TOGGLE SWITCH ========== */
.toggle-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { display: none; }
.slider {
    position: absolute; inset: 0;
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 11px; transition: background .2s;
}
.slider::after {
    content: ''; position: absolute;
    width: 16px; height: 16px; background: var(--text-dim);
    border-radius: 50%; top: 2px; left: 2px; transition: transform .2s, background .2s;
}
.toggle-switch input:checked + .slider { background: var(--primary); border-color: var(--primary); }
.toggle-switch input:checked + .slider::after { transform: translateX(18px); background: #fff; }

/* ========== SETTINGS GRID ========== */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; }

/* ========== RADIO TABS ========== */
.radio-tabs { display: flex; gap: 10px; }
.radio-tab {
    flex: 1; border: 1px solid var(--border); padding: 11px;
    border-radius: 8px; display: flex; justify-content: center; align-items: center;
    cursor: pointer; font-size: 13px; color: var(--text-muted);
    background: var(--bg-2); transition: all .15s; font-family: inherit;
}
.radio-tab.active { border-color: var(--primary); background: rgba(59,130,246,.1); color: var(--text); }
.radio-tab input { display: none; }

/* ========== FILE DROP ========== */
.file-drop {
    border: 2px dashed var(--border); border-radius: 8px;
    padding: 30px; text-align: center; cursor: pointer;
    background: var(--bg-2); color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    font-size: 13px; transition: border-color .2s;
}
.file-drop:hover { border-color: var(--primary); }
.file-drop i { font-size: 26px; color: var(--text-dim); }
.file-drop input { display: none; }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.72);
    display: flex; align-items: center; justify-content: center;
    z-index: 5000; padding: 20px;
}
.modal-overlay.hidden { display: none !important; }
.modal-box {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; width: 100%; max-width: 540px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.modal-header {
    padding: 18px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-actions {
    display: flex; justify-content: flex-end; gap: 10px;
    padding-top: 16px; margin-top: 8px;
    border-top: 1px solid var(--border);
}

/* ========== SIDEBAR BACKDROP ========== */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.6); z-index: 199;
}
.sidebar-backdrop.visible { display: block; }

/* ========== TOAST ========== */
.toast-container {
    position: fixed; bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 9999; max-width: 340px;
    width: calc(100% - 40px); pointer-events: none;
}
.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--primary);
    border: 1px solid var(--border);
    border-left-width: 4px;
    padding: 12px 16px; border-radius: 0 8px 8px 0;
    font-size: 13px; font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    animation: toast-slide .3s ease;
    pointer-events: all;
    transition: opacity .3s;
}
@keyframes toast-slide { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ========== EMPTY STATE ========== */
.empty-row td {
    text-align: center; padding: 48px 20px;
    color: var(--text-dim); font-size: 13px;
}

/* ========== NOTIFICATIONS VIEW ========== */
#view-notifications .panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; }

/* ========== HIDDEN ========== */
.hidden { display: none !important; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .dashboard-panels { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .form-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100%;
        transform: translateX(-100%); z-index: 500;
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-only { display: flex !important; }
    .content-area { padding: 16px; }
    .topbar { padding: 0 16px; }
    .view-toolbar { flex-wrap: wrap; }
    .search-bar { min-width: 100%; }
    .stat-cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
