/* Perfila management UI — WordPress-admin layout with the EmpleandoMentes palette
   (spec 11 §1.1, spec 10 §11.5). No build: plain CSS with the palette as variables. */

:root {
  --cyan: #009ED1;
  --cyan-dark: #00769C;      /* ≥ 4.5:1 on white, for links and text */
  --orange: #FF6B00;
  --green: #66BA00;
  --green-dark: #4E8F00;
  --black: #1D1D1B;
  --ink: #1D1D1B;
  --muted: #5B5F66;
  --line: #DCDFE4;
  --bg: #F3F4F6;
  --box: #FFFFFF;
  --menu-bg: #1D1D1B;
  --menu-ink: #E8E8E6;
  --menu-hover: #2C2C29;
  --danger: #B42318;
  --radius: 6px;
  --top-h: 46px;
  --menu-w: 220px;
  --menu-w-collapsed: 56px;
  --side-w: 300px;
  font-size: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Mulish', Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: 'Poppins', Arial, sans-serif; color: var(--ink); margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
a { color: var(--cyan-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--box); padding: .5rem 1rem; }
.skip-link:focus { left: .5rem; top: .5rem; }

/* ── Top bar ── */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 30;
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  background: var(--box); border-bottom: 3px solid var(--cyan);
}
.topbar .brand { display: flex; align-items: center; gap: .6rem; font-family: 'Poppins', sans-serif; font-weight: 700; color: var(--ink); }
.topbar .brand img { height: 30px; width: auto; }
.topbar .brand small { color: var(--muted); font-weight: 400; font-family: 'Mulish', sans-serif; }
.topbar .scope { color: var(--muted); font-size: .9rem; }
.topbar .scope strong { color: var(--ink); }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.topbar .role-badge { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .6rem; font-size: .8rem; }
.icon-btn { background: none; border: 0; padding: .35rem; border-radius: var(--radius); cursor: pointer; color: var(--ink); display: inline-flex; }
.icon-btn:hover { background: var(--bg); }
.menu-open-btn { display: none; }

/* ── Left menu ── */
.menu {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--menu-w); z-index: 20;
  background: var(--menu-bg); color: var(--menu-ink); overflow-y: auto; padding: .5rem 0 3rem;
}
.menu ul { list-style: none; margin: 0; padding: 0; }
.menu > ul > li > a {
  display: flex; align-items: center; gap: .7rem; padding: .55rem 1rem; color: var(--menu-ink);
  font-family: 'Poppins', sans-serif; font-size: .92rem; border-left: 4px solid transparent;
}
.menu a:hover { background: var(--menu-hover); text-decoration: none; color: #fff; }
.menu li.active > a { border-left-color: var(--cyan); color: var(--cyan); background: #262624; font-weight: 600; }
.menu svg { flex: none; width: 20px; height: 20px; }
.menu .submenu { display: none; background: #262624; padding: .25rem 0 .5rem; }
.menu li.active .submenu { display: block; }
.menu .submenu a { display: block; padding: .3rem 1rem .3rem 3.1rem; color: #C9C9C6; font-size: .88rem; }
.menu .submenu a[aria-current="page"] { color: #fff; font-weight: 700; }
.menu .collapse-btn {
  display: flex; align-items: center; gap: .7rem; width: 100%; margin-top: .75rem; padding: .55rem 1rem;
  background: none; border: 0; color: #A9A9A6; cursor: pointer; font: inherit; text-align: left;
}
.menu .collapse-btn:hover { color: #fff; }

body.menu-collapsed .menu { width: var(--menu-w-collapsed); }
body.menu-collapsed .menu .label, body.menu-collapsed .menu .submenu { display: none; }
body.menu-collapsed .main { margin-left: var(--menu-w-collapsed); }
body.menu-collapsed .menu .collapse-btn svg { transform: rotate(180deg); }

/* ── Main area: center + optional right column ── */
.main { margin-left: var(--menu-w); padding: calc(var(--top-h) + 1.25rem) 1.5rem 3rem; }
.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.page.with-side { grid-template-columns: minmax(0, 1fr) var(--side-w); }
.content { min-width: 0; }

.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin-bottom: .5rem; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.crumbs a { color: var(--muted); }
.screen-options-toggle { margin-left: auto; }

.subsubsub { display: flex; flex-wrap: wrap; gap: .25rem; margin: .5rem 0 .75rem; padding: 0; list-style: none; font-size: .9rem; }
.subsubsub li + li::before { content: "|"; color: var(--line); margin-right: .25rem; }
.subsubsub a.current { color: var(--ink); font-weight: 700; }
.subsubsub .count { color: var(--muted); }

.notice { background: var(--box); border-left: 4px solid var(--cyan); padding: .6rem .9rem; margin: 0 0 1rem; border-radius: 0 var(--radius) var(--radius) 0; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.notice.success { border-left-color: var(--green); }
.notice.warning { border-left-color: var(--orange); }
.notice.error { border-left-color: var(--danger); }

/* ── Boxes, tables, forms ── */
.box { background: var(--box); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.25rem; }
.box > h2, .box > h3 { margin-bottom: .75rem; }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.side-panels .box { padding: .85rem; }
.side-panels h2 { font-size: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .4rem; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: .75rem; }
.filters label { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; color: var(--muted); }

table.list { width: 100%; border-collapse: collapse; background: var(--box); border: 1px solid var(--line); border-radius: var(--radius); }
table.list th, table.list td { padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-family: 'Poppins', sans-serif; font-size: .82rem; font-weight: 600; color: var(--muted); background: #FAFAFA; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #F8FBFD; }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.row-actions { font-size: .82rem; color: var(--muted); }

input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=date], input[type=month], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #B9BEC6; border-radius: var(--radius);
  padding: .35rem .5rem; min-height: 32px; max-width: 100%;
}
textarea { width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem 1rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field > label, .field > .label { font-weight: 700; font-size: .88rem; }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; }
.field .help { color: var(--muted); font-size: .8rem; }
.field .errors, .errorlist { color: var(--danger); font-size: .82rem; margin: 0; padding: 0; list-style: none; }
.field.wide { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.checks label, .checks div { font-weight: 400; }
.checks ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem; }
legend { font-family: 'Poppins', sans-serif; font-weight: 700; padding: 0 .35rem; }

.btn {
  display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-weight: 700; font-size: .88rem;
  padding: .38rem .8rem; border-radius: var(--radius); border: 1px solid #B9BEC6; background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; min-height: 32px;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--green); border-color: var(--green-dark); color: var(--black); }
.btn.primary:hover { background: #73CC05; }
.btn.small { padding: .2rem .55rem; font-size: .8rem; min-height: 26px; }
.btn.danger { color: var(--danger); }
.btn.link { border: 0; background: none; color: var(--cyan-dark); padding: 0; min-height: 0; font-weight: 400; }

.pill { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: #EEF7E2; border-color: #C7E3A3; }
.pill.warn { background: #FFF1E6; border-color: #FFD0AD; }
.pill.off { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ── Tiles and bars ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.tile { background: var(--box); border: 1px solid var(--line); border-top: 3px solid var(--cyan); border-radius: var(--radius); padding: .75rem .9rem; }
.tile .value { font-family: 'Poppins', sans-serif; font-size: 1.45rem; font-weight: 700; display: block; }
.tile .label { color: var(--muted); font-size: .85rem; }
a.tile:hover { text-decoration: none; border-top-color: var(--orange); }
.bar-cell { min-width: 160px; }
.bar { display: flex; align-items: center; gap: .5rem; }
.bar .track { flex: 1; height: 10px; background: #EEF1F4; border-radius: 999px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--cyan); border-radius: 999px; }
.bar .n { min-width: 3.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.chart svg { width: 100%; height: 140px; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart rect { fill: var(--cyan); }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .45rem .8rem; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; color: var(--muted); font-family: 'Poppins', sans-serif; font-size: .88rem; }
.tabs a[aria-selected="true"] { background: var(--box); border-color: var(--line); color: var(--ink); margin-bottom: -1px; font-weight: 600; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.screen-options { display: none; }
.screen-options.open { display: block; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.pagination { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .75rem; font-size: .88rem; }

/* ── Login ── */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--bg); }
.login-box { width: 100%; max-width: 360px; background: var(--box); border: 1px solid var(--line); border-top: 4px solid var(--cyan); border-radius: var(--radius); padding: 1.5rem; }
.login-box img { height: 40px; display: block; margin: 0 auto 1rem; }

/* ── Responsive (spec 11 §1.1) ── */
@media (max-width: 1279px) {
  .page.with-side { grid-template-columns: minmax(0, 1fr); }          /* lg: panels under the content */
}
@media (max-width: 1023px) {
  .menu { width: var(--menu-w-collapsed); }                           /* md: icons only */
  .menu .label, .menu .submenu { display: none; }
  .main { margin-left: var(--menu-w-collapsed); }
  .menu .collapse-btn { display: none; }
}
@media (max-width: 767px) {
  .menu-open-btn { display: inline-flex; }
  .menu { width: var(--menu-w); transform: translateX(-100%); transition: transform .2s; }   /* off-canvas */
  .menu .label { display: inline; }
  body.menu-open .menu { transform: none; }
  body.menu-open .menu li.active .submenu { display: block; }
  .main, body.menu-collapsed .main { margin-left: 0; padding-left: 1rem; padding-right: 1rem; }
  .topbar .scope, .topbar .role-badge { display: none; }
}
