/* ============================================================
   IPTV PANEL — CSS Principal
   Dark theme · XStream style · Production ready
   ============================================================ */

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

:root {
    --bg0:     #060b14;
    --bg1:     #0c1220;
    --bg2:     #101828;
    --bg3:     #162036;
    --bg-hover:#1a2844;
    --border:  #1d3050;
    --border2: #2a4070;

    --blue:    #0ea5e9;
    --blue2:   #38bdf8;
    --green:   #10b981;
    --red:     #ef4444;
    --amber:   #f59e0b;
    --purple:  #a855f7;
    --cyan:    #06b6d4;
    --teal:    #14b8a6;

    --text:    #dde5f0;
    --text2:   #7896bb;
    --text3:   #3d5c80;

    --sidebar-w: 240px;
    --topbar-h:  56px;
    --radius:    8px;
    --transition: all 0.18s ease;

    --font-ui:   'Exo 2', sans-serif;
    --font-brand:'Rajdhani', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

html { font-size: 14px; }
body {
    font-family: var(--font-ui);
    background: var(--bg0);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg1); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }

/* ── Links ── */
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue2); }

/* ── Code ── */
code, .mono { font-family: var(--font-mono); font-size: 12px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--border);
}
.brand-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 0 16px rgba(14,165,233,.3);
}
.brand-name {
    display: block;
    font-family: var(--font-brand);
    font-size: 18px;
    letter-spacing: 1px;
    background: linear-gradient(90deg, var(--blue2), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-name strong { font-weight: 700; }
.brand-version { font-size: 10px; color: var(--text3); letter-spacing: 2px; }

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-group-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text3);
    text-transform: uppercase;
    padding: 10px 8px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 6px;
    color: var(--text2);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.nav-item.active {
    background: linear-gradient(90deg, rgba(14,165,233,.15), rgba(14,165,233,.04));
    color: var(--blue);
    border: 1px solid rgba(14,165,233,.2);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -1px; top: 25%; bottom: 25%;
    width: 3px;
    background: var(--blue);
    border-radius: 0 3px 3px 0;
}
.nav-icon { width: 20px; text-align: center; font-size: 15px; }
.nav-badge {
    margin-left: auto;
    background: var(--green);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    font-family: var(--font-mono);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; }
.logout-btn {
    width: 32px; height: 32px;
    background: rgba(239,68,68,.1);
    border: 1px solid rgba(239,68,68,.2);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: var(--red);
    flex-shrink: 0;
    transition: var(--transition);
}
.logout-btn:hover { background: rgba(239,68,68,.2); color: var(--red); }

/* ============================================================
   MAIN WRAP
   ============================================================ */
.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.sidebar-toggle {
    background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer;
    display: none;
    padding: 4px;
}
.page-heading {
    font-family: var(--font-brand);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: .5px;
    flex: 1;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.online-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--green);
    font-weight: 600;
}
.online-dot {
    width: 8px; height: 8px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--green);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%,100% { opacity: 1; }
    50%      { opacity: .4; }
}
.topbar-time { font-family: var(--font-mono); font-size: 12px; color: var(--text3); }

/* ── Alerts ── */
.alert {
    margin: 12px 24px 0;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: var(--green); }
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: var(--red);   }

/* ── Page content ── */
.page-content { padding: 24px; flex: 1; }
.page-footer  {
    padding: 10px 24px;
    font-size: 11px;
    color: var(--text3);
    border-top: 1px solid var(--border);
    text-align: right;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}
.card.max-800 { max-width: 800px; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,.15);
    gap: 12px;
    flex-wrap: wrap;
}
.card-title {
    font-family: var(--font-brand);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .3px;
}
.card-body { padding: 18px; }
.card-body.p0 { padding: 0; }
.head-actions { display: flex; gap: 8px; }
.mt-20 { margin-top: 20px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.stat-card[data-color="blue"]   { --c: var(--blue); }
.stat-card[data-color="green"]  { --c: var(--green); }
.stat-card[data-color="red"]    { --c: var(--red); }
.stat-card[data-color="amber"]  { --c: var(--amber); }
.stat-card[data-color="purple"] { --c: var(--purple); }
.stat-card[data-color="cyan"]   { --c: var(--cyan); }
.stat-card[data-color="teal"]   { --c: var(--teal); }
.stat-card::before { background: var(--c); }
.stat-icon { font-size: 20px; margin-bottom: 10px; }
.stat-val {
    font-family: var(--font-brand);
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: var(--c);
}
.stat-lbl { font-size: 11px; color: var(--text2); margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }

/* ============================================================
   DASH GRID
   ============================================================ */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Server rows */
.server-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
}
.server-row:last-child { border-bottom: none; }
.srv-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.srv-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse-dot 2s infinite; }
.srv-dot.offline { background: var(--red); }
.srv-dot.maintenance { background: var(--amber); }
.srv-info { flex: 1; min-width: 0; }
.srv-info strong { display: block; font-size: 13px; }
.srv-info span   { font-size: 11px; color: var(--text3); }
.srv-load { display: flex; align-items: center; gap: 8px; }
.load-val { font-family: var(--font-mono); font-size: 13px; font-weight: 600; min-width: 44px; text-align: right; }
.load-val.low  { color: var(--green); }
.load-val.med  { color: var(--amber); }
.load-val.high { color: var(--red); }
.mini-bar { width: 64px; height: 5px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; }
.mini-fill { height: 100%; background: var(--blue); border-radius: 3px; }

/* Expiry rows */
.expiry-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
}
.expiry-row:last-child { border-bottom: none; }
.line-username { flex: 1; font-size: 13px; font-weight: 600; }
.badge-expiry {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(245,158,11,.1);
    color: var(--amber);
    border: 1px solid rgba(245,158,11,.3);
}
.badge-expiry.urgent {
    background: rgba(239,68,68,.1);
    color: var(--red);
    border-color: rgba(239,68,68,.3);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    padding: 9px 14px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text3);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,.2);
    white-space: nowrap;
}
tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar-sm {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px;
    flex-shrink: 0;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
}
.badge-online {
    background: rgba(16,185,129,.15);
    color: var(--green);
    border: 1px solid rgba(16,185,129,.3);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
}

/* ── Live dot ── */
.live-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.live-dot::before {
    content: '';
    width: 7px; height: 7px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--green);
    animation: pulse-dot 1.5s infinite;
    flex-shrink: 0;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.page-btn {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text2);
    font-size: 13px;
    transition: var(--transition);
}
.page-btn:hover, .page-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}
.page-info { margin-left: auto; font-size: 11px; color: var(--text3); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-ui);
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
}
.btn:focus { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn-primary {
    background: linear-gradient(135deg, var(--blue), #2563eb);
    color: white;
    box-shadow: 0 2px 12px rgba(14,165,233,.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(14,165,233,.35); color: white; }
.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text2);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger {
    background: rgba(239,68,68,.15);
    border-color: rgba(239,68,68,.3);
    color: var(--red);
}
.btn-danger:hover { background: var(--red); color: white; }
.btn-success {
    background: linear-gradient(135deg, var(--green), #059669);
    color: white;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.btn-block { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text2);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.form-control {
    width: 100%;
    background: var(--bg1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    color: var(--text);
    font-size: 13.5px;
    font-family: var(--font-ui);
    outline: none;
    transition: var(--transition);
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(14,165,233,.12); }
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg2); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-control.form-sm { padding: 6px 10px; font-size: 12px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Checkbox grid */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
}
.checkbox-item:hover { border-color: var(--blue); background: rgba(14,165,233,.05); }
.checkbox-item input { accent-color: var(--blue); }

/* Password input */
.input-pass-wrap { position: relative; }
.pass-toggle {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; font-size: 14px;
    color: var(--text3);
}

/* ============================================================
   PAGE ACTIONS (filters + buttons top bar)
   ============================================================ */
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar { flex: 1; }
.filter-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action-group { display: flex; gap: 6px; }

/* ============================================================
   UA CELL (short user-agent)
   ============================================================ */
.ua-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text3);
    font-size: 11px;
}

/* ============================================================
   TEXT UTILS
   ============================================================ */
.text-xs    { font-size: 11px; }
.text-sm    { font-size: 12px; }
.text-muted { color: var(--text3); }
.text-danger{ color: var(--red); }
.text-amber { color: var(--amber); }
.text-green { color: var(--green); }
.text-center{ text-align: center; }
.text-right { text-align: right; }
.empty-msg  { padding: 24px; text-align: center; color: var(--text3); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.body-blank {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg0);
}
.login-wrap { width: 100%; padding: 20px; display: flex; justify-content: center; }
.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}
.login-icon {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    box-shadow: 0 0 24px rgba(14,165,233,.4);
}
.login-brand {
    font-family: var(--font-brand);
    font-size: 22px;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--blue2), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.login-form { margin-top: 4px; }
.login-footer { text-align: center; font-size: 11px; color: var(--text3); margin-top: 20px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--green);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    z-index: 999;
    box-shadow: 0 4px 16px rgba(16,185,129,.4);
    animation: slide-in .2s ease;
}
@keyframes slide-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-240px); width: 240px; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-wrap { margin-left: 0; }
    .dash-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .filter-form .form-control { font-size: 13px; }
    .page-content { padding: 14px; }
}
