/* =============================================================================
   Universe IPTV Helper — Dashboard theme
   "Control room": deep ink, faint gold aurora, glass surfaces, gold accent.
   Self-hosted fonts (no CDN). Fully responsive: sidebar -> drawer on mobile.
   ============================================================================= */

@font-face {
    font-family: "Bricolage Grotesque";
    src: url("/assets/fonts/bricolage-600.woff2") format("woff2");
    font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Bricolage Grotesque";
    src: url("/assets/fonts/bricolage-700.woff2") format("woff2");
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("/assets/fonts/jetbrains-400.woff2") format("woff2");
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("/assets/fonts/jetbrains-600.woff2") format("woff2");
    font-weight: 600; font-style: normal; font-display: swap;
}

:root {
    --bg:         #0a0c12;
    --bg-2:       #0e1118;
    --surface:    #12151d;
    --surface-2:  #181c26;
    --line:       #20242f;
    --line-2:     #2b313f;
    --text:       #e8eaf0;
    --muted:      #9aa1b3;
    --faint:      #636b7e;
    --accent:     #ffb020;
    --accent-2:   #ffc861;
    --accent-ink: #1a1204;
    --success:    #34d399;
    --success-d:  #06281d;
    --danger:     #f87171;
    --radius:     16px;
    --radius-sm:  10px;
    --radius-xs:  8px;
    --sidebar-w:  248px;
    --shadow:     0 18px 50px rgba(0, 0, 0, .5);
    --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --font:       system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
    --font-ar:    "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
    --font-mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    font-size: 15px;
    position: relative;
}
body::before {
    content: "";
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(880px 520px at 92% -8%, rgba(255, 176, 32, .10), transparent 60%),
        radial-gradient(720px 520px at -10% 110%, rgba(96, 110, 245, .07), transparent 60%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232838; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2e3447; }

.mono, code { font-family: var(--font-mono); }
code { font-size: .9em; color: var(--accent-2); background: rgba(255,176,32,.08); padding: 1px 6px; border-radius: 5px; }

/* ============================ App shell ============================ */
.app { position: relative; z-index: 1; min-height: 100dvh; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    background: linear-gradient(180deg, #0e1118, #0b0e15);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 6px;
    padding: 20px 14px; z-index: 40;
}
.side-brand {
    display: flex; align-items: center; gap: 11px;
    padding: 6px 8px 18px; margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.side-brand__mark {
    width: 38px; height: 38px; flex: none;
    display: grid; place-items: center;
    font-family: var(--font-display); font-weight: 700; font-size: 20px;
    color: var(--accent-ink);
    background: linear-gradient(145deg, var(--accent-2), var(--accent));
    border-radius: 11px;
    box-shadow: 0 6px 16px rgba(255, 176, 32, .28);
}
.side-brand__txt {
    font-family: var(--font-display); font-weight: 700; font-size: 16px;
    line-height: 1.1; color: var(--text); display: flex; flex-direction: column;
}
.side-brand__txt small { font-family: var(--font); font-weight: 500; font-size: 11px; color: var(--accent); letter-spacing: .04em; }

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; }

.side-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 13px; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 500; font-size: 14.5px;
    position: relative; transition: background .15s, color .15s;
}
.side-link svg { width: 20px; height: 20px; flex: none; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: rgba(255, 176, 32, .12); color: var(--accent-2); }
.side-link.active::before {
    content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.side-link--muted { color: var(--faint); }
.side-link--muted:hover { color: var(--danger); }

.scrim { display: none; }

.main { margin-left: var(--sidebar-w); min-height: 100dvh; }
.main-inner {
    max-width: 1080px; margin: 0 auto;
    padding: 30px 32px 64px;
    animation: page-in .4s ease both;
}
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Topbar (mobile only) */
.topbar {
    display: none; align-items: center; gap: 14px;
    height: 58px; padding: 0 16px;
    background: rgba(10, 12, 18, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
}
.topbar__brand { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.topbar__brand b { color: var(--accent); }
.hamburger {
    width: 40px; height: 40px; border-radius: 10px; flex: none;
    background: var(--surface); border: 1px solid var(--line);
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
    cursor: pointer; padding: 0;
}
.hamburger span { width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: .2s; }
body.nav-open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.nav-open .hamburger span:nth-child(2) { opacity: 0; }
body.nav-open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ============================ Page header ============================ */
.page-title {
    font-family: var(--font-display); font-weight: 700; font-size: 27px;
    letter-spacing: -.02em; line-height: 1.15; margin-bottom: 4px;
}
.page-sub { color: var(--muted); font-size: 14.5px; margin-bottom: 26px; }
.page-sub a { color: var(--muted); border-bottom: 1px dashed var(--line-2); }
.page-sub a:hover { color: var(--accent); }

/* ============================ Cards ============================ */
.card {
    background: linear-gradient(180deg, var(--surface), #11141c);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: card-in .45s ease both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card:nth-of-type(2) { animation-delay: .05s; }
.card:nth-of-type(3) { animation-delay: .1s; }

.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-head h3 { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.card-body { padding: 8px 12px; }

/* ============================ Rows ============================ */
.row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 10px; border-radius: var(--radius-xs);
    transition: background .12s;
}
.row + .row { border-top: 1px solid rgba(255,255,255,.03); }
.icon {
    width: 40px; height: 40px; flex: none; border-radius: 10px; object-fit: contain;
    background: var(--bg-2); border: 1px solid var(--line-2); padding: 5px;
}
.icon-empty { display: inline-flex; align-items: center; justify-content: center; color: var(--faint); }
.order {
    font-family: var(--font-mono); font-size: 12px; color: var(--faint);
    min-width: 22px; text-align: center; flex: none;
}
.name { font-weight: 500; }
.meta { color: var(--muted); font-size: 13px; font-family: var(--font-mono); }
.spacer { flex: 1; }
.empty { padding: 26px 12px; text-align: center; color: var(--faint); }

/* ============================ Buttons ============================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-family: var(--font); font-size: 14px; font-weight: 600;
    padding: 10px 16px; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer; line-height: 1; white-space: nowrap;
    transition: transform .08s ease, background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: var(--accent-ink); }
.btn-primary:hover { box-shadow: 0 8px 22px rgba(255, 176, 32, .3); color: var(--accent-ink); }
.btn-ghost { background: var(--surface-2); border-color: var(--line-2); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-2); }
.btn-danger { background: transparent; border-color: rgba(248,113,113,.4); color: #fca5a5; }
.btn-danger:hover { border-color: var(--danger); color: #fecaca; background: rgba(248,113,113,.08); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; padding: 12px; }

form.inline { display: inline; margin: 0; }

/* ============================ Badges ============================ */
.badge, .badge-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px; font-weight: 600; padding: 4px 11px; border-radius: 999px;
    border: 1px solid transparent;
}
.badge-btn { cursor: pointer; font-family: inherit; }
.badge-on  { background: rgba(52,211,153,.14); color: #6ee7b7; }
.badge-off { background: rgba(120,128,148,.16); color: var(--muted); }
.badge-btn:hover { filter: brightness(1.18); }

/* ============================ Forms ============================ */
.field { margin-bottom: 18px; }
.field label, label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; letter-spacing: .03em; text-transform: uppercase; }
.input {
    width: 100%; font-family: var(--font); font-size: 14.5px; color: var(--text);
    background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
    padding: 11px 13px; transition: border-color .15s, box-shadow .15s; outline: none;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 176, 32, .16); }
textarea.input { resize: vertical; line-height: 1.7; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input[type="file"].input { padding: 9px; }
input[type="file"].input::file-selector-button { font-family: var(--font); font-weight: 600; font-size: 13px; color: var(--accent-ink); background: var(--accent); border: none; padding: 8px 13px; border-radius: 8px; margin-right: 12px; cursor: pointer; }
.field-err { display: block; color: #fca5a5; font-size: 12px; margin-top: 6px; text-transform: none; letter-spacing: 0; }
.check { display: flex; align-items: center; gap: 9px; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 14.5px; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.rtl { direction: rtl; font-family: var(--font-ar); text-align: right; }

/* Placeholder toolbar */
.ph-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.ph-chip {
    font-family: var(--font-mono); font-size: 12px; font-weight: 500;
    color: var(--accent-2); background: rgba(255,176,32,.1);
    border: 1px solid rgba(255,176,32,.3); border-radius: 999px;
    padding: 4px 11px; cursor: pointer; transition: background .15s;
}
.ph-chip:hover { background: rgba(255,176,32,.2); }

/* Live preview */
.preview {
    background: var(--bg-2); border: 1px solid var(--line-2);
    border-radius: var(--radius-sm); padding: 13px 15px; min-height: 84px;
    white-space: pre-wrap; word-break: break-word; font-family: var(--font-ar);
    font-size: 13.5px; line-height: 1.8; color: var(--text); margin: 0;
}

/* ============================ Alerts ============================ */
.alert { padding: 12px 15px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.3); color: #6ee7b7; }
.alert-danger { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.3); color: #fca5a5; }

/* ============================ Stat tiles ============================ */
.grid.stats {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 26px;
}
@media (min-width: 720px) { .grid.stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
    background: linear-gradient(180deg, var(--surface), #11141c);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 18px 16px; position: relative; overflow: hidden;
    animation: card-in .45s ease both;
}
.stat::after {
    content: ""; position: absolute; top: -30px; right: -30px; width: 90px; height: 90px;
    background: radial-gradient(circle, rgba(255,176,32,.14), transparent 70%);
}
.stat:nth-child(2) { animation-delay: .04s; }
.stat:nth-child(3) { animation-delay: .08s; }
.stat:nth-child(4) { animation-delay: .12s; }
.stat .n { font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 1; color: var(--accent-2); }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 8px; letter-spacing: .03em; }

/* ============================ Login ============================ */
.auth-wrap {
    min-height: 100dvh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1;
}
.auth-card {
    width: 100%; max-width: 392px; padding: 34px 30px;
    background: linear-gradient(180deg, var(--surface), #11141c);
    border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
    animation: card-in .5s ease both;
}
.auth-logo { font-family: var(--font-display); font-weight: 700; font-size: 23px; text-align: center; }
.auth-logo span { color: var(--accent); }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 26px; }
.auth-card .btn-block { margin-top: 6px; }

/* ============================ Responsive ============================ */
@media (max-width: 960px) {
    .topbar { display: flex; }
    .main { margin-left: 0; }
    .main-inner { padding: 22px 18px 56px; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform .26s cubic-bezier(.4, 0, .2, 1);
        box-shadow: 24px 0 60px rgba(0,0,0,.5);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .scrim {
        display: block; position: fixed; inset: 0; z-index: 35;
        background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px);
    }
    .page-title { font-size: 23px; }
    .card-head { padding: 14px 16px; }
}
@media (max-width: 420px) {
    .card-head { flex-direction: column; align-items: stretch; gap: 10px; }
    .card-head .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Drag-and-drop */
.drag-handle { cursor: grab; color: var(--faint); font-size: 16px; line-height: 1; user-select: none; }
.sortable-row { transition: background .12s; }
.sortable-row:hover { background: var(--surface-2); }
.sortable-row.dragging { opacity: .4; background: var(--surface-2); }

/* Brand mark (planet) */
.side-brand__mark svg { width: 22px; height: 22px; display: block; }
.auth-mark {
    width: 50px; height: 50px; margin: 0 auto 14px;
    display: grid; place-items: center;
    color: var(--accent-ink);
    background: linear-gradient(145deg, var(--accent-2), var(--accent));
    border-radius: 14px;
    box-shadow: 0 8px 22px rgba(255, 176, 32, .3);
}
