/* Jellyfin Portal - Enterprise Console UI (v7) */

:root{
  --bg:#f6f7fb;
  --surface:#ffffff;
  --surface-2:#fbfbfe;
  --text:#0f172a;
  --muted:#64748b;
  --border:rgba(15,23,42,.10);
  --primary:#4f46e5;
  --primary-weak:rgba(79,70,229,.12);
  --danger:#ef4444;
  --success:#22c55e;
  --warning:#f59e0b;

  --radius:14px;
  --radius-sm:12px;
  --shadow:0 1px 2px rgba(15,23,42,.05), 0 10px 30px rgba(15,23,42,.07);
  --shadow-soft:0 1px 2px rgba(15,23,42,.04), 0 8px 20px rgba(15,23,42,.06);
}

[data-theme="dark"]{
  --bg:#0b1220;
  --surface:rgba(15,23,42,.92);
  --surface-2:rgba(15,23,42,.78);
  --text:#e5e7eb;
  --muted:rgba(226,232,240,.70);
  --border:rgba(226,232,240,.12);
  --primary:#8b7bff;
  --primary-weak:rgba(139,123,255,.18);
  --shadow:0 1px 2px rgba(0,0,0,.25), 0 16px 48px rgba(0,0,0,.35);
  --shadow-soft:0 1px 2px rgba(0,0,0,.20), 0 14px 40px rgba(0,0,0,.32);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "PingFang SC","Microsoft YaHei", Arial;
  background:var(--bg);
  color:var(--text);
}

/* utils */
.row{display:flex; align-items:center; gap:10px}
.grid{display:grid; gap:12px}
.muted{color:var(--muted)}
.sep{border:none; border-top:1px solid var(--border); margin:16px 0}
.kbd{border:1px solid var(--border); border-radius:10px; padding:2px 8px; font-size:12px; color:var(--muted); background:rgba(255,255,255,.7)}
[data-theme="dark"] .kbd{background:rgba(0,0,0,.25)}
.badge{display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border-radius:999px; border:1px solid var(--border); color:var(--muted); font-size:12px; background:rgba(255,255,255,.7)}
[data-theme="dark"] .badge{background:rgba(0,0,0,.22)}

code{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace}

/* buttons */
.btn{
  appearance:none;
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:650;
  font-size:13px;
  display:inline-flex; align-items:center; gap:8px;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover{background:rgba(79,70,229,.06); border-color:rgba(79,70,229,.20)}
.btn:active{transform: translateY(1px)}
.btn.primary{background:var(--primary); border-color:transparent; color:#fff}
.btn.primary:hover{filter:brightness(1.03)}
.btn.ghost{background:transparent}
.btn.danger{background:rgba(239,68,68,.12); border-color:rgba(239,68,68,.25); color:#b91c1c}
[data-theme="dark"] .btn.danger{color:#fecaca}
.btn.icon{width:36px; height:36px; padding:0; justify-content:center; border-radius:12px}
.btn.small{padding:8px 10px; border-radius:10px; font-size:12px}

/* compatibility for ui.js */
.btn-primary{background:var(--primary); border-color:transparent; color:#fff}
.btn-primary:hover{filter:brightness(1.03)}
.btn-danger{background:rgba(239,68,68,.12); border-color:rgba(239,68,68,.25); color:#b91c1c}
.btn-ghost{background:transparent}

/* inputs */
.input, select.input, textarea.input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  outline:none;
  font-size:13px;
}
.input:focus{border-color:rgba(79,70,229,.35); box-shadow:0 0 0 4px rgba(79,70,229,.10)}
label{display:block; font-size:12px; color:var(--muted); margin:0 0 8px}
textarea.input{min-height:96px; resize:vertical}

/* panels */
.panel{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow-soft);
}
.panel .hd{
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
}
.panel .hd h3{margin:0; font-size:14px; font-weight:900}
.panel .bd{padding:14px 16px}

/* tiles */
.tiles{display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap:12px}
@media (max-width: 980px){ .tiles{grid-template-columns:1fr} }
.tile{
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
  background:var(--surface-2);
  display:flex; align-items:flex-start; gap:12px;
}
.tile .tico{
  width:34px; height:34px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  background:rgba(79,70,229,.10);
  color:var(--primary);
}
.tile .tt{font-weight:900; margin:0; font-size:13px}
.tile .td{margin:4px 0 0; color:var(--muted); font-size:12px; line-height:1.4}

/* table */
.table-wrap{overflow:auto}
.table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
}
.table th{
  text-align:left;
  font-size:12px;
  color:var(--muted);
  font-weight:700;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  background:var(--surface);
  position:sticky; top:0; z-index:1;
}
.table td{
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}
.table tr:hover td{background:rgba(79,70,229,.04)}
.pill{
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}
.pill.ok{background:rgba(34,197,94,.10); border-color:rgba(34,197,94,.20); color:#15803d}
.pill.warn{background:rgba(245,158,11,.12); border-color:rgba(245,158,11,.20); color:#a16207}
.pill.err{background:rgba(239,68,68,.10); border-color:rgba(239,68,68,.20); color:#b91c1c}

/* dropdown */
.dropdown{position:relative; display:inline-flex}
.dropdown-menu{
  position:absolute;
  right:0;
  top:100%;
  margin-top:10px;
  min-width:180px;
  padding:8px;
  border-radius:14px;
  border:1px solid var(--border);
  background:var(--surface);
  box-shadow:var(--shadow);
  display:none;
  z-index:80;
}
.dropdown-menu.show{display:block}
.dropdown-menu button{
  width:100%;
  border:none;
  background:transparent;
  padding:10px 10px;
  border-radius:12px;
  cursor:pointer;
  font-size:13px;
  font-weight:750;
  color:var(--text);
  display:flex; align-items:center; justify-content:space-between;
}
.dropdown-menu button:hover{background:rgba(79,70,229,.07)}
.dropdown-menu .mark{color:var(--primary); opacity:0}

/* toast */
.toast-wrap{
  position:fixed;
  right:16px;
  bottom:16px;
  display:flex;
  flex-direction:column;
  gap:10px;
  z-index:200;
}
.toast{
  width:320px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow);
  padding:12px;
  transition:opacity .25s ease, transform .25s ease;
}
.toast .t{font-weight:900}
.toast .d{margin-top:4px; color:var(--muted); font-size:12px; line-height:1.35}
.toast.ok{border-color:rgba(34,197,94,.25)}
.toast.err{border-color:rgba(239,68,68,.30)}
.toast.warn{border-color:rgba(245,158,11,.30)}

/* ui.js modal compat */
.modal-mask{
  position:fixed; inset:0;
  background:rgba(15,23,42,.45);
  display:none;
  align-items:center; justify-content:center;
  padding:18px;
  z-index:160;
}
.modal-mask .modal{
  width:min(720px, 100%);
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow);
}
.modal-mask .modal .hd{padding:14px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between}
.modal-mask .modal .hd h3{margin:0; font-size:15px; font-weight:950}
.modal-mask .modal .bd{padding:14px 16px}
.modal-mask .modal .ft{padding:14px 16px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:10px}

/* public */
.public-shell{min-height:100vh; display:flex; flex-direction:column}
.public-top{
  height:62px;
  display:flex; align-items:center; justify-content:space-between;
  padding:0 18px;
  border-bottom:1px solid var(--border);
  background:var(--surface);
}
.public-main{flex:1; display:flex; align-items:flex-start; justify-content:center; padding:40px 24px}
.auth-grid{width:min(1040px, 100%); display:block}
.auth-merged{
  display:grid;
  grid-template-columns: 1fr 1px 420px;
  gap:0;
  align-items:stretch;
}
.auth-vsep{ background:var(--border); width:1px; }
.auth-left{ padding:18px 18px 18px 18px; }
.auth-right{ padding:18px 18px 18px 18px; }
@media (max-width: 980px){
  .auth-merged{ grid-template-columns:1fr; }
  .auth-vsep{ display:none; }
  .auth-left{ padding-bottom:0; }
}

.brandbox{display:flex; align-items:center; gap:10px}
.dot{width:30px; height:30px; border-radius:10px; background:var(--primary); box-shadow:0 10px 24px rgba(79,70,229,.25)}
.hero h2{margin:0; font-size:28px; font-weight:950; letter-spacing:-.02em}
.hero p{margin:10px 0 0; color:var(--muted); line-height:1.55}
.form-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:14px}

/* admin shell */
.shell{display:grid; grid-template-columns: 260px 1fr; min-height:100vh}
@media (max-width: 980px){ .shell{grid-template-columns:1fr} .sidebar{position:static; height:auto} .topbar{position:static} }
.sidebar{
  background:var(--surface);
  border-right:1px solid var(--border);
  padding:16px;
  position:sticky; top:0; height:100vh;
  display:flex; flex-direction:column;
}
.brand{display:flex; align-items:center; gap:10px; padding:10px 10px 14px}
.brand h1{font-size:14px; margin:0; font-weight:950}
.brand p{margin:0; font-size:12px}
.account{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--surface-2);
  margin:10px 0 14px;
}
.avatar{
  width:34px; height:34px; border-radius:999px;
  background:rgba(79,70,229,.12);
  display:flex; align-items:center; justify-content:center;
  font-weight:900; color:var(--primary);
}
.nav{display:flex; flex-direction:column; gap:6px}
.nav-item{
  border:none; background:transparent;
  color:var(--text);
  width:100%;
  text-align:left;
  padding:10px 10px;
  border-radius:12px;
  display:flex; align-items:center; gap:10px;
  cursor:pointer;
  font-weight:750;
  font-size:13px;
}
.nav-item:hover{background:rgba(79,70,229,.06)}
.nav-item.active{background:rgba(79,70,229,.10); box-shadow: inset 3px 0 0 var(--primary)}
.nav-item .ico{width:18px; height:18px; display:inline-flex; align-items:center; justify-content:center; color:var(--muted)}
.nav-item.active .ico{color:var(--primary)}
.sidebar-foot{margin-top:auto; display:flex; flex-direction:column; gap:10px; padding-top:14px}

.main{display:flex; flex-direction:column; min-width:0}
.topbar{
  height:56px;
  display:flex; align-items:center; justify-content:space-between;
  padding:0 18px;
  border-bottom:1px solid var(--border);
  background:var(--bg);
  position:sticky; top:0; z-index:40;
}
.search{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--surface);
  min-width:280px;
}
.search input{
  border:none; outline:none; background:transparent;
  width:260px; max-width:42vw;
  font-size:13px;
  color:var(--text);
}
.top-actions{display:flex; align-items:center; gap:10px}

.page{padding:18px}
.page-head{display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin-bottom:14px}
.page-title{margin:0; font-size:24px; font-weight:950; letter-spacing:-.02em}
.page-desc{margin:4px 0 0; color:var(--muted); font-size:13px}
.page-grid{display:grid; grid-template-columns: 1fr 360px; gap:16px; align-items:start}
@media (max-width: 1160px){ .page-grid{grid-template-columns:1fr} }


/* ---- enterprise components: pager & inline search ---- */
.pager{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px;
  padding-top:12px;
}
.pager-pages{ display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
.pagebtn{
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  border-radius:10px;
  padding:6px 10px;
  font-size:12px;
  cursor:pointer;
}
.pagebtn.active{
  background:rgba(79,70,229,.14);
  border-color:rgba(79,70,229,.28);
  color:var(--primary);
  font-weight:800;
}
.pagebtn:disabled{ opacity:.5; cursor:not-allowed; }

.insearch{
  display:flex; align-items:center; gap:8px;
  border:1px solid var(--border);
  background:var(--surface-2);
  border-radius:999px;
  padding:8px 10px;
}
.insearch input{
  border:none;
  background:transparent;
  outline:none;
  color:var(--text);
  width:240px;
  max-width:40vw;
  font-size:13px;
}
.insearch .kbd{margin-left:6px}

/* avatar button */
.btn.avatar{
  width:34px; height:34px;
  border-radius:999px;
  display:inline-flex; align-items:center; justify-content:center;
  background:rgba(79,70,229,.14);
  border:1px solid rgba(79,70,229,.22);
  color:var(--primary);
  font-weight:950;
  padding:0;
}
.dropdown-menu .danger{ color: #ef4444; }






/* Theme dropdown (only theme menu uses grid to keep icon+label aligned) */
.dropdown-menu.theme-menu button{
  display:grid;
  grid-template-columns: 16px 1fr;
  align-items:center;
  column-gap:8px;
}
.dropdown-menu.theme-menu .ticon{
  width:16px;
  text-align:center;
}
.dropdown-menu.theme-menu button.active{
  background: rgba(99,102,241,.12);
  color: var(--text);
}
