/* =====================================================================
   CMSGO — complemento del sistema de diseño CMS GO (cmsgo-brand.css)
   Usa exclusivamente los tokens de :root de AM.
   ===================================================================== */
:root {
  --danger: #E1463E;
  --danger-50: #FCE6E4;
  --focus: 0 0 0 3px var(--am-green-50);
}

[hidden] { display: none !important; }
a { color: var(--am-green-700); }
a:hover { color: var(--am-green-800); }
h1, h2, h3, h4 { margin: 0; }

/* ---------- Shell ---------- */
.app-body .sidebar { height: auto; }
.sidebar .site-switch { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.sidebar .site-switch label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; padding: 0 6px; }
.sidebar .site-switch select {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  padding: 8px 10px; font-weight: 600; font-size: 13px;
}
.sidebar .site-switch select:focus { outline: none; border-color: var(--am-green); box-shadow: var(--focus); }
.nav-item { cursor: pointer; }
.nav-item .ico { width: 16px; height: 16px; }
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .chev { margin-left: auto; transition: transform .15s; opacity: .5; }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.main { background: var(--bg); }
.page { background: transparent; }
.page-eyebrow {
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 12px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--am-green-700); margin: 0 0 4px;
}
.menu-toggle { display: none; }
.pb-site { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); min-width: 0; }
.pb-site b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .app-body .sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0; z-index: 40; transform: translateX(-100%);
    transition: transform .2s; box-shadow: var(--sh-pop);
  }
  .app-body.nav-open .sidebar { transform: none; }
  .page { padding: 18px 16px 60px; }
  .page-header { flex-wrap: wrap; align-items: flex-start; }
  .page-actions { margin-left: 0; flex-wrap: wrap; }
  .pb-search, .pb-avatar-name, .pb-site { display: none; }
  .platform-bar { padding: 0 12px; gap: 10px; }
}

/* ---------- Botones extra ---------- */
.btn { text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary, .btn-primary:hover { color: #fff; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-2); color: #fff; }
.btn-danger { background: var(--danger-50); color: #A4231C; }
.btn-danger:hover { background: #F9D4D0; color: #A4231C; }
.btn-link { background: none; color: var(--am-green-700); padding: 0; font-weight: 600; }
.btn-link.danger { color: #A4231C; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 15px; height: 15px; }

/* ---------- Alertas ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-md); border: 1px solid; font-size: 13.5px; margin-bottom: 16px; }
.alert-success { background: var(--am-green-50); border-color: var(--am-green-100); color: var(--am-green-800); }
.alert-error { background: #FCEAE8; border-color: #F4C9C5; color: #A4231C; }
.alert-info { background: var(--peach-soft); border-color: #F2DED7; color: var(--ink-2); }
.alert-warn { background: #FEF6E5; border-color: #F7E1B8; color: #8B5E14; }

/* ---------- Cards ---------- */
.card + .card { margin-top: 16px; }
.card-title { font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 17px; }
.card-header .sub { color: var(--ink-4); font-size: 12px; }
.card-header .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-pad { padding: 18px; }
.card-footer { border-top: 1px solid var(--line-2); padding: 12px 18px; background: var(--surface-2); display: flex; gap: 8px; align-items: center; }

/* ---------- KPI ---------- */
.kpi { text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s; }
a.kpi:hover { border-color: var(--am-green-100); box-shadow: var(--sh-2); color: inherit; }
.kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(3, 1fr) !important; } }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; } }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4);
  font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #FCFCFA; }
.tbl .title-cell a { color: var(--ink); font-weight: 600; text-decoration: none; }
.tbl .title-cell a:hover { color: var(--am-green-700); }
.tbl .row-actions { display: flex; gap: 12px; margin-top: 4px; font-size: 12px; opacity: .0; transition: opacity .12s; flex-wrap: wrap; }
.tbl tr:hover .row-actions, .tbl .row-actions:focus-within { opacity: 1; }
@media (hover: none) { .tbl .row-actions { opacity: 1; } }
.tbl .row-actions a, .tbl .row-actions button { font-size: 12px; font-weight: 600; text-decoration: none; }
.muted { color: var(--ink-4); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-4); }
.empty .cond { font-size: 22px; font-weight: 700; color: var(--ink-3); display: block; margin-bottom: 6px; }

/* ---------- Filtros / pestañas ---------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filterbar input, .filterbar select, .input, .select, textarea.input {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 11px; background: var(--surface); font-size: 13.5px; min-height: 36px;
}
.filterbar input:focus, .filterbar select:focus, .input:focus, .select:focus { outline: none; border-color: var(--am-green); box-shadow: var(--focus); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 10px 14px; font-weight: 600; font-size: 13px; color: var(--ink-3); text-decoration: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--am-green-800); border-bottom-color: var(--am-green); }
.tabs .count { font-size: 11px; background: var(--line-2); color: var(--ink-3); border-radius: var(--pill); padding: 1px 7px; }
.tabs a.active .count { background: var(--am-green-50); color: var(--am-green-700); }

/* ---------- Formularios ---------- */
.field input, .field textarea, .field select { width: 100%; }
.field .help { font-size: 12px; color: var(--ink-4); margin: 0; }
.field-error { color: #A4231C; font-size: 12px; margin: 2px 0 0; font-weight: 500; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field label .req { color: var(--danger); }
.field .inline { display: flex; gap: 8px; align-items: center; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--am-green); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.form-grid .side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 16px; }
.form-grid .side .card + .card { margin-top: 0; }
@media (max-width: 1080px) { .form-grid { grid-template-columns: 1fr; } .form-grid .side { position: static; } }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
@media (max-width: 700px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
.section-title {
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-4); margin: 6px 0 12px;
}
.checklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.checklist .scope { font-size: 10.5px; color: var(--ink-4); margin-left: auto; }
.title-input {
  width: 100%; border: 0; background: transparent; font-family: "Barlow Condensed", sans-serif; font-weight: 700;
  font-size: 32px; letter-spacing: -.01em; line-height: 1.1; padding: 4px 0; color: var(--ink);
}
.title-input:focus { outline: none; }
.title-input::placeholder { color: var(--ink-4); opacity: .6; }
.slug-row { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-4); flex-wrap: wrap; }
.slug-row input { border: 1px dashed var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12.5px; min-width: 200px; background: var(--surface-2); }
.color-input { display: flex; gap: 8px; align-items: center; }
.color-input input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }

/* ---------- Selector de medios (campo) ---------- */
.media-field { display: flex; flex-direction: column; gap: 8px; }
.media-field .preview {
  border: 1px dashed var(--line); border-radius: var(--r-md); background: var(--surface-2); min-height: 120px;
  display: grid; place-items: center; overflow: hidden; color: var(--ink-4); font-size: 12px; cursor: pointer;
}
.media-field .preview img { width: 100%; height: 100%; max-height: 220px; object-fit: cover; display: block; }
.media-field .actions { display: flex; gap: 8px; }

/* ---------- Biblioteca de medios ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 16px; }
.media-tile {
  position: relative; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface);
  text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: border-color .12s, box-shadow .12s;
}
.media-tile:hover { border-color: var(--am-green-100); box-shadow: var(--sh-2); color: inherit; }
.media-tile .thumb { aspect-ratio: 1 / 1; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.media-tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-tile .ext { font-family: "Barlow Condensed", sans-serif; font-weight: 900; font-size: 22px; color: var(--ink-4); text-transform: uppercase; }
.media-tile .name { font-size: 12px; padding: 7px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-tile.selected { border-color: var(--am-green); box-shadow: 0 0 0 3px var(--am-green-100); }
.media-tile .order {
  position: absolute; top: 6px; right: 6px; background: var(--am-green); color: #fff; font-weight: 700; font-size: 11px;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
}
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--r-lg); padding: 26px; text-align: center; color: var(--ink-3);
  background: var(--surface); transition: border-color .12s, background .12s; cursor: pointer;
}
.dropzone.over { border-color: var(--am-green); background: var(--am-green-50); }
.dropzone .cond { font-size: 18px; font-weight: 700; color: var(--ink); display: block; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(22, 20, 15, .45); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-pop); width: min(1000px, 100%); max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.modal-head h3 { font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 20px; }
.modal-body { overflow-y: auto; flex: 1; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* ---------- Autores ordenables ---------- */
.sortable-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.sortable-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font-size: 13px; }
.sortable-item .num { width: 20px; height: 20px; border-radius: 50%; background: var(--am-green-50); color: var(--am-green-800); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.sortable-item .name { flex: 1; font-weight: 600; }
.sortable-item button { color: var(--ink-4); padding: 2px 4px; border-radius: 4px; }
.sortable-item button:hover { color: var(--ink); background: var(--bg); }

/* ---------- Editor de bloques (Editor.js) ---------- */
.editor-card { padding: 10px 18px 24px; }
#editorjs { min-height: 360px; font-family: "Source Serif 4", Georgia, serif; font-size: 17px; line-height: 1.6; }
#editorjs .ce-block__content, #editorjs .ce-toolbar__content { max-width: 760px; }
#editorjs h2, #editorjs h3, #editorjs h4 { font-family: "Barlow Condensed", sans-serif; font-weight: 700; margin: .6em 0 .2em; }
#editorjs h2 { font-size: 28px; } #editorjs h3 { font-size: 23px; } #editorjs h4 { font-size: 19px; }
#editorjs blockquote, #editorjs .cdx-quote__text { font-style: italic; }
.cms-block-media { border: 1px dashed var(--line); border-radius: var(--r-md); padding: 12px; background: var(--surface-2); font-family: "Barlow", sans-serif; font-size: 13px; }
.cms-block-media img, .cms-block-media video { max-width: 100%; border-radius: 8px; display: block; margin: 0 auto 8px; }
.cms-block-media .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin-bottom: 8px; }
.cms-block-media .gallery img { aspect-ratio: 1 / 1; object-fit: cover; margin: 0; }
.cms-block-media input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; background: #fff; }
.cms-block-media .placeholder { text-align: center; padding: 18px; color: var(--ink-3); }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); }
.auth-brand { background: #14110A; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: var(--am-green); opacity: .16; }
.auth-brand h1 { font-family: "Barlow Condensed", sans-serif; font-weight: 900; font-size: 54px; line-height: .95; letter-spacing: -.02em; max-width: 440px; }
.auth-brand p { color: #CFCAC0; font-size: 15px; max-width: 420px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 380px; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-brand { display: none; } }

/* ---------- Misceláneos ---------- */
.activity { display: flex; flex-direction: column; }
.activity-item { display: flex; gap: 10px; padding: 10px 18px; border-top: 1px solid var(--line-2); font-size: 13px; }
.activity-item:first-child { border-top: 0; }
.activity-item .avatar { width: 26px; height: 26px; font-size: 11px; flex-shrink: 0; }
.activity-item .when { color: var(--ink-4); font-size: 11.5px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tpl-card { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.tpl-card.current { border-color: var(--am-green); box-shadow: 0 0 0 3px var(--am-green-50); }
.tpl-card .cc-mono { margin-bottom: 4px; }
.perm-matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; text-transform: none; letter-spacing: 0; padding: 10px 6px; }
.perm-matrix td.c { text-align: center; }
.token-box { font-family: ui-monospace, Menlo, Consolas, monospace; background: #14110A; color: #DCEFC8; padding: 12px 14px; border-radius: var(--r-md); word-break: break-all; font-size: 13px; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; }
.dl dt { color: var(--ink-4); }
.dl dd { margin: 0; word-break: break-all; }
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.error-page .code { font-family: "Barlow Condensed", sans-serif; font-weight: 900; font-size: 120px; line-height: .9; color: var(--am-green); letter-spacing: -.03em; }
