/* ============================================================
   ApexPoster admin — Apex Technology Group brand
   deep-space background + indigo→violet→magenta gradient glass
   ============================================================ */
:root {
    --indigo: #6366f1;
    --violet: #8b5cf6;
    --violet-light: #a78bfa;
    --magenta: #c026d3;
    --bg: #0a0a0f;
    --surface: #12121c;
    --surface-raised: #1a1a28;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --success: #34d399;
    --warning: #fbbf24;
    --error: #fb7185;
    --info: #38bdf8;
    --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c026d3 100%);
    --glow: 0 0 40px rgba(139, 92, 246, 0.25);
    --border: rgba(139, 92, 246, 0.14);
    --border-strong: rgba(139, 92, 246, 0.45);
    --radius: 14px;
    --font: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg); color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--violet-light); text-decoration: none; }
button { font-family: var(--font); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.5); }
::selection { background: rgba(139, 92, 246, 0.4); }

/* ---- background orbs ---- */
.orbs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.3; }
.orb-1 { width: 600px; height: 600px; background: radial-gradient(circle, var(--indigo), transparent 70%); top: -220px; right: -120px; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, var(--violet), transparent 70%); bottom: -180px; left: -120px; }
.orb-3 { width: 420px; height: 420px; background: radial-gradient(circle, var(--magenta), transparent 70%); top: 45%; left: 55%; opacity: 0.12; }

/* ---- helpers ---- */
.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.glass {
    background: rgba(18, 18, 28, 0.6);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border);
}
.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.12em; }

/* ---- buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface-raised);
    color: var(--text); font-weight: 600; font-size: 0.92rem; cursor: pointer;
    transition: border-color .2s, transform .1s, background .2s;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gradient); border: none; color: #fff; box-shadow: 0 6px 20px rgba(139,92,246,.35); }
.btn-primary:hover { box-shadow: 0 8px 28px rgba(139,92,246,.5); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--error); border-color: rgba(251,113,133,.3); background: transparent; }
.btn-danger:hover { border-color: var(--error); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- forms ---- */
label { display: block; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
input, select {
    width: 100%; padding: 11px 14px; border-radius: var(--radius);
    background: rgba(10,10,15,.6); border: 1px solid rgba(148,163,184,.25);
    color: var(--text); font-size: 0.95rem; font-family: var(--font);
}
input:focus, select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139,92,246,.18); }
.field { margin-bottom: 16px; }

/* ---- landing (signed out) ---- */
.landing { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 40px 24px; }
.landing-inner { width: 100%; max-width: 1120px; display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 64px; align-items: center; }

.marketing .eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.76rem; font-weight: 700; color: var(--violet-light); margin-bottom: 18px; }
.hero { font-size: clamp(2.4rem, 4.6vw, 3.8rem); font-weight: 800; line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 20px; }
.lede { font-size: 1.08rem; color: var(--text-dim); line-height: 1.6; max-width: 30em; margin: 0 0 32px; }

.features { list-style: none; padding: 0; margin: 0 0 30px; display: grid; gap: 18px; }
.feature { display: flex; gap: 14px; align-items: flex-start; }
.feature-ic { font-size: 1.4rem; line-height: 1.3; width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: 11px; background: rgba(139,92,246,.12); border: 1px solid var(--border); }
.feature strong { display: block; font-size: 1rem; margin-bottom: 2px; }
.feature p { margin: 0; color: var(--text-dim); font-size: 0.9rem; line-height: 1.5; }

.mk-foot { display: flex; align-items: center; gap: 12px; padding-top: 22px; border-top: 1px solid var(--border); }
.mk-foot img { height: 22px; opacity: 0.9; }
.mk-foot span { color: var(--text-dim); font-size: 0.86rem; }

.auth { display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; padding: 34px 30px; border-radius: 22px; }
.auth-card h2 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 800; }
.auth-sub { text-align: left; color: var(--text-dim); margin: 0 0 24px; font-size: 0.9rem; }

.provider-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); font-weight: 600; font-size: 0.95rem; cursor: pointer; margin-bottom: 12px; border: 1px solid transparent; transition: transform .1s, filter .2s, border-color .2s; }
.provider-btn:active { transform: translateY(1px); }
.provider-google { background: #fff; color: #1f1f1f; }
.provider-google:hover { filter: brightness(0.96); }
.provider-apple { background: #000; color: #fff; border-color: rgba(255,255,255,.18); }
.provider-apple:hover { border-color: rgba(255,255,255,.4); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 0.8rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.toggle-line { text-align: center; color: var(--text-dim); font-size: 0.88rem; margin: 18px 0 0; }
.toggle-line a { cursor: pointer; font-weight: 600; }

@media (max-width: 900px) {
  .landing-inner { grid-template-columns: 1fr; gap: 36px; max-width: 460px; }
  .marketing { text-align: center; }
  .feature { text-align: left; }
  .features { max-width: 420px; margin-inline: auto; }
  .mk-foot { justify-content: center; }
  .auth-sub { text-align: center; }
}

/* ---- app shell ---- */
.app { position: relative; z-index: 1; min-height: 100vh; display: flex; }
.sidebar {
    width: 240px; flex-shrink: 0; padding: 26px 18px;
    border-right: 1px solid var(--border); background: rgba(18,18,28,.5);
    backdrop-filter: blur(18px); display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; padding: 0 8px; }
.brand img { height: 30px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px;
    border-radius: 12px; color: var(--text-dim); font-weight: 600; cursor: pointer;
    border: 1px solid transparent; font-size: 0.92rem;
}
.nav-item:hover { color: var(--text); background: rgba(139,92,246,.08); }
.nav-item.active { color: var(--text); background: rgba(139,92,246,.14); border-color: var(--border); }
.nav-icon { width: 20px; text-align: center; }
.sidebar-foot { font-size: 0.8rem; color: var(--text-dim); border-top: 1px solid var(--border); padding-top: 16px; }

.main { flex: 1; padding: 32px 40px; max-width: 1200px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.7rem; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-dim); font-size: 0.9rem; }

/* ---- cards / grids ---- */
.card {
    background: linear-gradient(180deg, rgba(26,26,40,.85), rgba(18,18,28,.85));
    border: 1px solid var(--border); border-radius: 16px; padding: 20px;
}
.grid { display: grid; gap: 16px; }
.grid-screens { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-media { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.screen-card { display: flex; flex-direction: column; gap: 12px; }
.screen-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.screen-name { font-weight: 700; font-size: 1.05rem; }
.dot { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; }
.dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.dot.online { color: var(--success); }
.dot.online::before { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot.offline { color: var(--text-dim); }
.screen-meta { font-size: 0.82rem; color: var(--text-dim); line-height: 1.7; }
.screen-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.media-tile { border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); position: relative; }
.media-tile img, .media-tile video { width: 100%; height: 130px; object-fit: cover; display: block; background: #000; }
.media-info { padding: 8px 10px; font-size: 0.78rem; }
.media-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.media-kind { color: var(--text-dim); text-transform: uppercase; font-size: 0.68rem; letter-spacing: .08em; }
.media-del { position: absolute; top: 6px; right: 6px; background: rgba(10,10,15,.7); border: 1px solid var(--border); color: var(--error); width: 28px; height: 28px; border-radius: 8px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.media-tile:hover .media-del { opacity: 1; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: .04em; }
.badge-code { background: rgba(139,92,246,.16); color: var(--violet-light); border: 1px solid var(--border); font-size: 0.95rem; padding: 6px 14px; }
.badge-admin { background: rgba(192,38,211,.16); color: #e879f9; }
.badge-owner { background: rgba(99,102,241,.16); color: var(--violet-light); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .06em; }

/* ---- playlist editor ---- */
.pl-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 8px; }
.pl-item img, .pl-item video { width: 74px; height: 46px; object-fit: cover; border-radius: 8px; background: #000; flex-shrink: 0; }
.pl-item .grow { flex: 1; min-width: 0; }
.pl-item .grow .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dur { width: 84px; flex-shrink: 0; }
.dur input { padding: 7px 8px; text-align: center; }
.pl-reorder { display: flex; flex-direction: column; gap: 2px; }
.pl-reorder button { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 0.9rem; padding: 0 4px; }
.pl-reorder button:hover { color: var(--violet-light); }

.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 340px; overflow-y: auto; padding: 4px; }
.picker-tile { border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--surface); }
.picker-tile.sel { border-color: var(--violet); }
.picker-tile img, .picker-tile video { width: 100%; height: 78px; object-fit: cover; display: block; background: #000; }
.picker-tile .pn { font-size: 0.7rem; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(5,5,10,.72); backdrop-filter: blur(4px); z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal { width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; border-radius: 20px; padding: 28px; background: linear-gradient(180deg, #1a1a28, #12121c); border: 1px solid var(--border-strong); box-shadow: 0 24px 80px rgba(0,0,0,.7), var(--glow); }
.modal h2 { margin: 0 0 4px; font-size: 1.3rem; }
.modal .sub { color: var(--text-dim); font-size: 0.86rem; margin: 0 0 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ---- empty / toast ---- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty .big { font-size: 2.4rem; margin-bottom: 10px; }
.error-text { color: var(--error); font-size: 0.85rem; margin-top: 10px; min-height: 1.2em; }

#toasts { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 13px 18px; border-radius: 12px; background: var(--surface-raised); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 0.9rem; font-weight: 600; animation: slidein .25s ease; }
.toast.ok { border-color: rgba(52,211,153,.4); }
.toast.err { border-color: rgba(251,113,133,.4); color: #fecdd3; }
@keyframes slidein { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

@media (max-width: 720px) {
    .sidebar { width: 68px; padding: 20px 8px; }
    .brand span, .nav-item span, .sidebar-foot { display: none; }
    .main { padding: 22px 16px; }
}
