/* ==========================================================================
   NewsCMS Admin Design System
   Layers on top of Tailwind utilities already used in views.
   Accent color comes from the per-site setting (white-label) via --accent.
   ========================================================================== */

:root {
    --accent: #4f46e5;
    --accent-ink: #ffffff;
    --accent-soft: color-mix(in srgb, var(--accent) 10%, #ffffff);
    --accent-softer: color-mix(in srgb, var(--accent) 6%, #ffffff);
    --ring: color-mix(in srgb, var(--accent) 35%, transparent);
    --sidebar-w: 16rem;
    --sidebar-w-collapsed: 4.25rem;
}

html { font-family: 'Inter', 'Noto Sans Bengali', ui-sans-serif, system-ui, -apple-system, sans-serif; }
body { -webkit-font-smoothing: antialiased; }

/* --------------------------------------------------------------------------
   Form controls — consistent look everywhere without touching each view
   -------------------------------------------------------------------------- */
.adm-main input[type="text"],
.adm-main input[type="email"],
.adm-main input[type="url"],
.adm-main input[type="number"],
.adm-main input[type="password"],
.adm-main input[type="search"],
.adm-main input[type="datetime-local"],
.adm-main input[type="date"],
.adm-main textarea,
.adm-main select {
    border-color: #e2e8f0;
    border-radius: 0.5rem;
    background-color: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.adm-main input:focus,
.adm-main textarea:focus,
.adm-main select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}
.adm-main input[type="color"] { border-radius: 0.5rem; cursor: pointer; }
.adm-main label { color: #334155; }

/* Field-level error state (set by server-side @error or JS) */
.adm-invalid { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgb(239 68 68 / .15) !important; }
.adm-error-text { color: #dc2626; font-size: .75rem; margin-top: .25rem; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: var(--accent); color: var(--accent-ink);
    padding: .625rem 1.25rem; border-radius: .5rem;
    font-size: .875rem; font-weight: 600; line-height: 1.25rem;
    transition: filter .15s, transform .05s;
    box-shadow: 0 1px 2px rgb(0 0 0 / .08);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: #fff; color: #334155; border: 1px solid #e2e8f0;
    padding: .625rem 1.25rem; border-radius: .5rem;
    font-size: .875rem; font-weight: 500; line-height: 1.25rem;
    transition: background .15s;
}
.btn-secondary:hover { background: #f8fafc; }

.btn-danger {
    display: inline-flex; align-items: center; gap: .375rem;
    color: #dc2626; font-size: .8125rem; font-weight: 500;
    padding: .375rem .75rem; border-radius: .375rem;
    transition: background .15s;
}
.btn-danger:hover { background: rgb(220 38 38 / .08); }

/* --------------------------------------------------------------------------
   Toggle switch (replaces bare checkboxes)  <label class="adm-switch">…
   -------------------------------------------------------------------------- */
.adm-switch { display: inline-flex; align-items: center; gap: .625rem; cursor: pointer; user-select: none; }
.adm-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.adm-switch .track {
    width: 2.25rem; height: 1.25rem; border-radius: 9999px; background: #cbd5e1;
    position: relative; flex-shrink: 0; transition: background .18s;
}
.adm-switch .track::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: calc(1.25rem - 4px); height: calc(1.25rem - 4px);
    border-radius: 9999px; background: #fff; transition: transform .18s;
    box-shadow: 0 1px 2px rgb(0 0 0 / .25);
}
.adm-switch input:checked + .track { background: var(--accent); }
.adm-switch input:checked + .track::after { transform: translateX(1rem); }
.adm-switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--ring); }

/* --------------------------------------------------------------------------
   Tag chips input
   -------------------------------------------------------------------------- */
.adm-tags {
    display: flex; flex-wrap: wrap; gap: .375rem; align-items: center;
    border: 1px solid #e2e8f0; border-radius: .5rem; background: #fff;
    padding: .375rem .5rem; cursor: text; min-height: 2.625rem;
}
.adm-tags:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.adm-tags .chip {
    display: inline-flex; align-items: center; gap: .25rem;
    background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 80%, #000);
    border-radius: .375rem; padding: .125rem .25rem .125rem .5rem;
    font-size: .8125rem; font-weight: 500;
}
.adm-tags .chip button { border-radius: .25rem; padding: 0 .25rem; line-height: 1.1; font-size: .875rem; }
.adm-tags .chip button:hover { background: rgb(0 0 0 / .08); }
.adm-tags input { border: none !important; box-shadow: none !important; outline: none; flex: 1; min-width: 7rem; padding: .25rem; font-size: .875rem; background: transparent; }

/* --------------------------------------------------------------------------
   Character counter
   -------------------------------------------------------------------------- */
.adm-counter { font-size: .6875rem; font-variant-numeric: tabular-nums; float: right; margin-top: .25rem; color: #94a3b8; }
.adm-counter.ok   { color: #16a34a; }
.adm-counter.warn { color: #d97706; }
.adm-counter.over { color: #dc2626; font-weight: 600; }

/* --------------------------------------------------------------------------
   Image dropzone
   -------------------------------------------------------------------------- */
.adm-dropzone {
    border: 2px dashed #cbd5e1; border-radius: .625rem; background: #f8fafc;
    padding: 1.25rem; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
    position: relative;
}
.adm-dropzone:hover, .adm-dropzone.dragover { border-color: var(--accent); background: var(--accent-softer); }
.adm-dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.adm-dropzone .dz-preview img { max-height: 11rem; margin: 0 auto .5rem; border-radius: .5rem; box-shadow: 0 1px 3px rgb(0 0 0 / .15); }
.adm-dropzone .dz-remove { position: relative; z-index: 2; }

/* --------------------------------------------------------------------------
   Searchable select (combobox)
   -------------------------------------------------------------------------- */
.adm-combo { position: relative; }
.adm-combo-btn {
    width: 100%; text-align: left; border: 1px solid #e2e8f0; border-radius: .5rem;
    background: #fff; padding: .5rem .75rem; font-size: .875rem;
    display: flex; justify-content: space-between; align-items: center; gap: .5rem;
}
.adm-combo-btn:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.adm-combo-panel {
    position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border: 1px solid #e2e8f0; border-radius: .5rem;
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / .15); overflow: hidden;
}
.adm-combo-panel input { width: 100%; border: none !important; border-bottom: 1px solid #f1f5f9 !important; border-radius: 0 !important; box-shadow: none !important; padding: .5rem .75rem; font-size: .875rem; }
.adm-combo-list { max-height: 13rem; overflow-y: auto; padding: .25rem; }
.adm-combo-list button {
    display: block; width: 100%; text-align: left; padding: .4rem .625rem;
    font-size: .875rem; border-radius: .375rem;
}
.adm-combo-list button:hover, .adm-combo-list button.active { background: var(--accent-soft); }
.adm-combo-list button[aria-selected="true"] { font-weight: 600; color: var(--accent); }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
#adm-toasts { position: fixed; top: 1rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: 22rem; }
.adm-toast {
    display: flex; align-items: flex-start; gap: .625rem;
    background: #0f172a; color: #f1f5f9; border-radius: .625rem;
    padding: .75rem 1rem; font-size: .875rem; box-shadow: 0 10px 25px -5px rgb(0 0 0 / .35);
    animation: adm-toast-in .25s ease-out;
}
.adm-toast.success { border-left: 3px solid #22c55e; }
.adm-toast.error   { border-left: 3px solid #ef4444; }
.adm-toast.info    { border-left: 3px solid var(--accent); }
@keyframes adm-toast-in { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: none; } }
.adm-toast.leaving { opacity: 0; transition: opacity .3s; }

/* --------------------------------------------------------------------------
   Command palette
   -------------------------------------------------------------------------- */
#adm-palette { position: fixed; inset: 0; z-index: 90; display: none; }
#adm-palette.open { display: block; }
#adm-palette .backdrop { position: absolute; inset: 0; background: rgb(2 6 23 / .55); backdrop-filter: blur(2px); }
#adm-palette .panel {
    position: relative; max-width: 34rem; margin: 10vh auto 0; background: #fff;
    border-radius: .875rem; box-shadow: 0 25px 60px -10px rgb(0 0 0 / .45); overflow: hidden;
}
#adm-palette .panel input { width: 100%; border: none; outline: none; padding: 1rem 1.25rem; font-size: 1rem; border-bottom: 1px solid #f1f5f9; }
#adm-palette .results { max-height: 45vh; overflow-y: auto; padding: .375rem; }
#adm-palette .results a {
    display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem;
    border-radius: .5rem; font-size: .875rem; color: #334155;
}
#adm-palette .results a.active, #adm-palette .results a:hover { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 80%, #000); }
#adm-palette .results .group-label { padding: .5rem .75rem .25rem; font-size: .6875rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: #94a3b8; }
#adm-palette .empty { padding: 1.5rem; text-align: center; color: #94a3b8; font-size: .875rem; }

/* --------------------------------------------------------------------------
   Confirm modal
   -------------------------------------------------------------------------- */
#adm-confirm { position: fixed; inset: 0; z-index: 95; display: none; }
#adm-confirm.open { display: block; }
#adm-confirm .backdrop { position: absolute; inset: 0; background: rgb(2 6 23 / .55); }
#adm-confirm .panel {
    position: relative; max-width: 26rem; margin: 22vh auto 0; background: #fff;
    border-radius: .875rem; padding: 1.5rem; box-shadow: 0 25px 60px -10px rgb(0 0 0 / .45);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.adm-sidebar { width: var(--sidebar-w); transition: width .2s ease, transform .25s ease; }
.adm-nav-item {
    display: flex; align-items: center; gap: .625rem;
    padding: .5rem .625rem; border-radius: .5rem;
    font-size: .8438rem; color: #94a3b8; white-space: nowrap;
    border-left: 2px solid transparent; transition: background .12s, color .12s;
}
.adm-nav-item:hover { background: rgb(255 255 255 / .06); color: #e2e8f0; }
.adm-nav-item.active { background: rgb(255 255 255 / .08); color: #fff; border-left-color: var(--accent); }
.adm-nav-item svg { width: 1.05rem; height: 1.05rem; flex-shrink: 0; opacity: .8; }
.adm-nav-item.active svg { color: var(--accent); opacity: 1; }
.adm-nav-group { padding: 1rem .625rem .25rem; font-size: .625rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #475569; white-space: nowrap; }

/* Saved filter views — chip row injected above filter forms */
.adm-views { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; margin-bottom: .75rem; }
.adm-view-chip {
    display: inline-flex; align-items: center; gap: .25rem;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 999px;
    padding: .25rem .3rem .25rem .75rem; font-size: .75rem; color: #475569;
}
.adm-view-chip a { color: inherit; text-decoration: none; }
.adm-view-chip:hover { border-color: #94a3b8; }
.adm-view-chip.active { background: var(--accent); border-color: transparent; color: #fff; }
.adm-view-chip button {
    border: 0; background: transparent; color: inherit; opacity: .45;
    font-size: .875rem; line-height: 1; padding: 0 .3rem; cursor: pointer;
}
.adm-view-chip button:hover { opacity: 1; }
.adm-view-save {
    border: 1px dashed #cbd5e1; background: transparent; border-radius: 999px;
    padding: .25rem .75rem; font-size: .75rem; color: #64748b; cursor: pointer;
}
.adm-view-save:hover:not(:disabled) { border-color: #64748b; color: #334155; }
.adm-view-save:disabled { cursor: default; opacity: .7; }

.adm-nav-badge {
    margin-left: auto; background: #f59e0b; color: #1e293b;
    font-size: .625rem; font-weight: 700; line-height: 1.15rem;
    border-radius: 999px; padding: 0 .4rem; min-width: 1.15rem; text-align: center;
}

/* Collapsed (desktop) */
@media (min-width: 1024px) {
    body.sb-collapsed .adm-sidebar { width: var(--sidebar-w-collapsed); }
    body.sb-collapsed .adm-nav-item span,
    body.sb-collapsed .adm-nav-group,
    body.sb-collapsed .adm-brand-text { display: none; }
    body.sb-collapsed .adm-nav-item { justify-content: center; position: relative; }
    /* Badge collapses to a corner dot so the queue signal survives icon-only mode */
    body.sb-collapsed .adm-nav-item .adm-nav-badge {
        display: block; position: absolute; top: 3px; right: 5px;
        width: .5rem; height: .5rem; min-width: 0; padding: 0; font-size: 0;
    }
}
/* Mobile drawer */
@media (max-width: 1023.98px) {
    .adm-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; transform: translateX(-100%); }
    body.sb-open .adm-sidebar { transform: none; }
    #adm-sb-backdrop { display: none; position: fixed; inset: 0; z-index: 55; background: rgb(2 6 23 / .5); }
    body.sb-open #adm-sb-backdrop { display: block; }
}

/* --------------------------------------------------------------------------
   Dropdown (topbar user menu)
   -------------------------------------------------------------------------- */
.adm-dropdown { position: relative; }
.adm-dropdown .menu {
    display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
    min-width: 12rem; background: #fff; border: 1px solid #e2e8f0; border-radius: .625rem;
    box-shadow: 0 12px 30px -8px rgb(0 0 0 / .2); padding: .375rem;
}
.adm-dropdown.open .menu { display: block; }
.adm-dropdown .menu a, .adm-dropdown .menu button {
    display: flex; width: 100%; align-items: center; gap: .5rem; text-align: left;
    padding: .5rem .625rem; font-size: .8438rem; color: #334155; border-radius: .375rem;
}
.adm-dropdown .menu a:hover, .adm-dropdown .menu button:hover { background: #f1f5f9; }

/* --------------------------------------------------------------------------
   Tables & cards polish
   -------------------------------------------------------------------------- */
.adm-main table tbody tr { transition: background .1s; }
.adm-main table tbody tr:hover { background: #f8fafc; }
.adm-main .shadow-sm { box-shadow: 0 1px 3px rgb(15 23 42 / .06), 0 1px 2px rgb(15 23 42 / .04); }

/* Sticky form action bar */
.adm-actions {
    position: sticky; bottom: 0; z-index: 30;
    background: color-mix(in srgb, #f1f5f9 85%, transparent);
    backdrop-filter: blur(6px);
    margin: 0 -.25rem; padding: .75rem .25rem;
    border-top: 1px solid #e2e8f0;
}

/* Autosave restore banner */
.adm-restore {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    border-radius: .625rem; padding: .625rem 1rem; font-size: .8438rem; margin-bottom: 1rem;
}

/* Empty states */
.adm-empty { text-align: center; padding: 3rem 1.5rem; color: #94a3b8; }
.adm-empty svg { width: 2.5rem; height: 2.5rem; margin: 0 auto .75rem; opacity: .5; }

/* Scrollbars */
.adm-sidebar nav::-webkit-scrollbar, .adm-combo-list::-webkit-scrollbar, #adm-palette .results::-webkit-scrollbar { width: 6px; }
.adm-sidebar nav::-webkit-scrollbar-thumb { background: rgb(255 255 255 / .12); border-radius: 3px; }
.adm-combo-list::-webkit-scrollbar-thumb, #adm-palette .results::-webkit-scrollbar-thumb { background: rgb(0 0 0 / .15); border-radius: 3px; }

/* ==========================================================================
   DARK MODE — override the light utilities the views already use.
   Toggled by .dark on <html>.
   ========================================================================== */
.dark { color-scheme: dark; }
.dark body.bg-slate-100 { background: #0b1220; color: #cbd5e1; }
.dark .adm-main .bg-white, .dark header.bg-white { background: #111a2e !important; }
.dark .adm-main .bg-slate-50 { background: #0e1526 !important; }
.dark .adm-main .bg-slate-100 { background: #0b1220 !important; }
.dark .adm-main, .dark .adm-main .text-slate-800 { color: #cbd5e1; }
.dark .adm-main .text-slate-900, .dark header .text-slate-900 { color: #e2e8f0 !important; }
.dark .adm-main .text-slate-700 { color: #cbd5e1 !important; }
.dark .adm-main .text-slate-600, .dark .adm-main .text-slate-500 { color: #8fa3bf !important; }
.dark .adm-main .text-slate-400 { color: #64748b !important; }
.dark .adm-main .border, .dark .adm-main .border-b, .dark .adm-main .border-t,
.dark .adm-main [class*="border-slate"], .dark header.border-b { border-color: #1e293b !important; }
.dark .adm-main input, .dark .adm-main textarea, .dark .adm-main select, .dark .adm-main .adm-tags,
.dark .adm-combo-btn { background-color: #0e1526; border-color: #263349; color: #e2e8f0; }
.dark .adm-main label { color: #a8b8cf; }
.dark .adm-main table tbody tr:hover { background: #16203a; }
.dark .adm-main .divide-y > * { border-color: #1e293b !important; }
.dark .adm-main .bg-slate-200 { background: #263349 !important; color: #cbd5e1; }
.dark .adm-main .bg-green-100, .dark .adm-main .bg-green-200 { background: rgb(34 197 94 / .18) !important; color: #4ade80 !important; }
.dark .adm-main .bg-amber-100, .dark .adm-main .bg-amber-200 { background: rgb(245 158 11 / .18) !important; color: #fbbf24 !important; }
.dark .adm-main .bg-red-100 { background: rgb(239 68 68 / .15) !important; color: #f87171 !important; }
.dark .adm-main .bg-blue-100 { background: rgb(59 130 246 / .18) !important; color: #93c5fd !important; }
.dark .adm-main .text-green-800 { color: #4ade80 !important; }
.dark .adm-main .text-red-800, .dark .adm-main .text-red-700 { color: #f87171 !important; }
.dark .adm-main .text-blue-700 { color: #93c5fd !important; }
.dark .adm-main .border-green-300 { border-color: rgb(34 197 94 / .4) !important; }
.dark .adm-main .border-red-300 { border-color: rgb(239 68 68 / .4) !important; }
.dark .btn-secondary { background: #16203a; color: #cbd5e1; border-color: #263349; }
.dark .btn-secondary:hover { background: #1c2942; }
.dark .adm-dropdown .menu, .dark .adm-combo-panel, .dark #adm-palette .panel, .dark #adm-confirm .panel { background: #111a2e; border-color: #263349; }
.dark .adm-dropdown .menu a, .dark .adm-dropdown .menu button { color: #cbd5e1; }
.dark .adm-dropdown .menu a:hover, .dark .adm-dropdown .menu button:hover { background: #1c2942; }
.dark #adm-palette .panel input { background: #111a2e; color: #e2e8f0; border-color: #1e293b; }
.dark #adm-palette .results a { color: #cbd5e1; }
.dark .adm-combo-panel input { border-color: #1e293b !important; }
.dark .adm-dropzone { background: #0e1526; border-color: #263349; }
.dark .adm-dropzone:hover, .dark .adm-dropzone.dragover { background: #16203a; border-color: var(--accent); }
.dark .adm-actions { background: color-mix(in srgb, #0b1220 85%, transparent); border-color: #1e293b; }
.dark .adm-restore { background: rgb(245 158 11 / .1); border-color: rgb(245 158 11 / .35); color: #fbbf24; }
.dark .adm-tags .chip { background: color-mix(in srgb, var(--accent) 25%, transparent); color: #c7d2fe; }
.dark .adm-counter { color: #64748b; }
.dark .adm-main .ql-toolbar, .dark .adm-main .ql-container { border-color: #263349 !important; }
.dark .adm-main .ql-toolbar { background: #16203a; }
.dark .adm-main .ql-editor { color: #e2e8f0; }
.dark .adm-main .ql-snow .ql-stroke { stroke: #a8b8cf; }
.dark .adm-main .ql-snow .ql-fill { fill: #a8b8cf; }
.dark .adm-main .ql-snow .ql-picker { color: #a8b8cf; }

/* Quill sizing */
.adm-main .ql-container { min-height: 320px; font-size: 1rem; border-bottom-left-radius: .5rem; border-bottom-right-radius: .5rem; }
.adm-main .ql-toolbar { border-top-left-radius: .5rem; border-top-right-radius: .5rem; }
