/* ============================================================
   BharatNews Admin — premium design system
   Dark-first, glassmorphic, variable-driven (light theme ready).
   ============================================================ */
:root {
  --bg:        #080b12;
  --bg-grad-1: #0e1524;
  --bg-grad-2: #0a0e18;
  --surface:   rgba(255,255,255,.038);
  --surface-2: rgba(255,255,255,.06);
  --surface-hover: rgba(255,255,255,.09);
  --border:    rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --text:      #e8ecf4;
  --text-muted:#9aa6bd;
  --text-dim:  #64708a;
  --brand:     #e11d2a;
  --brand-2:   #ff5a4d;
  --brand-ink: #ff8a80;
  --brand-glow: rgba(225,29,42,.45);
  --ring:      rgba(225,29,42,.55);
  --shadow:    0 18px 40px -18px rgba(0,0,0,.7);
  --radius:    16px;
  --sidebar-w: 264px;
  --sidebar-collapsed: 78px;
}
html.admin-light {
  --bg:#eef1f6; --bg-grad-1:#f6f8fc; --bg-grad-2:#eaeef5;
  --surface:rgba(15,23,42,.035); --surface-2:rgba(15,23,42,.06); --surface-hover:rgba(15,23,42,.09);
  --border:rgba(15,23,42,.10); --border-strong:rgba(15,23,42,.16);
  --text:#0f172a; --text-muted:#475569; --text-dim:#94a3b8;
  --shadow:0 18px 40px -22px rgba(15,23,42,.35);
}

html.dark body {
  background:
    radial-gradient(1100px 600px at 82% -8%, rgba(225,29,42,.10), transparent 60%),
    radial-gradient(900px 520px at -5% 100%, rgba(56,80,220,.12), transparent 55%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

/* ---- Scrollbars ------------------------------------------------ */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(148,163,184,.28); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.5); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---- App shell ------------------------------------------------ */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 14px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  border-right: 1px solid var(--border); backdrop-filter: blur(14px);
  transition: width .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto; overflow-x: hidden;
}
.admin-brand { display:flex; align-items:center; gap:.6rem; padding:.2rem .5rem 1rem; }
.admin-brand .logo {
  width:38px; height:38px; border-radius:12px; flex-shrink:0;
  background: linear-gradient(135deg, var(--brand), #7a0a12);
  display:grid; place-items:center; color:#fff; font-weight:900; font-size:20px;
  box-shadow: 0 8px 20px -6px var(--brand-glow); font-family:'Tiro Devanagari Hindi',serif;
}
.admin-brand .name { font-weight:800; font-size:1.05rem; line-height:1.15; letter-spacing:-.01em; min-width:0; }
.admin-brand .name b { color: var(--brand-ink); }

.nav-group { margin-top: .5rem; }
.nav-group-label {
  font-size:10px; font-weight:800; letter-spacing:.14em; text-transform:uppercase;
  color: var(--text-dim); padding: .4rem .8rem .3rem; white-space:nowrap;
}
.nav-item {
  position:relative; display:flex; align-items:center; gap:.7rem;
  padding:.55rem .7rem; border-radius:12px; font-weight:600; font-size:.9rem;
  color: var(--text-muted); cursor:pointer; margin-bottom:2px; white-space:nowrap;
  transition: background .16s, color .16s, transform .12s;
}
.nav-item .nav-ico {
  width:30px; height:30px; flex-shrink:0; border-radius:9px; display:grid; place-items:center;
  font-size:15px; background: var(--surface); border:1px solid var(--border); transition: all .16s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover .nav-ico { background: var(--surface-hover); }
.nav-item.active { color:#fff; background: linear-gradient(90deg, rgba(225,29,42,.22), rgba(225,29,42,.06)); }
.nav-item.active .nav-ico { background: linear-gradient(135deg, var(--brand), #8f0d15); border-color: transparent; box-shadow: 0 6px 16px -6px var(--brand-glow); }
.nav-item.active::before {
  content:''; position:absolute; left:-14px; top:50%; transform:translateY(-50%);
  width:4px; height:22px; border-radius:0 4px 4px 0; background: var(--brand);
  box-shadow: 0 0 12px var(--brand-glow);
}

/* Collapsed rail */
.admin-shell.collapsed .admin-sidebar { width: var(--sidebar-collapsed); }
.admin-shell.collapsed .admin-sidebar .nav-item span:not(.nav-ico),
.admin-shell.collapsed .admin-sidebar .nav-group-label,
.admin-shell.collapsed .admin-sidebar .admin-brand .name,
.admin-shell.collapsed .admin-sidebar .sb-user .u-meta { display:none; }
.admin-shell.collapsed .admin-sidebar .nav-item { justify-content:center; padding:.55rem; }

.sb-user { margin-top:auto; padding-top:12px; border-top:1px solid var(--border); }
.sb-user .card { display:flex; align-items:center; gap:.6rem; padding:.5rem .6rem; border-radius:12px; background:var(--surface); }
.sb-user .avatar { width:34px; height:34px; border-radius:10px; flex-shrink:0; display:grid; place-items:center;
  background:linear-gradient(135deg,#3850dc,#7a29c9); color:#fff; font-weight:800; font-size:14px; }

/* ---- Topbar --------------------------------------------------- */
.admin-topbar {
  position: sticky; top: 0; z-index: 40; display:flex; align-items:center; gap:14px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(18px);
}
.icon-btn {
  width:38px; height:38px; border-radius:11px; display:grid; place-items:center;
  background: var(--surface); border:1px solid var(--border); color: var(--text-muted);
  cursor:pointer; transition: all .15s; font-size:17px;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); transform: translateY(-1px); }

.cmdk-trigger {
  display:flex; align-items:center; gap:.6rem; min-width:200px; max-width:420px; flex:1;
  padding:.55rem .85rem; border-radius:12px; background: var(--surface); border:1px solid var(--border);
  color: var(--text-dim); font-size:.9rem; cursor:pointer; transition: all .15s;
}
.cmdk-trigger:hover { border-color: var(--border-strong); background: var(--surface-2); }
.cmdk-trigger kbd {
  margin-left:auto; font-size:11px; font-weight:700; padding:2px 7px; border-radius:6px;
  background: var(--surface-2); border:1px solid var(--border); color: var(--text-muted); font-family:inherit;
}
.provider-chip { display:flex; align-items:center; gap:.4rem; font-size:.78rem; font-weight:700;
  padding:.35rem .7rem; border-radius:999px; background: rgba(56,80,220,.14); color:#a9b6ff; border:1px solid rgba(56,80,220,.25); white-space:nowrap; }

/* ---- Cards / panels ------------------------------------------ */
.panel { background: var(--surface); border:1px solid var(--border); border-radius: var(--radius); backdrop-filter: blur(8px); }

.stat-card {
  position:relative; overflow:hidden; border-radius: var(--radius); padding: 1.1rem 1.15rem;
  background: linear-gradient(150deg, var(--surface-2), var(--surface));
  border:1px solid var(--border); transition: transform .2s, border-color .2s, box-shadow .2s;
}
.stat-card::after { content:''; position:absolute; inset:0 0 auto auto; width:140px; height:140px;
  background: radial-gradient(circle at 100% 0%, var(--kc, rgba(225,29,42,.16)), transparent 70%); pointer-events:none; }
.stat-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.stat-ico { width:42px; height:42px; border-radius:12px; display:grid; place-items:center; font-size:20px;
  background: var(--kc-solid, rgba(225,29,42,.16)); }
.stat-num { font-size: 1.9rem; font-weight:800; letter-spacing:-.02em; line-height:1.1; margin-top:.6rem; }
.stat-label { font-size:.82rem; color: var(--text-muted); }
.trend { display:inline-flex; align-items:center; gap:.2rem; font-size:.72rem; font-weight:800; padding:.12rem .45rem; border-radius:999px; }
.trend.up { color:#34d399; background:rgba(52,211,153,.14); }
.trend.down { color:#fb7185; background:rgba(251,113,133,.14); }
.trend.flat { color:var(--text-dim); background:var(--surface-2); }

/* ---- Buttons -------------------------------------------------- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:.4rem;
  padding:.5rem .95rem; border-radius:11px; font-weight:700; font-size:.85rem; cursor:pointer;
  border:1px solid transparent; transition: transform .12s, box-shadow .15s, background .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), #a80f18); color:#fff; box-shadow: 0 10px 24px -10px var(--brand-glow); }
.btn-primary:hover { box-shadow: 0 14px 30px -10px var(--brand-glow); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #991b1b); color:#fff; box-shadow: 0 10px 24px -10px rgba(220,38,38,.5); }
.btn-danger:hover { box-shadow: 0 14px 30px -10px rgba(220,38,38,.55); }

/* ---- Inputs --------------------------------------------------- */
.input { width:100%; padding:.6rem .85rem; border-radius:11px; background: var(--surface-2);
  border:1px solid var(--border); color: var(--text); transition: border-color .15s, box-shadow .15s; }
.input::placeholder { color: var(--text-dim); }
.input:focus { outline:none; border-color: var(--ring); box-shadow: 0 0 0 3px rgba(225,29,42,.16); }
select.input option { background:#0e1524; color:var(--text); }

/* ---- Badge ---------------------------------------------------- */
.badge { display:inline-flex; align-items:center; font-size:.7rem; font-weight:700; padding:.18rem .55rem; border-radius:8px; }

/* ---- Tables --------------------------------------------------- */
table thead th { color: var(--text-dim); font-weight:800; letter-spacing:.04em; }
table tbody tr { transition: background .12s; }
table tbody tr:hover { background: var(--surface); }

/* ---- Skeletons ------------------------------------------------ */
.sk { position:relative; overflow:hidden; background: var(--surface-2); border-radius:12px; }
.sk::after { content:''; position:absolute; inset:0; transform:translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); animation: sk 1.3s infinite; }
@keyframes sk { 100% { transform: translateX(100%); } }

/* ---- View transition ------------------------------------------ */
#content.swapping { opacity:0; transform: translateY(8px); }
#content { transition: opacity .28s, transform .28s; }

/* ---- Command palette ------------------------------------------ */
.cmdk-backdrop { position:fixed; inset:0; z-index:90; background: rgba(4,7,12,.6); backdrop-filter: blur(6px);
  display:flex; align-items:flex-start; justify-content:center; padding-top:12vh; animation: fade .18s ease; }
@keyframes fade { from { opacity:0; } }
.cmdk-box { width:min(620px,92vw); border-radius:18px; overflow:hidden; border:1px solid var(--border-strong);
  background: linear-gradient(180deg, #121a2b, #0d1420); box-shadow: 0 40px 80px -20px rgba(0,0,0,.8);
  animation: pop .2s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { transform: translateY(-10px) scale(.98); opacity:0; } }
.cmdk-input { width:100%; padding:1.1rem 1.2rem; background:transparent; border:none; outline:none;
  color: var(--text); font-size:1.05rem; border-bottom:1px solid var(--border); }
.cmdk-list { max-height:min(420px,56vh); overflow-y:auto; padding:.5rem; }
.cmdk-sec { font-size:10px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; color:var(--text-dim); padding:.6rem .7rem .3rem; }
.cmdk-item { display:flex; align-items:center; gap:.75rem; padding:.6rem .7rem; border-radius:11px; cursor:pointer; color:var(--text-muted); }
.cmdk-item .ci-ico { width:32px; height:32px; border-radius:9px; display:grid; place-items:center; background:var(--surface-2); border:1px solid var(--border); font-size:15px; }
.cmdk-item.sel, .cmdk-item:hover { background: var(--surface-2); color: var(--text); }
.cmdk-item.sel { box-shadow: inset 0 0 0 1px var(--border-strong); }
.cmdk-item .ci-hint { margin-left:auto; font-size:11px; color:var(--text-dim); }

/* Keep .hidden authoritative over the display:flex overlays above
   (admin.css loads after tailwind.css, so a bare .hidden would lose). */
.cmdk-backdrop.hidden, #toast.hidden { display: none !important; }

/* ---- Toast ---------------------------------------------------- */
#toast { display:flex; align-items:center; gap:.5rem; padding:.7rem 1.1rem; border-radius:13px;
  font-weight:700; box-shadow: 0 18px 40px -14px rgba(0,0,0,.6); border:1px solid var(--border-strong);
  background: linear-gradient(135deg,#15803d,#166534); color:#fff; }

/* ---- Dropdown menu (avatar) ----------------------------------- */
.menu { position:absolute; right:0; top:calc(100% + 8px); width:220px; z-index:70; padding:.4rem;
  border-radius:14px; border:1px solid var(--border-strong); background: linear-gradient(180deg,#131b2c,#0e1522); box-shadow: var(--shadow); }
.menu a, .menu button { display:flex; width:100%; align-items:center; gap:.6rem; padding:.55rem .7rem; border-radius:10px;
  color:var(--text-muted); font-size:.88rem; font-weight:600; cursor:pointer; background:none; border:none; text-align:left; }
.menu a:hover, .menu button:hover { background:var(--surface-2); color:var(--text); }

/* ---- Bell panel ----------------------------------------------- */
#bell-panel { border-radius:16px; border:1px solid var(--border-strong); background: linear-gradient(180deg,#131b2c,#0e1522); }

/* ---- Section headings inside views ---------------------------- */
.view-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:1.1rem; }
.view-head h2 { font-size:1.15rem; font-weight:800; letter-spacing:-.01em; }

/* Quill retheme to match tokens */
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--border) !important; }
.ql-toolbar.ql-snow { background: var(--surface); border-radius:12px 12px 0 0; }
.ql-container.ql-snow { background: var(--surface); border-radius:0 0 12px 12px; min-height:320px; }
.ql-editor { color:var(--text); font-family:'Noto Sans Devanagari',sans-serif; font-size:1rem; }
.ql-editor.ql-blank::before { color: var(--text-dim); font-style:normal; }
.ql-snow .ql-stroke { stroke: var(--text-muted); } .ql-snow .ql-fill { fill: var(--text-muted); } .ql-snow .ql-picker { color: var(--text-muted); }

/* Light-theme remaps for utility classes used inside views */
html.admin-light .bg-white\/5 { background-color: rgba(15,23,42,.04) !important; }
html.admin-light .bg-white\/10 { background-color: rgba(15,23,42,.07) !important; }
html.admin-light .border-white\/5 { border-color: rgba(15,23,42,.07) !important; }
html.admin-light .border-white\/10 { border-color: rgba(15,23,42,.12) !important; }
html.admin-light .text-gray-200 { color:#334155 !important; }
html.admin-light .text-gray-300 { color:#475569 !important; }
html.admin-light .text-gray-400 { color:#64748b !important; }
html.admin-light .text-gray-500 { color:#94a3b8 !important; }
html.admin-light body, html.admin-light .text-gray-200 { color:#0f172a; }

/* ---- Feature-rich editor -------------------------------------------------- */
.field { display:flex; flex-direction:column; gap:.35rem; }
.field > label, .field-label { font-size:.72rem; font-weight:700; letter-spacing:.02em; text-transform:uppercase; color: var(--text-dim); }
.field .hint { font-size:.72rem; color: var(--text-dim); }
textarea.input { min-height:64px; resize:vertical; line-height:1.5; }
.counter { font-size:.68rem; color: var(--text-dim); text-align:right; }
.counter.over { color:#fb7185; }

/* Toggle switch */
.switch { display:flex; align-items:center; gap:.6rem; cursor:pointer; user-select:none; padding:.5rem .6rem; border:1px solid var(--border); border-radius:12px; background:var(--surface); transition:border-color .16s, background .16s; }
.switch:hover { border-color: var(--border-strong); }
.switch input { display:none; }
.switch .track { width:38px; height:22px; border-radius:999px; background:var(--surface-hover); position:relative; transition:background .18s; flex:0 0 auto; }
.switch .track::after { content:''; position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%; background:#fff; transition:transform .18s; box-shadow:0 1px 3px rgba(0,0,0,.4); }
.switch input:checked + .track { background: linear-gradient(135deg, var(--brand), #8f0d15); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch .sw-text { font-size:.82rem; font-weight:600; }
.switch .sw-sub { font-size:.68rem; color:var(--text-dim); font-weight:400; }

/* Hero image uploader */
.hero-box { border:1px dashed var(--border-strong); border-radius: var(--radius); overflow:hidden; background:var(--surface); }
.hero-drop { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.5rem; padding:2rem 1rem; text-align:center; cursor:pointer; transition:background .16s; color:var(--text-muted); }
.hero-drop:hover, .hero-drop.drag { background:var(--surface-2); }
.hero-drop .big { font-size:2rem; }
.hero-preview { position:relative; aspect-ratio:16/9; background:#000; }
.hero-preview img { width:100%; height:100%; object-fit:cover; display:block; }
.hero-preview .hero-tools { position:absolute; inset:auto 0 0 0; display:flex; gap:.4rem; padding:.5rem; background:linear-gradient(0deg, rgba(0,0,0,.7), transparent); }
.hero-preview .hero-tools .btn { backdrop-filter:blur(4px); }

/* Crop modal */
.crop-modal { position:fixed; inset:0; z-index:90; background:rgba(4,7,12,.78); backdrop-filter:blur(6px); display:flex; align-items:center; justify-content:center; padding:1rem; }
.crop-card { width:100%; max-width:860px; background:var(--surface-solid, #10161f); border:1px solid var(--border-strong); border-radius:var(--radius); box-shadow:var(--shadow); display:flex; flex-direction:column; max-height:92vh; }
html.admin-light .crop-card { background:#fff; }
.crop-head { display:flex; align-items:center; justify-content:space-between; padding:.9rem 1.1rem; border-bottom:1px solid var(--border); }
.crop-stage { flex:1; min-height:0; background:#0b0e14; overflow:hidden; }
.crop-stage img { display:block; max-width:100%; }
.crop-foot { display:flex; align-items:center; gap:.6rem; flex-wrap:wrap; padding:.8rem 1.1rem; border-top:1px solid var(--border); }
.seg { display:inline-flex; border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.seg button { padding:.35rem .7rem; font-size:.78rem; font-weight:700; background:var(--surface); color:var(--text-muted); border:0; cursor:pointer; }
.seg button.on { background:linear-gradient(135deg,var(--brand),#8f0d15); color:#fff; }
.cropper-view-box, .cropper-face { border-radius:0; }

/* Publish/meta side rail cards */
.rail-card { padding:1rem; }
.rail-card h3 { font-size:.9rem; font-weight:800; margin-bottom:.15rem; }

/* ---- Light-theme fixes for components with hardcoded dark surfaces ------- */
html.admin-light select.input option { background:#ffffff; color:#0f172a; }
html.admin-light .cmdk-box { background: linear-gradient(180deg,#ffffff,#f4f6fb); box-shadow: 0 40px 80px -24px rgba(15,23,42,.35); }
html.admin-light .menu { background: linear-gradient(180deg,#ffffff,#f5f7fb); }
html.admin-light #bell-panel { background: linear-gradient(180deg,#ffffff,#f5f7fb); }
html.admin-light .cmdk-backdrop { background: rgba(15,23,42,.28); }
html.admin-light .sk::after { background: linear-gradient(90deg, transparent, rgba(15,23,42,.06), transparent); }
html.admin-light .text-gray-600 { color:#64748b !important; }
html.admin-light .text-gray-100, html.admin-light .text-gray-50 { color:#1e293b !important; }
/* Quill editor surface reads too subtle on light — give it a defined field */
html.admin-light .ql-toolbar.ql-snow, html.admin-light .ql-container.ql-snow { background:#ffffff; border-color: var(--border-strong); }
html.admin-light .provider-chip { background:#ffffff; }
/* Modal cards sit over a dark bg-black/60 overlay — the translucent .panel would read
   dark in light theme, so give modal panels a solid surface. */
html.admin-light .bg-black\/60 .panel { background:#ffffff; border-color: var(--border-strong); backdrop-filter:none; }
/* Calendar event chips use 200-level text (for dark bg) — darken on light theme for contrast. */
html.admin-light .text-amber-200 { color:#b45309 !important; }
html.admin-light .text-green-200 { color:#15803d !important; }
html.admin-light .text-red-200   { color:#b91c1c !important; }
html.admin-light .text-blue-200  { color:#1d4ed8 !important; }
