/* =====================================================================
   Panel administrativo · Yerba Mate CEFA
   Interfaz de gestión de contenido del sitio
   ===================================================================== */

:root {
  --sidebar-w: 264px;
  --topbar-h: 66px;
  --green-900: #06280F;
  --green-800: #0B3D1A;
  --green-700: #0B6B23;
  --brand:     #05751D;
  --brand-lt:  #39A701;
  --green-400: #49A760;
  --green-300: #8FCB9B;
  --green-100: #E3F1E5;
  --green-50:  #F1F8F2;
  --sand:      #F6F5F1;
  --ink:       #1B2420;
  --body:      #4A5A52;
  --muted:     #7C8C84;
  --line:      #E2E8E3;
  --danger:    #C62828;
  --danger-bg: #FDECEC;
  --warn:      #B8860B;
  --warn-bg:   #FEF6E3;
  --font-display: 'Roboto Slab', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 3px 12px rgba(6, 40, 15, .07);
  --shadow-md: 0 12px 30px rgba(6, 40, 15, .11);
  --ease: cubic-bezier(.22, .68, .32, 1);
}

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

body.admin {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  color: var(--body);
  background: var(--sand);
  -webkit-font-smoothing: antialiased;
}
body.admin img, body.admin svg { max-width: 100%; }
body.admin ul, body.admin ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-lt); }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.25;
  margin: 0 0 .5em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
  background: var(--green-50);
  padding: .12em .42em;
  border-radius: 4px;
}
:focus-visible { outline: 3px solid var(--brand-lt); outline-offset: 2px; }

/* ==================================================== Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 12% 18%, rgba(57, 167, 1, .22), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(255, 255, 255, .1), transparent 45%),
    linear-gradient(150deg, var(--green-900), var(--green-800) 55%, var(--green-700));
}
.login-card {
  width: min(100%, 430px);
  background: #fff;
  border-radius: 22px;
  padding: 2.2rem;
  box-shadow: var(--shadow-md);
}
.login-card__logo { width: 96px; margin: 0 auto 1.2rem; display: block; }
.login-card h1 { text-align: center; font-size: 1.4rem; margin-bottom: .3rem; }
.login-card__sub { text-align: center; font-size: .88rem; color: var(--muted); margin-bottom: 1.8rem; }
.login-foot { text-align: center; margin-top: 1.6rem; font-size: .8rem; color: var(--muted); }
.login-foot a { font-weight: 600; }

/* ==================================================== Estructura */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--green-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 200;
  transition: transform .3s var(--ease);
}
.sidebar__brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.1rem 1.2rem;
  min-height: var(--topbar-h);
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.sidebar__brand img {
  width: 40px; height: 40px;
  background: #fff; border-radius: 10px; padding: 4px; object-fit: contain;
}
.sidebar__brand strong { display: block; font-size: .93rem; line-height: 1.2; }
.sidebar__brand span { font-size: .72rem; color: var(--green-300); }

.sidebar__nav { flex: 1; padding: 1rem .8rem 1.6rem; overflow-y: auto; }
.sidebar__group {
  padding: 1rem .6rem .4rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .42);
}
.sidebar__link {
  display: flex; align-items: center; gap: .7rem;
  padding: .68rem .8rem;
  border-radius: var(--radius-sm);
  color: var(--green-200);
  font-size: .89rem;
  font-weight: 500;
  margin-bottom: .15rem;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.sidebar__link svg { flex-shrink: 0; opacity: .85; }
.sidebar__link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar__link.is-active { background: var(--brand); color: #fff; }
.sidebar__link .pill {
  margin-left: auto;
  padding: .05rem .45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  font-size: .7rem;
  font-weight: 700;
}
.sidebar__link.is-active .pill { background: rgba(0, 0, 0, .25); }

.sidebar__foot {
  padding: .9rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, .09);
  font-size: .76rem;
  color: var(--green-300);
}
.sidebar__user { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.sidebar__avatar {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand-lt);
  color: var(--green-900);
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar__user strong { display: block; color: #fff; font-size: .84rem; }
.sidebar__logout {
  display: flex; align-items: center; gap: .5rem;
  color: var(--green-200); font-size: .82rem;
  padding: 0; cursor: pointer; width: 100%; text-align: left;
  border: 0; background: none;
}
.sidebar__logout:hover { color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
  position: sticky; top: 0; z-index: 150;
  display: flex; align-items: center; gap: 1rem;
  min-height: var(--topbar-h);
  padding: .7rem 1.5rem;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.admin-topbar h1 { margin: 0; font-size: 1.2rem; overflow-wrap: break-word; }
/* Permite que el bloque del título y el de acciones se encojan y bajen de
   línea en pantallas angostas en lugar de desbordar el ancho de la página. */
.admin-topbar > div { min-width: 0; }
.admin-topbar__actions {
  margin-left: auto;
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sidebar-toggle { display: none; }

.content { padding: 1.8rem 1.5rem 3rem; flex: 1; }
.content__inner { max-width: 1180px; }

/* ==================================================== Tarjetas */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.4rem;
  overflow: hidden;
}
.card__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: .8rem;
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--line);
}
.card__head h2, .card__head h3 { margin: 0; }
.card__head .spacer { margin-left: auto; }
.card__body { padding: 1.3rem; }
.card__body--flush { padding: 0; }
.card__foot {
  padding: 1rem 1.3rem;
  border-top: 1px solid var(--line);
  background: var(--green-50);
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
}

/* ==================================================== Métricas */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.8rem;
}
.metric {
  display: flex; align-items: center; gap: .9rem;
  padding: 1.2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.metric__icon {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 13px;
  background: var(--green-50);
  color: var(--brand);
  flex-shrink: 0;
}
.metric__num {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}
.metric__label { font-size: .8rem; color: var(--muted); }

/* ==================================================== Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .62rem 1.15rem;
  border-radius: 999px;
  border: 2px solid transparent;
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s var(--ease);
}
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 5px 14px rgba(5, 117, 29, .24); }
.btn--primary:hover { background: var(--brand-lt); color: #fff; }
.btn--lime { background: var(--brand-lt); color: var(--green-900); }
.btn--lime:hover { background: #4BBF10; color: var(--green-900); }
.btn--outline { border-color: var(--line); color: var(--body); background: #fff; }
.btn--outline:hover { border-color: var(--brand); color: var(--brand); }
.btn--ghost { color: var(--muted); }
.btn--ghost:hover { background: var(--green-50); color: var(--brand); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #A32020; color: #fff; }
.btn--wa { background: #25D366; color: #fff; }
.btn--wa:hover { background: #1eb855; color: #fff; }
.btn--sm { padding: .4rem .8rem; font-size: .8rem; }
.btn--lg { padding: .85rem 1.5rem; font-size: .95rem; }
.btn--block { display: flex; width: 100%; }
.btn--icon-only { padding: .4rem; width: 32px; height: 32px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ==================================================== Formularios */
.field { margin-bottom: 1.1rem; }
.field__label {
  display: block;
  margin-bottom: .4rem;
  font-size: .84rem;
  font-weight: 600;
  color: var(--ink);
}
.field__hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--danger); }
.field__error { font-size: .78rem; color: var(--danger); margin-top: .3rem; }

.input, .select, .textarea {
  width: 100%;
  padding: .65rem .85rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--ink);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(5, 117, 29, .12);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.textarea--tall { min-height: 300px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A5A52' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  background-size: 15px;
  padding-right: 2.2rem;
}

.check { display: flex; align-items: flex-start; gap: .55rem; font-size: .88rem; cursor: pointer; }
.check input { width: 17px; height: 17px; margin-top: .22rem; accent-color: var(--brand); flex-shrink: 0; }

.form-grid { display: grid; gap: 0 1.1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* Interruptor */
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .88rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 42px; height: 24px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background-color .22s var(--ease);
  flex-shrink: 0;
}
.switch__track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .22s var(--ease);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--brand-lt); outline-offset: 2px; }

/* ==================================================== Alertas */
.alert {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .9rem 1.1rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  font-size: .88rem;
  margin-bottom: 1.2rem;
}
.alert svg { flex-shrink: 0; margin-top: .18rem; }
.alert strong { display: block; color: inherit; margin-bottom: .1rem; }
.alert--success { background: var(--green-50); border-color: var(--brand); color: #14532B; }
.alert--error   { background: var(--danger-bg); border-color: var(--danger); color: #8A1F1F; }
.alert--warning { background: var(--warn-bg); border-color: var(--warn); color: #7A5C05; }
.alert--info    { background: #EAF2FA; border-color: #2A6DA8; color: #1B4B75; }

/* ==================================================== Insignias */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: var(--green-50);
  color: var(--brand);
  white-space: nowrap;
}
.badge--on   { background: #E8F6EC; color: #12833C; }
.badge--off  { background: #F1F2F1; color: #6B7A72; }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--info { background: #EAF2FA; color: #1B4B75; }
.badge--lime { background: rgba(57, 167, 1, .14); color: var(--green-700); }

/* ==================================================== Tablas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th {
  background: var(--green-50);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.table tbody tr:hover { background: var(--green-50); }
.table tbody tr:last-child td { border-bottom: 0; }
.table__actions { display: flex; gap: .35rem; justify-content: flex-end; }
.table__thumb {
  width: 46px; height: 46px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--green-50);
  display: grid; place-items: center;
  color: var(--brand);
  overflow: hidden;
}
.table__order { width: 60px; }
.table__order .input { padding: .3rem .45rem; text-align: center; }
.table__flag { width: 90px; }

/* ==================================================== Estados vacíos */
.empty { padding: 3rem 1.5rem; text-align: center; }
.empty__icon {
  display: grid; place-items: center;
  width: 62px; height: 62px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--green-50);
  color: var(--brand);
}
.empty h3 { margin-bottom: .35rem; }
.empty p { color: var(--muted); font-size: .9rem; max-width: 400px; margin: 0 auto 1.4rem; }

/* ==================================================== Cargador de imagen */
.img-picker { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: flex-start; }
.img-picker__preview {
  width: 168px; height: 168px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  display: grid; place-items: center;
  background: var(--green-50);
  color: var(--green-400);
  overflow: hidden;
  flex-shrink: 0;
  text-align: center;
  padding: .8rem;
}
.img-picker__preview img { width: 100%; height: 100%; object-fit: contain; }
.img-picker__preview small { font-size: .74rem; line-height: 1.35; }
.img-picker__controls { flex: 1; min-width: 210px; }
.img-picker__controls input[type="file"] {
  width: 100%;
  padding: .55rem;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  background: #fff;
}

/* ==================================================== Filtros */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin-bottom: 1.3rem;
}
.filters-bar__chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.filters-bar__search { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; align-items: center; }
.filters-bar__search .input { min-width: 220px; }
.filters-bar--stack { flex-direction: column; align-items: stretch; }
.filters-bar--stack .filters-bar__search { margin-left: 0; }
.filters-bar--stack .filters-bar__search .input { flex: 1; }
.chip {
  padding: .42rem .9rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--body);
  font-size: .84rem;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: .4rem;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ==================================================== Ayudas */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.4rem; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.small { font-size: .82rem; }
.divider { height: 1px; background: var(--line); margin: 1.4rem 0; border: 0; }

.help-list { counter-reset: help; }
.help-list li {
  position: relative;
  padding: .9rem 0 .9rem 2.4rem;
  border-bottom: 1px solid var(--line);
  counter-increment: help;
}
.help-list li:last-child { border-bottom: 0; }
.help-list li::before {
  content: counter(help);
  position: absolute; left: 0; top: .95rem;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--green-50);
  color: var(--brand);
  font-size: .78rem;
  font-weight: 700;
}
.help-list strong { display: block; color: var(--ink); margin-bottom: .1rem; }

/* ==================================================== Adaptación */
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: grid; }
  .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(6, 40, 15, .5);
    z-index: 190;
    display: none;
  }
  body.sidebar-open .sidebar-backdrop { display: block; }
}

@media (max-width: 640px) {
  .content { padding: 1.2rem 1rem 2.5rem; }
  .admin-topbar { padding: .7rem 1rem; flex-wrap: wrap; row-gap: .6rem; }
  .admin-topbar h1 { font-size: 1.05rem; }
  .admin-topbar__actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .card__head { padding: .9rem 1rem; }
  .card__body { padding: 1rem; }
  .metrics { grid-template-columns: 1fr; gap: .8rem; }
  .table th, .table td { padding: .65rem .7rem; }
  .row-actions .btn { flex: 1; }
  .filters-bar__search { margin-left: 0; width: 100%; }
  .filters-bar__search .input { flex: 1; min-width: 0; }
}