/* Área de redacción */
:root { --bg: #f4f5f7; --panel: #fff; --ink: #1a1b1f; --muted: #6b6e76; --line: #e2e4e9; --accent: #e8762d; --blue: #1f4e8c; --green: #1f7a3a; --red: #b42318; --amber: #b7791f; }
*, *::before, *::after { box-sizing: border-box; }
body.adm { margin: 0; background: var(--bg); color: var(--ink); font-family: "Inter", system-ui, sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }
.h1 { font-family: "Playfair Display", Georgia, serif; font-size: 26px; font-weight: 700; }
.h2 { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 10px; color: var(--muted); }
.muted { color: var(--muted); }
.ta-r { text-align: right; } .ta-c { text-align: center; }
.inline { display: inline; }
code { background: #eee; padding: 2px 5px; border-radius: 3px; }

.adm-top { display: flex; align-items: center; gap: 16px; height: 52px; padding: 0 18px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.adm-top a { color: #fff; }
.adm-top__brand { font-family: "Playfair Display", serif; font-weight: 700; font-size: 18px; }
.adm-top__brand span { font-family: "Inter"; font-weight: 400; font-size: 13px; opacity: .7; }
.adm-top__right { margin-left: auto; display: flex; gap: 18px; align-items: center; font-size: 13px; }
.adm-top__user small { opacity: .7; margin-left: 4px; }
.adm-top__out { opacity: .8; }
.adm-top__menu { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }

.adm-wrap { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 52px); }
.adm-side { background: #fff; border-right: 1px solid var(--line); padding: 18px 0; }
.adm-side ul { list-style: none; margin: 0; padding: 0; }
.adm-side li a { display: block; padding: 9px 22px; color: var(--ink); font-weight: 500; border-left: 3px solid transparent; }
.adm-side li a:hover { background: var(--bg); text-decoration: none; }
.adm-side li a.is-active { border-left-color: var(--accent); background: #fff6ef; font-weight: 600; }
.adm-side__new { display: block; margin: 18px 18px 0; padding: 10px; text-align: center; background: var(--accent); color: #fff !important; font-weight: 600; border-radius: 6px; }
.adm-side__new:hover { text-decoration: none; filter: brightness(.95); }
.adm-side__role { margin: 22px 18px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }
.adm-main { padding: 24px 28px 60px; min-width: 0; }

.pagehead-adm { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead-adm .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pagehead-adm .badge { margin-left: 8px; vertical-align: middle; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 18px; }
.card--table { padding: 0; overflow-x: auto; }
.card--form { max-width: 640px; }
.card__foot { margin: 0; padding: 14px 18px; border-top: 1px solid var(--line); }
.card--form .card__foot { margin: 14px -18px -18px; }
.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; color: var(--ink); display: flex; flex-direction: column; }
.stat:hover { text-decoration: none; border-color: var(--blue); }
.stat b { font-size: 28px; font-family: "Playfair Display", serif; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat--warn b { color: var(--amber); } .stat--danger b { color: var(--red); }

.tbl { width: 100%; border-collapse: collapse; }
.tbl td, .tbl th { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; text-align: left; }
.tbl tr:first-child td { border-top: 0; }
.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-top: 0; background: #fafbfc; }
.tbl--list td, .tbl--list th { padding: 10px 14px; }
.tbl tr.is-muted td { opacity: .5; }
.td-title a { font-weight: 600; color: var(--ink); }
.td-actions { white-space: nowrap; }
.td-actions form { display: inline; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: #e9eaee; color: #444; white-space: nowrap; }
.badge--publicado { background: #e3f5e8; color: var(--green); }
.badge--revision { background: #fff3d6; color: var(--amber); }
.badge--rechazado { background: #fde8e6; color: var(--red); }
.badge--role-administrador { background: #1a1b1f; color: #fff; }
.badge--role-editor { background: #e3ebf7; color: var(--blue); }
.pill { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; margin-left: 6px; background: #fff0e4; color: var(--accent); border-radius: 3px; }
.pill--red { background: #fde8e6; color: var(--red); }

.btn { display: inline-block; padding: 8px 14px; border: 1px solid #c9ccd3; border-radius: 6px; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #d4681f; }
.btn--danger { color: var(--red); border-color: #e6b5b0; }
.btn--danger:hover { background: #fde8e6; }
.btn--warn { color: var(--amber); border-color: #e6cf9f; }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--xs { padding: 2px 8px; font-size: 12px; }
.btn--block { width: 100%; padding: 11px; }

.input { width: 100%; padding: 8px 10px; border: 1px solid #c9ccd3; border-radius: 6px; font: inherit; background: #fff; }
.input:focus { outline: 2px solid #f6c7a4; border-color: var(--accent); }
.input--title { font-family: "Playfair Display", serif; font-size: 24px; font-weight: 700; padding: 10px 12px; }
.input--mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.input--sm { padding: 5px 8px; }
.input--xs { width: 80px; padding: 5px 8px; }
textarea.input { resize: vertical; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.chk { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }

.filters { margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs a { padding: 6px 12px; border-radius: 999px; color: var(--ink); font-weight: 500; }
.tabs a:hover { background: #e9eaee; text-decoration: none; }
.tabs a.is-active { background: var(--ink); color: #fff; }
.filters__row { display: flex; gap: 8px; flex-wrap: wrap; }
.filters__row .input { width: auto; flex: 1; min-width: 160px; }

.adm-flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.adm-flash--ok { background: #e3f5e8; border-color: #a5d9b4; color: var(--green); }
.adm-flash--error { background: #fde8e6; border-color: #f0b2ab; color: var(--red); }
.adm-flash--warn { background: #fff3d6; border-color: #f0d38c; color: #6d4a00; }

.log { list-style: none; margin: 0; padding: 0; }
.log li { padding: 8px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }
.log--sm li { font-size: 12.5px; }
.toplist { padding-left: 20px; margin: 0; }
.toplist li { padding: 6px 0; border-top: 1px solid var(--line); }
.roles-help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; font-size: 12.5px; color: var(--muted); }
.roles-help div { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.roles-help--4 { grid-template-columns: repeat(4, 1fr); }
.roles-help b { color: var(--ink); }

/* Editor de noticias */
.editor__grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.editor__main { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.rte { border: 1px solid #c9ccd3; border-radius: 6px; background: #fff; }
.rte__bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: #fafbfc; position: sticky; top: 52px; z-index: 5; border-radius: 6px 6px 0 0; }
.rte__bar button { border: 1px solid transparent; background: transparent; padding: 5px 9px; border-radius: 4px; cursor: pointer; font: inherit; font-size: 13px; min-width: 32px; }
.rte__bar button:hover { background: #e9eaee; }
.rte__bar button.is-on { background: var(--ink); color: #fff; }
.rte__sep { width: 1px; background: var(--line); margin: 4px 4px; }
.rte__html { margin-left: auto; font-family: ui-monospace, monospace; }
.rte__area { min-height: 420px; padding: 18px 22px; outline: 0; font-family: "Source Serif 4", Georgia, serif; font-size: 17px; line-height: 1.65; }
.rte__area:empty::before { content: "Escribe aquí el cuerpo de la noticia…"; color: #aaa; }
.rte__area h2 { font-size: 22px; margin: 1.2em 0 .5em; font-family: "Playfair Display", serif; }
.rte__area h3 { font-size: 18px; margin: 1em 0 .4em; font-family: "Playfair Display", serif; }
.rte__area img { max-width: 100%; height: auto; display: block; margin: 1em auto; }
.rte__area img.is-selected { outline: 3px solid var(--accent); }
.rte__area blockquote { border-left: 4px solid var(--accent); margin: 1em 0; padding-left: 16px; font-style: italic; color: #444; }
.rte__area table { border-collapse: collapse; width: 100%; } .rte__area td, .rte__area th { border: 1px solid var(--line); padding: 6px 8px; }
.rte__area a { color: var(--blue); text-decoration: underline; }
.rte__source { width: 100%; min-height: 420px; border: 0; padding: 14px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }
.rte.is-source .rte__area { display: none; }
.rte.is-source .rte__source { display: block !important; }
.rte.is-uploading { opacity: .6; pointer-events: none; }
.cover img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 6px; background: #eee; margin-bottom: 8px; }
.cover__btns { display: flex; gap: 6px; margin-bottom: 12px; }

.mediagrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.mediagrid__item { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mediagrid__item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; cursor: copy; display: block; }
.mediagrid__item img:hover { opacity: .85; }
.mediagrid__item figcaption { padding: 6px 8px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 6px; word-break: break-all; }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 18px 0; }
.pager__btn { border: 1px solid #c9ccd3; background: #fff; padding: 6px 12px; border-radius: 6px; color: var(--ink); font-weight: 600; }
.pager__info { color: var(--muted); }

/* Login */
.adm--login { display: grid; place-items: center; min-height: 100vh; }
.login { width: min(420px, 92vw); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 32px; text-align: center; }
.login__logo { width: 220px; margin: 0 auto 14px; }
.login h1 { font-family: "Playfair Display", serif; font-size: 22px; margin-bottom: 18px; }
.login form { text-align: left; }
.login label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; }
.login input { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid #c9ccd3; border-radius: 6px; font: inherit; font-size: 15px; text-transform: none; letter-spacing: 0; }
.login__back { margin: 18px 0 0; font-size: 13px; }

@media (max-width: 980px) {
  .cols, .editor__grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .roles-help { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .adm-wrap { grid-template-columns: 1fr; }
  .adm-side { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .adm-side.is-open { display: block; }
  .adm-top__menu { display: block; }
  .adm-top__right a:not(.adm-top__out):not(.adm-top__user) { display: none; }
  .adm-main { padding: 16px; }
  .rte__bar { top: 0; position: static; }
}
