/* VODUM modern layer — "web3 / AI" look: aurora background, glass cards, neon accents.
   Works on top of the compiled Tailwind utilities by re-pointing them at CSS variables,
   so every existing page follows the theme (dark by default, light on demand). */

:root, html[data-theme="dark"] {
  --bg: #05060f;
  --bg-aurora-1: rgba(124, 92, 255, .22);
  --bg-aurora-2: rgba(34, 211, 238, .14);
  --bg-aurora-3: rgba(244, 114, 182, .10);
  --surface: rgba(16, 19, 40, .72);
  --surface-2: rgba(26, 31, 62, .78);
  --surface-3: rgba(38, 45, 86, .85);
  --border: rgba(140, 150, 255, .16);
  --border-strong: rgba(140, 150, 255, .30);
  --text: #eef0ff;
  --text-2: #c7ccf0;
  --muted: #8b93bd;
  --accent: #8b6bff;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #22d3ee 100%);
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .04);
  --glow: 0 0 0 1px rgba(139, 107, 255, .35), 0 8px 30px -8px rgba(124, 92, 255, .55);
  --plex: #ebaf00;
  --ok: #34d399; --warn: #fbbf24; --bad: #fb7185;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f6fc;
  --bg-aurora-1: rgba(124, 92, 255, .13);
  --bg-aurora-2: rgba(34, 211, 238, .12);
  --bg-aurora-3: rgba(244, 114, 182, .08);
  --surface: rgba(255, 255, 255, .86);
  --surface-2: rgba(240, 243, 252, .95);
  --surface-3: rgba(226, 231, 247, .95);
  --border: rgba(80, 90, 160, .16);
  --border-strong: rgba(80, 90, 160, .30);
  --text: #12152b;
  --text-2: #2f3558;
  --muted: #5c6489;
  --accent: #6d4aff;
  --accent-2: #0891b2;
  --accent-grad: linear-gradient(135deg, #6d4aff 0%, #0ea5c6 100%);
  --shadow: 0 10px 30px -14px rgba(40, 50, 110, .28), inset 0 1px 0 rgba(255, 255, 255, .9);
  --glow: 0 0 0 1px rgba(109, 74, 255, .35), 0 8px 26px -10px rgba(109, 74, 255, .45);
  --plex: #d99a00;
  --ok: #059669; --warn: #b45309; --bad: #e11d48;
  color-scheme: light;
}

html { background: var(--bg); }
body, body.bg-slate-950 {
  background-color: var(--bg) !important;
  background-image:
    radial-gradient(900px 600px at 8% -10%, var(--bg-aurora-1), transparent 60%),
    radial-gradient(800px 520px at 100% 0%, var(--bg-aurora-2), transparent 55%),
    radial-gradient(700px 500px at 50% 110%, var(--bg-aurora-3), transparent 60%) !important;
  background-attachment: fixed;
  color: var(--text) !important;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- re-point Tailwind slate utilities at the theme ---- */
.bg-slate-950 { background-color: var(--bg) !important; }
.bg-slate-900, .bg-slate-900\/95 { background-color: var(--surface) !important; }
.bg-slate-950\/50, .bg-slate-950\/95 { background-color: var(--surface-2) !important; }
.bg-slate-800, .bg-slate-800\/60 { background-color: var(--surface-2) !important; }
.bg-slate-700 { background-color: var(--surface-3) !important; }
.hover\:bg-slate-800:hover { background-color: var(--surface-3) !important; }
.hover\:bg-slate-700:hover { background-color: var(--surface-3) !important; }
.border-slate-800, .border-slate-700, .border-slate-800\/60 { border-color: var(--border) !important; }
.divide-slate-800 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border) !important; }
.text-slate-100, .text-slate-200, .text-white { color: var(--text) !important; }
.text-slate-300 { color: var(--text-2) !important; }
.text-slate-400, .text-slate-500, .text-slate-600 { color: var(--muted) !important; }
.text-primary, .hover\:text-primary:hover { color: var(--accent-2) !important; }
html[data-theme="light"] .text-cyan-300, html[data-theme="light"] .text-cyan-400 { color: #0e7490 !important; }
html[data-theme="light"] .text-emerald-300, html[data-theme="light"] .text-emerald-400 { color: #047857 !important; }
html[data-theme="light"] .text-amber-200, html[data-theme="light"] .text-amber-300 { color: #92400e !important; }
html[data-theme="light"] .text-red-200, html[data-theme="light"] .text-red-300, html[data-theme="light"] .text-rose-300 { color: #be123c !important; }
html[data-theme="light"] .text-emerald-200 { color: #065f46 !important; }

/* ---- cards / panels ---- */
.rounded-xl.border, .rounded-lg.border.bg-slate-900, section.rounded-xl, .card {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}
.rounded-xl { border-radius: 16px !important; }

/* ---- sidebar / headers ---- */
aside#desktopSidebar, header.border-b, .sticky.top-0.z-40 {
  background: var(--surface) !important;
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border-color: var(--border) !important;
}
aside#desktopSidebar nav a, aside#desktopSidebar nav button { border-radius: 12px !important; transition: background .18s ease, color .18s ease, transform .18s ease; }
aside#desktopSidebar nav a:hover, aside#desktopSidebar nav button:hover { transform: translateX(2px); }
aside#desktopSidebar nav a.bg-slate-800 {
  background: linear-gradient(90deg, rgba(124, 92, 255, .22), rgba(34, 211, 238, .08)) !important;
  box-shadow: inset 2px 0 0 var(--accent);
  color: var(--text) !important;
}
aside#desktopSidebar nav svg, #mobileMenuNav svg { opacity: .9; width: 1.1rem; height: 1.1rem; }

/* ---- brand + Plex mark (top-left, both themes) ---- */
.plex-mark { width: 1.35rem; height: 1.35rem; flex: 0 0 auto; filter: drop-shadow(0 0 8px rgba(235, 175, 0, .45)); }
.plex-brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 10px;
  background: linear-gradient(145deg, rgba(235, 175, 0, .16), rgba(235, 175, 0, .04)); border: 1px solid rgba(235, 175, 0, .35); }

/* ---- form controls ---- */
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted) !important; opacity: .8; }
input:focus, select:focus, textarea:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .28) !important;
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* ---- buttons ---- */
.bg-primary, button.bg-primary, a.bg-primary, .bg-blue-600, .bg-emerald-600, .bg-emerald-500, .bg-indigo-600 {
  background-image: var(--accent-grad) !important;
  background-color: transparent !important;
  color: #fff !important;
  border: 0 !important;
  box-shadow: 0 6px 20px -8px rgba(124, 92, 255, .7);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.bg-primary:hover, .bg-blue-600:hover, .bg-emerald-600:hover, .bg-emerald-500:hover, .hover\:bg-primary-dark:hover, .hover\:bg-blue-700:hover {
  filter: brightness(1.1); box-shadow: var(--glow); transform: translateY(-1px);
  background-image: var(--accent-grad) !important;
}
button:disabled, .opacity-50 { cursor: not-allowed; }

/* ---- tables ---- */
table thead th { color: var(--muted) !important; font-weight: 600; letter-spacing: .02em; }
table tbody tr { transition: background .15s; }
table tbody tr:hover { background: rgba(124, 92, 255, .07); }
.border-t.border-slate-800, tr.border-t { border-color: var(--border) !important; }

/* ---- Plex SSO button (login) ---- */
.plex-sso-btn {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  background: linear-gradient(135deg, #1f1f23, #2b2b31) !important; color: #fff !important;
  border: 1px solid rgba(235, 175, 0, .55) !important;
  box-shadow: 0 0 0 1px rgba(235, 175, 0, .15), 0 10px 26px -12px rgba(235, 175, 0, .55);
  transition: transform .15s, box-shadow .2s;
}
.plex-sso-btn:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(235, 175, 0, .5), 0 12px 30px -10px rgba(235, 175, 0, .7); }
.plex-sso-btn .plex-mark { width: 1.2rem; height: 1.2rem; }
.plex-sso-tag { margin-left: .25rem; padding: .05rem .45rem; border-radius: 999px; font-size: .62rem; letter-spacing: .06em; text-transform: uppercase;
  background: rgba(235, 175, 0, .16); color: var(--plex); border: 1px solid rgba(235, 175, 0, .4); }
html[data-theme="light"] .plex-sso-btn { background: linear-gradient(135deg, #2a2a30, #3a3a42) !important; }

/* ---- theme toggle ---- */
.theme-toggle .theme-label-light, .theme-toggle .theme-icon-light { display: none; }
html[data-theme="light"] .theme-toggle .theme-label-light, html[data-theme="light"] .theme-toggle .theme-icon-light { display: inline; }
html[data-theme="light"] .theme-toggle .theme-label-dark, html[data-theme="light"] .theme-toggle .theme-icon-dark { display: none; }
.theme-fab { position: fixed; right: 16px; bottom: 16px; z-index: 60; width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); box-shadow: var(--glow); cursor: pointer; }
.theme-fab svg { width: 20px; height: 20px; }

/* ---- Plex people search (avatars) ---- */
.plex-search { position: relative; z-index: 40; isolation: isolate; }
.plex-search .avatar { width: 34px; height: 34px; border-radius: 999px; overflow: hidden; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-grad); color: #fff; font-weight: 700; flex: 0 0 auto; }
.plex-search .avatar img { width: 100%; height: 100%; object-fit: cover; }
.plex-search [data-results] { position: absolute; z-index: 90; left: 0; right: 0; top: calc(100% + 6px); background: var(--pop-bg, #151a36);
  border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); max-height: 320px; overflow: auto;
  }
.plex-search .row { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .8rem; text-align: left; background: transparent; border: 0; color: var(--text); cursor: pointer; }
.plex-search .row:hover { background: rgba(124, 92, 255, .14); }
.plex-search .who { display: flex; flex-direction: column; min-width: 0; }
.plex-search .who small { color: var(--muted); }
.plex-search .empty { padding: .8rem 1rem; color: var(--muted); font-size: .85rem; }
.plex-search [data-chip] { display: inline-flex; align-items: center; gap: .55rem; margin-top: .5rem; padding: .3rem .8rem .3rem .3rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-strong); }

/* ---- generic components used by new pages ---- */
.glass { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.kpi-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi { padding: 1.1rem 1.25rem; }
.kpi .label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.kpi .value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; margin-top: .35rem; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .6rem; border-radius: 999px; font-size: .72rem; border: 1px solid var(--border-strong); color: var(--text-2); }
.pill-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.pill-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.pill-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--accent-grad); }
.progress.done > i { background: linear-gradient(90deg, #10b981, #34d399); }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; padding: .3rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); width: fit-content; }
.tabs a, .tabs button { padding: .45rem 1rem; border-radius: 10px; color: var(--text-2); font-size: .85rem; background: transparent; border: 0; cursor: pointer; }
.tabs .active { background: var(--accent-grad); color: #fff; box-shadow: var(--glow); }
.gradient-text { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fade-in { animation: vfade .35s ease both; }
@keyframes vfade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* ---- insights / analytics ---- */
  #globe-wrap{position:relative;height:min(68vh,640px);border-radius:20px;overflow:hidden;background:radial-gradient(circle at 50% 40%,rgba(124,92,255,.12),transparent 65%),var(--surface)}
  #globe{width:100%;height:100%}
  .globe-tip{padding:.5rem .7rem;border-radius:10px;background:rgba(10,12,28,.92);color:#fff;font-size:12px;line-height:1.35;max-width:260px;border:1px solid rgba(139,107,255,.5)}
  .grid-cards{display:grid;gap:.9rem;grid-template-columns:repeat(auto-fill,minmax(230px,1fr))}
  .title-card{padding:1rem;border-radius:16px;background:var(--surface);border:1px solid var(--border);transition:.18s}
  .title-card:hover{border-color:var(--accent);transform:translateY(-2px);box-shadow:var(--glow)}
  .title-card h3{font-weight:600;font-size:.95rem;line-height:1.25;margin:.15rem 0 .5rem;overflow-wrap:anywhere}
  .title-card small{color:var(--muted)}
  .row-meta{display:flex;justify-content:space-between;gap:.5rem;font-size:.78rem;color:var(--text-2);margin-top:.35rem}
  .insights-toolbar{display:flex;flex-wrap:wrap;gap:.6rem;align-items:center;margin:1rem 0}
  .insights-toolbar select,.insights-toolbar input{padding:.5rem .8rem;font-size:.85rem}
  .pager{display:flex;gap:.6rem;align-items:center;justify-content:center;margin-top:1.2rem;font-size:.85rem}
  .pager button{padding:.4rem .9rem;border-radius:10px;border:1px solid var(--border-strong);background:var(--surface);color:var(--text);cursor:pointer}
  .pager button:disabled{opacity:.4;cursor:not-allowed}

.an-grid{display:grid;gap:1rem;grid-template-columns:repeat(auto-fit,minmax(320px,1fr))}
.an-card{padding:1.1rem 1.25rem;border-radius:18px;background:var(--surface);border:1px solid var(--border);box-shadow:var(--shadow);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px)}
.an-card.wide{grid-column:1/-1}
.an-card h3{font-size:.95rem;font-weight:600;margin:0 0 .15rem}
.an-card .hint{color:var(--muted);font-size:.75rem;margin-bottom:.8rem}
.an-bars{display:flex;align-items:flex-end;gap:2px;height:150px}
.an-bars i{flex:1;min-width:2px;border-radius:3px 3px 0 0;background:var(--accent-grad);opacity:.9;position:relative}
.an-bars i:hover{opacity:1;filter:brightness(1.25)}
.an-axis{display:flex;justify-content:space-between;font-size:.68rem;color:var(--muted);margin-top:.3rem}
.an-heat{display:grid;grid-template-columns:2.2rem repeat(24,minmax(0,1fr));gap:2px;font-size:.62rem;color:var(--muted)}
.an-heat b{font-weight:400;align-self:center}
.an-heat span{aspect-ratio:1;min-height:10px;min-width:0;border-radius:3px;background:var(--surface-3)}
.an-hbar{display:grid;grid-template-columns:minmax(80px,32%) 1fr auto;gap:.6rem;align-items:center;font-size:.8rem;margin:.35rem 0}
.an-hbar .lbl{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.an-hbar .bar{height:8px;border-radius:999px;background:var(--surface-3);overflow:hidden}
.an-hbar .bar i{display:block;height:100%;border-radius:inherit;background:var(--accent-grad)}
.an-hbar .bar.warn i{background:linear-gradient(90deg,#f59e0b,#fb7185)}
.an-hbar .bar.ok i{background:linear-gradient(90deg,#10b981,#34d399)}
.an-donut{width:120px;height:120px;border-radius:50%;position:relative;flex:0 0 auto}
.an-donut::after{content:"";position:absolute;inset:24px;border-radius:50%;background:var(--surface)}
.an-legend{display:flex;flex-direction:column;gap:.3rem;font-size:.8rem}
.an-legend span::before{content:"";display:inline-block;width:.6rem;height:.6rem;border-radius:3px;margin-right:.45rem;background:var(--c)}
.an-svg{width:100%;height:160px;display:block}
.an-list{list-style:none;margin:0;padding:0;font-size:.82rem}
.an-list li{display:flex;justify-content:space-between;gap:.6rem;padding:.35rem 0;border-bottom:1px solid var(--border)}
.an-list li:last-child{border-bottom:0}
.an-empty{color:var(--muted);font-size:.85rem;padding:.6rem 0}

/* ---- Right-to-left languages (Arabic, Hebrew) ---- */
[dir="rtl"] { text-align: start; }
[dir="rtl"] .text-left  { text-align: right; }
[dir="rtl"] .text-right { text-align: left; }
[dir="rtl"] .ml-auto { margin-left: 0; margin-right: auto; }
[dir="rtl"] .mr-auto { margin-right: 0; margin-left: auto; }
[dir="rtl"] .ml-1 { margin-left: 0; margin-right: .25rem; }
[dir="rtl"] .ml-2 { margin-left: 0; margin-right: .5rem; }
[dir="rtl"] .ml-3 { margin-left: 0; margin-right: .75rem; }
[dir="rtl"] .mr-1 { margin-right: 0; margin-left: .25rem; }
[dir="rtl"] .mr-2 { margin-right: 0; margin-left: .5rem; }
[dir="rtl"] .mr-3 { margin-right: 0; margin-left: .75rem; }
[dir="rtl"] .pl-3 { padding-left: 0; padding-right: .75rem; }
[dir="rtl"] .pr-3 { padding-right: 0; padding-left: .75rem; }
[dir="rtl"] .pl-4 { padding-left: 0; padding-right: 1rem; }
[dir="rtl"] .pr-4 { padding-right: 0; padding-left: 1rem; }
[dir="rtl"] .border-l { border-left-width: 0; border-right-width: 1px; }
[dir="rtl"] .border-r { border-right-width: 0; border-left-width: 1px; }
[dir="rtl"] .left-0  { left: auto; right: 0; }
[dir="rtl"] .right-0 { right: auto; left: 0; }
[dir="rtl"] .left-3  { left: auto; right: .75rem; }
[dir="rtl"] .right-3 { right: auto; left: .75rem; }
/* Technical values stay left-to-right inside RTL pages */
[dir="rtl"] code, [dir="rtl"] pre, [dir="rtl"] kbd,
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="url"],
[dir="rtl"] input[type="password"], [dir="rtl"] input[type="number"] { direction: ltr; text-align: start; unicode-bidi: plaintext; }
[dir="rtl"] .theme-fab, [dir="rtl"] #theme-fab { left: 1rem; right: auto; }

/* opaque popovers (search suggestions must stay readable above the fields below) */
:root { --pop-bg: #151a36; }
html[data-theme="light"] { --pop-bg: #ffffff; }
.plex-search .row { position: relative; line-height: 1.25; }
.plex-search .who { overflow: hidden; }
.plex-search .who b, .plex-search .who small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* language picker */
.lang-select { display: inline-flex; align-items: center; gap: .4rem; }
.lang-select-icon { width: 16px; height: 16px; flex: 0 0 auto; opacity: .8; }
.lang-select select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: .3rem .5rem; font-size: .8rem; max-width: 11rem; }
