/* =========================================================================
   Noticias24Colombia — panel de administracion
   ========================================================================= */

/* El tema oscuro es el de partida; el claro se activa con
   <html data-theme="light"> o con la preferencia del sistema. */

:root {
  --bg: #0d1017;
  --bg-soft: #151a24;
  --bg-card: #1a202c;
  --line: #262d3b;
  --text: #eef1f6;
  --text-soft: #a8b1c2;
  --text-dim: #78819a;
  --amarillo: #ffcf33;
  --azul: #2f6bff;
  --rojo: #e0243a;
  --verde: #2ea05a;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --glass: rgba(255, 255, 255, .06);
  --glass-strong: rgba(255, 255, 255, .11);
  --top-bg: rgba(13, 16, 23, .96);
  --row-hover: rgba(255, 255, 255, .025);
  --th-bg: rgba(255, 255, 255, .02);
  --code-bg: #0a0d13;
}

/* ------------------------------ Tema claro ------------------------------ */

:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-soft: #ffffff;
  --bg-card: #eef1f6;
  --line: #d8dde7;
  --text: #161a21;
  --text-soft: #48505f;
  --text-dim: #6c7486;
  --azul: #1a41b0;
  --rojo: #c31229;
  --verde: #1f7a44;

  --glass: rgba(22, 26, 33, .05);
  --glass-strong: rgba(22, 26, 33, .1);
  --top-bg: rgba(255, 255, 255, .96);
  --row-hover: rgba(22, 26, 33, .03);
  --th-bg: rgba(22, 26, 33, .03);
  --code-bg: #eceff5;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fa;
    --bg-soft: #ffffff;
    --bg-card: #eef1f6;
    --line: #d8dde7;
    --text: #161a21;
    --text-soft: #48505f;
    --text-dim: #6c7486;
    --azul: #1a41b0;
    --rojo: #c31229;
    --verde: #1f7a44;

    --glass: rgba(22, 26, 33, .05);
    --glass-strong: rgba(22, 26, 33, .1);
    --top-bg: rgba(255, 255, 255, .96);
    --row-hover: rgba(22, 26, 33, .03);
    --th-bg: rgba(22, 26, 33, .03);
    --code-bg: #eceff5;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body.admin {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.muted { color: var(--text-dim); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
code { background: var(--code-bg); padding: 2px 6px; border-radius: 5px; font-size: .85em; color: var(--amarillo); }

:focus-visible { outline: 2px solid var(--amarillo); outline-offset: 2px; }

/* ------------------------------- Botones -------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border: 1px solid transparent; border-radius: 9px;
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
  transition: filter .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn--sm { padding: 6px 12px; font-size: .82rem; border-radius: 7px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--amarillo); color: #1a1400; }
.btn--ghost { background: var(--glass); border-color: var(--line); color: var(--text); }
.btn--ghost:hover { background: var(--glass-strong); }
.btn--danger { background: rgba(224,36,58,.14); border-color: rgba(224,36,58,.45); color: #ff8b98; }
.btn--danger:hover { background: rgba(224,36,58,.24); }

.inline { display: inline; }

/* ------------------------------ Estructura ------------------------------ */

.admin-top {
  position: sticky; top: 0; z-index: 40;
  height: 58px; padding: 0 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--top-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.admin-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.admin-brand strong { color: var(--amarillo); }
.admin-brand em { color: var(--text-dim); font-style: normal; font-weight: 400; }
.admin-brand__mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(180deg, var(--amarillo) 0 50%, var(--azul) 50% 75%, var(--rojo) 75% 100%);
}
.admin-top__right { display: flex; align-items: center; gap: 12px; }
.admin-top__link { color: var(--text-soft); font-size: .87rem; }
.admin-top__user { color: var(--text-dim); font-size: .85rem; }
.admin-top form { margin: 0; }

.admin-shell { display: flex; min-height: calc(100vh - 58px); align-items: stretch; }

.admin-side {
  flex: 0 0 216px; padding: 18px 12px;
  border-right: 1px solid var(--line); background: var(--bg-soft);
  display: flex; flex-direction: column; gap: 3px;
}
.admin-side a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text-soft); font-size: .9rem;
}
.admin-side a:hover { background: var(--glass); color: var(--text); text-decoration: none; }
.admin-side a.is-active { background: rgba(255,207,51,.14); color: var(--amarillo); font-weight: 600; }
.admin-side hr { border: 0; border-top: 1px solid var(--line); margin: 10px 4px; width: 100%; }
.badge {
  margin-left: auto; padding: 1px 8px; border-radius: 999px;
  background: var(--rojo); color: #fff; font-size: .72rem; font-style: normal; font-weight: 700;
}

.admin-main { flex: 1; padding: 24px 26px 60px; min-width: 0; }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-side { flex: none; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-side hr { display: none; }
  .admin-side a { white-space: nowrap; }
  .admin-main { padding: 18px 14px 50px; }
  .admin-top__user { display: none; }
}

.admin-head {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between; margin-bottom: 22px;
}
.admin-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.01em; }

/* -------------------------------- Avisos -------------------------------- */

.alert { padding: 12px 16px; border-radius: var(--radius); margin: 0 0 18px; font-size: .9rem; }
.alert--ok { background: rgba(46,160,90,.13); border: 1px solid rgba(46,160,90,.45); }
.alert--error { background: rgba(224,36,58,.13); border: 1px solid rgba(224,36,58,.45); }

/* ----------------------------- Estadisticas ------------------------------ */

.stat-grid {
  display: grid; gap: 12px; margin-bottom: 26px;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
}
.stat {
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px;
}
.stat--alert { border-color: rgba(255,207,51,.5); background: rgba(255,207,51,.07); }
.stat__label { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); }
.stat__value { font-size: 1.9rem; line-height: 1.1; font-weight: 700; }
.stat__hint { font-size: .8rem; color: var(--text-dim); }
.stat__hint a { color: var(--amarillo); }

.admin-cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.panel {
  padding: 18px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--line);
}
.panel--narrow { max-width: 520px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 14px; font-size: 1.02rem; }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.mini-list li { font-size: .89rem; line-height: 1.45; }
.mini-list__meta { display: block; font-size: .77rem; color: var(--text-dim); margin-top: 2px; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .03em;
}
.tag--published, .tag--approved { background: rgba(46,160,90,.18); color: #6ee2a0; }
.tag--draft, .tag--pending { background: rgba(255,207,51,.18); color: var(--amarillo); }
.tag--rejected { background: rgba(224,36,58,.18); color: #ff8b98; }

/* -------------------------------- Filtros -------------------------------- */

.filters {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.filters__tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.filters__tabs a {
  padding: 7px 14px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--line);
  color: var(--text-soft); font-size: .86rem;
}
.filters__tabs a:hover { color: var(--text); text-decoration: none; }
.filters__tabs a.is-active { background: var(--amarillo); border-color: var(--amarillo); color: #1a1400; font-weight: 600; }
.filters__tabs em { font-style: normal; opacity: .75; margin-left: 4px; }
.filters__tabs--wide { margin-bottom: 18px; }

.filters__search { display: flex; gap: 8px; }
.filters__search input {
  padding: 8px 13px; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--line);
  color: var(--text); font: inherit; font-size: .88rem;
}

/* -------------------------------- Tablas --------------------------------- */

.table-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto; background: var(--bg-soft);
}
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 900px; }
.admin-table th {
  padding: 11px 14px; text-align: left; font-size: .75rem;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim);
  border-bottom: 1px solid var(--line); background: var(--th-bg);
}
.admin-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: var(--row-hover); }
.admin-table__title { display: block; font-weight: 600; color: var(--text); }
.admin-table__slug { display: block; font-size: .75rem; color: var(--text-dim); margin-top: 2px; }
.admin-table .actions { display: flex; flex-wrap: wrap; gap: 5px; }

.thumb {
  display: block; width: 52px; height: 40px; border-radius: 7px;
  overflow: hidden; background: var(--bg-card);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.pager { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 18px; }
.pager a {
  padding: 7px 13px; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--line);
  font-size: .85rem; color: var(--text-soft);
}
.pager a.is-active { background: var(--amarillo); border-color: var(--amarillo); color: #1a1400; font-weight: 600; }

/* ------------------------------ Formularios ------------------------------ */

.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: .82rem; font-weight: 600; color: var(--text-soft);
}
.req { color: var(--rojo); }
.field input[type="text"], .field input[type="url"], .field input[type="password"],
.field input[type="search"], .field input[type="datetime-local"], .field select, .field textarea {
  width: 100%; padding: 10px 13px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); font: inherit; font-size: .93rem;
}
.field textarea { resize: vertical; line-height: 1.6; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88rem; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--amarillo); outline: none; }
.field input[type="file"] { width: 100%; font-size: .85rem; color: var(--text-soft); }
.field__hint { margin: 6px 0 0; font-size: .76rem; color: var(--text-dim); line-height: 1.5; }
.counter { color: var(--text-soft); }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--text-soft); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--amarillo); }

.post-form__grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 1040px) { .post-form__grid { grid-template-columns: minmax(0, 1fr) 330px; } }

.post-form__main, .side-box {
  padding: 18px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--line);
}
.side-box { margin-bottom: 14px; }
.side-box h2 {
  margin: 0 0 14px; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-dim);
}
.side-box--links ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.side-box--links a { color: var(--amarillo); font-size: .86rem; }

.post-form__foot {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line);
}

.editor-toolbar { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.editor-toolbar button {
  padding: 5px 11px; border-radius: 7px;
  background: var(--bg-card); border: 1px solid var(--line);
  color: var(--text-soft); font: inherit; font-size: .8rem; cursor: pointer;
}
.editor-toolbar button:hover { border-color: var(--amarillo); color: var(--text); }
.editor-toolbar button.is-active {
  border-color: var(--amarillo); color: var(--text); background: var(--bg-soft);
}
.editor-toolbar button[disabled] { opacity: .4; cursor: default; }
.editor-toolbar__sep {
  width: 1px; align-self: stretch; margin: 2px 3px; background: var(--line);
}

/* -------------------------- Editor del cuerpo ---------------------------- */

.editor-rich {
  min-height: 380px; max-height: 70vh; overflow-y: auto;
  padding: 18px 20px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text); font-size: 1rem; line-height: 1.7;
}
.editor-rich:focus { outline: none; border-color: var(--amarillo); }
.editor-rich > *:first-child { margin-top: 0; }
.editor-rich > *:last-child { margin-bottom: 0; }
.editor-rich p { margin: 0 0 1em; }
.editor-rich h2 { font-size: 1.4rem; line-height: 1.3; margin: 1.4em 0 .5em; }
.editor-rich h3 { font-size: 1.18rem; line-height: 1.35; margin: 1.3em 0 .45em; }
.editor-rich h4 { font-size: 1.03rem; margin: 1.2em 0 .4em; }
.editor-rich ul, .editor-rich ol { margin: 0 0 1em; padding-left: 1.5em; }
.editor-rich li { margin-bottom: .35em; }
.editor-rich blockquote {
  margin: 1.2em 0; padding: .2em 0 .2em 1em;
  border-left: 3px solid var(--amarillo); color: var(--text-soft); font-style: italic;
}
.editor-rich a { color: var(--amarillo); }
.editor-rich img { max-width: 100%; height: auto; border-radius: 8px; }
.editor-rich hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.editor [hidden] { display: none !important; }

/* Un parrafo que se convertira en una incrustacion: se marca en el editor
   para que el redactor lo vea antes de publicar. */
.editor-rich p[data-incrustacion] {
  position: relative;
  padding: 14px 14px 14px 16px;
  margin: 1.2em 0;
  border-left: 3px solid var(--amarillo);
  background: var(--glass);
  border-radius: 0 8px 8px 0;
  font-size: .88rem; word-break: break-all;
}
.editor-rich p[data-incrustacion]::before {
  content: "▶ " attr(data-incrustacion);
  display: block; margin-bottom: 6px;
  font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--amarillo); word-break: normal;
}

.editor-aviso {
  margin: 8px 0 0; padding: 0;
  font-size: .84rem; color: var(--amarillo);
  opacity: 0; transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.editor-aviso.se-ve { opacity: 1; transform: none; }

.image-preview { margin-bottom: 14px; }
.image-preview img { border-radius: 9px; border: 1px solid var(--line); margin-bottom: 8px; }
.image-preview--new[hidden] { display: none; }

/* ------------------------------ Moderacion ------------------------------- */

.mod-filtros {
  padding: 14px 16px; margin-bottom: 14px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
}
.mod-filtros__campos {
  display: grid; gap: 10px 14px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 12px;
}
.mod-filtros label { display: flex; flex-direction: column; gap: 5px; }
.mod-filtros label > span { font-size: .74rem; color: var(--text-dim); letter-spacing: .02em; }
.mod-filtros input, .mod-filtros select {
  padding: 8px 10px; border-radius: 8px;
  background: var(--bg-card); border: 1px solid var(--line);
  color: var(--text); font: inherit; font-size: .88rem;
}
.mod-filtros__acciones { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.ip-lista { display: flex; flex-wrap: wrap; gap: 7px; }
.ip-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--line);
  font-size: .8rem; text-decoration: none;
}
.ip-chip:hover, .ip-chip.is-active { border-color: var(--amarillo); text-decoration: none; }
.ip-chip code { font-size: .78rem; }
.ip-chip em { font-style: normal; font-weight: 700; color: var(--amarillo); }

.mod-item__ip code { font-size: .76rem; opacity: .85; }
.mod-item__ip:hover code { color: var(--amarillo); }

.bulk-bar {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  padding: 12px 16px; margin-bottom: 12px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
}
.bulk-bar__actions { display: flex; gap: 6px; flex-wrap: wrap; }

.mod-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mod-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--line);
}
.mod-item--pending { border-left: 3px solid var(--amarillo); }
.mod-item--approved { border-left: 3px solid var(--verde); }
.mod-item--rejected { border-left: 3px solid var(--rojo); opacity: .72; }
.mod-item__check input { width: 17px; height: 17px; accent-color: var(--amarillo); margin-top: 3px; }
.mod-item__body { flex: 1; min-width: 0; }
.mod-item__head { margin: 0 0 6px; display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.mod-item__head time { font-size: .76rem; color: var(--text-dim); }
.mod-item__text { margin: 0 0 8px; color: var(--text-soft); white-space: pre-wrap; word-break: break-word; }
.mod-item__post { margin: 0; font-size: .78rem; color: var(--text-dim); }
.mod-item__post a { color: var(--text-soft); }
.mod-item__actions {
  display: flex; flex-wrap: wrap; gap: 5px;
  justify-content: flex-end; align-items: flex-start;
  flex: 0 0 auto; max-width: 270px;
}

@media (max-width: 720px) {
  .mod-item { flex-wrap: wrap; }
  .mod-item__actions { width: 100%; max-width: none; justify-content: flex-start; }
}

/* --------------------------------- Login --------------------------------- */

body.admin--login {
  display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background: radial-gradient(1000px 500px at 50% -10%, #1a2233 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 392px; padding: 30px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login-card__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-weight: 600; }
.login-card__brand strong { color: var(--amarillo); }
.login-card h1 { margin: 0 0 20px; font-size: 1.25rem; }
.login-card__foot { margin: 18px 0 0; text-align: center; font-size: .86rem; }
.login-card__foot a { color: var(--text-dim); }

/* Aviso de actualizacion pendiente */
.alert--warn {
  background: rgba(255, 207, 51, .11);
  border: 1px solid rgba(255, 207, 51, .45);
}
.alert--info {
  background: rgba(47, 107, 255, .12);
  border: 1px solid rgba(47, 107, 255, .45);
}
.update-alert {
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
}


/* -------------------- Boton de tema en el panel ------------------------- */

.theme-toggle {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  background: none; border: 0; border-radius: 50%;
  color: var(--text-soft); cursor: pointer;
}
.theme-toggle:hover { color: var(--amarillo); background: var(--glass); }
.theme-toggle svg {
  width: 18px; height: 18px; grid-area: 1 / 1;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.theme-toggle__sun { display: none; }
.theme-toggle__moon { display: block; }
:root[data-theme="light"] .theme-toggle__sun { display: block; }
:root[data-theme="light"] .theme-toggle__moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle__sun { display: block; }
  :root:not([data-theme="dark"]) .theme-toggle__moon { display: none; }
}

/* En el tema claro, el fondo degradado del acceso se aclara. */
:root[data-theme="light"] body.admin--login {
  background: radial-gradient(1000px 500px at 50% -10%, #e7ecf6 0%, var(--bg) 60%);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) body.admin--login {
    background: radial-gradient(1000px 500px at 50% -10%, #e7ecf6 0%, var(--bg) 60%);
  }
}
