/*!
 * Bitto — CSS de shells (layouts de aplicación)
 * Fuente de verdad: design_handoff_bitto/Bitto Shells.dc.html
 *   Shell A — Sitio comercial       -> .bt-shell--public  (views/layouts/public.php)
 *   Shell B — Autenticación         -> .bt-shell--auth    (views/layouts/auth.php)
 *   Shell C — Portal público tenant -> .bt-shell--portal  (views/layouts/portal.php)
 *   Shell D — Aplicación interna    -> .bt-shell--panel   (views/layouts/panel.php)
 *   Shell E — Backoffice de Bitto   -> .bt-shell--panel.bt-shell--backoffice (variante del mismo layout)
 *
 * Depende de los tokens de web/css/bitto.css (--bt-*). No redefine componentes
 * bt-btn/bt-badge/etc., solo la estructura (shell) que los envuelve.
 */

.bt-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bt-bg);
  color: var(--bt-text);
}

.bt-shell__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--bt-radius-md);
  background: var(--bt-primary);
  color: var(--bt-on-primary);
  font-weight: 700;
  font-size: 16px;
}
.bt-shell__logo--sm { width: 22px; height: 22px; border-radius: var(--bt-radius-sm); font-size: 12px; }

.bt-shell__wordmark { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }

/* Enlace de marca (logo + wordmark) usado en los headers de public.php y
   auth.php — evita el subrayado de <a> por defecto. */
.bt-shell__brand-link { text-decoration: none; }

/* ==========================================================================
   Shell A — Sitio comercial (Shells.dc.html líneas 44-97)
   ========================================================================== */
.bt-shell--public .bt-shell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 64px;
  height: 68px;
  background: var(--bt-surface);
  border-bottom: 1px solid var(--bt-divider);
  flex-shrink: 0;
}
.bt-shell--public .bt-shell__brand { display: flex; align-items: center; gap: 8px; }
.bt-shell--public .bt-shell__nav { display: flex; align-items: center; gap: 28px; font-size: 14px; font-weight: 500; }
.bt-shell--public .bt-shell__nav a { color: var(--bt-secondary); }
.bt-shell--public .bt-shell__nav a.is-active { color: var(--bt-text); font-weight: 600; }
.bt-shell--public .bt-shell__actions { display: flex; align-items: center; gap: 12px; }
.bt-shell--public .bt-shell__actions a { font-size: 14px; font-weight: 600; white-space: nowrap; }

.bt-shell--public .bt-shell__main { flex: 1; }

.bt-shell--public .bt-shell__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 64px;
  border-top: 1px solid var(--bt-divider);
  background: var(--bt-bg);
  font-size: 12px;
  color: var(--bt-text-muted);
  flex-wrap: wrap;
}
.bt-shell--public .bt-shell__footer a { color: var(--bt-text-muted); }
.bt-shell--public .bt-shell__footer-links { display: flex; gap: 8px; align-items: center; }

/* ==========================================================================
   Shell B — Autenticación y onboarding (Shells.dc.html líneas 100-159)
   ========================================================================== */
.bt-shell--auth {
  display: grid;
  grid-template-columns: 1fr 520px;
  min-height: 100vh;
}
.bt-shell--auth .bt-shell__auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px;
}
.bt-shell--auth .bt-shell__auth-box {
  width: 420px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.bt-shell--auth .bt-shell__auth-brand { display: flex; align-items: center; gap: 8px; }

.bt-shell--auth .bt-shell__auth-steps { display: flex; align-items: center; gap: 6px; }
.bt-shell--auth .bt-shell__auth-step { height: 4px; flex: 1; border-radius: 2px; background: var(--bt-border); }
.bt-shell--auth .bt-shell__auth-step.is-done { background: var(--bt-primary); }
.bt-shell--auth .bt-shell__auth-steps-label { font-size: 12px; color: var(--bt-text-muted); margin-left: 8px; white-space: nowrap; }

.bt-shell--auth .bt-shell__auth-heading h1 { font-size: 26px; letter-spacing: -0.02em; }
.bt-shell--auth .bt-shell__auth-heading p { margin-top: 6px; font-size: 14px; color: var(--bt-text-muted); }

.bt-shell--auth .bt-shell__auth-footnote { font-size: 13px; color: var(--bt-text-muted); text-align: center; }

.bt-shell--auth .bt-shell__auth-aside {
  background: var(--bt-primary);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  gap: 20px;
}
.bt-shell--auth .bt-shell__auth-aside-eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: #9BC0C8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.bt-shell--auth .bt-shell__auth-aside h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.bt-shell--auth .bt-shell__auth-aside ul { display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: #D4E4E8; }
.bt-shell--auth .bt-shell__auth-aside li::before { content: '✓ '; }

@media (max-width: 900px) {
  .bt-shell--auth { grid-template-columns: 1fr; }
  .bt-shell--auth .bt-shell__auth-aside { display: none; }
}

/* $this->params['authAside'] === false (ej. login/B02): sin panel lateral,
   tarjeta centrada en toda la columna, como en el mockup. */
.bt-shell--auth.bt-shell--auth-no-aside {
  grid-template-columns: 1fr;
}

/* ==========================================================================
   Shell C — Portal público del tenant (Shells.dc.html líneas 161-199)
   Fondo cálido distinto del resto de shells (identidad "no-Bitto" del portal).
   El acento/color de marca por tenant no está soportado por datos aún, así
   que se usa --bt-primary como color de marca por defecto (ver task-2-report).
   ========================================================================== */
.bt-shell--portal { background: #FBF9F6; color: #3A2A24; }
.bt-shell--portal .bt-shell__portal-accent { height: 4px; background: var(--bt-primary); flex-shrink: 0; }
.bt-shell--portal .bt-shell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 64px;
  height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid #EDE7DF;
  flex-shrink: 0;
}
.bt-shell--portal .bt-shell__brand { display: flex; align-items: center; gap: 10px; }
.bt-shell--portal .bt-shell__brand-name { font-size: 16px; font-weight: 700; color: #3A2A24; }
.bt-shell--portal .bt-shell__nav { display: flex; align-items: center; gap: 24px; font-size: 14px; font-weight: 500; }
.bt-shell--portal .bt-shell__nav a { color: #6B5A50; }
.bt-shell--portal .bt-shell__nav a.bt-shell__nav-cta {
  font-weight: 600;
  color: #FFFFFF;
  background: var(--bt-primary);
  border-radius: var(--bt-radius-md);
  padding: 9px 16px;
}

.bt-shell--portal .bt-shell__main { flex: 1; }

.bt-shell--portal .bt-shell__footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px 64px;
  border-top: 1px solid #EDE7DF;
  background: #FFFFFF;
  font-size: 12px;
  color: #6B5A50;
  flex-wrap: wrap;
  text-align: center;
}
.bt-shell--portal .bt-shell__footer a { color: #6B5A50; }

@media (max-width: 640px) {
  .bt-shell--portal .bt-shell__header,
  .bt-shell--portal .bt-shell__footer { padding-left: 20px; padding-right: 20px; }
  .bt-shell--portal .bt-shell__nav { gap: 12px; }
}

/* Task 14 — a 390px el header de altura fija (64px, sin wrap) desbordaba:
   "QA Controller — Centro de atención" no cabe junto a los 3 enlaces de
   nav en una sola línea de 64px, así que el texto se partía carácter por
   carácter dentro de su propio ancho fijo, inflando el header a varias
   líneas. El mockup mobile (Bitto Mobile.dc.html M-C01) resuelve esto con
   un header más compacto (nombre truncado + ícono de menú); aquí, sin
   agregar un menú hamburguesa nuevo (fuera de alcance), se deja que el
   header pase a dos líneas controladas: marca arriba, nav abajo. */
@media (max-width: 480px) {
  .bt-shell--portal .bt-shell__header {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    row-gap: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .bt-shell--portal .bt-shell__brand-name {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
  }
  .bt-shell--portal .bt-shell__nav {
    width: 100%;
    gap: 16px;
    font-size: 13px;
  }
  .bt-shell--portal .bt-shell__nav a.bt-shell__nav-cta { margin-left: auto; padding: 8px 12px; }
}

/* ==========================================================================
   Shell D — Aplicación interna: topbar + sidebar (Shells.dc.html líneas 201-308)
   ========================================================================== */
.bt-shell--panel { height: 100vh; overflow: hidden; }

.bt-shell--panel .bt-shell__topbar {
  height: 56px;
  background: var(--bt-surface);
  border-bottom: 1px solid var(--bt-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  flex-shrink: 0;
}
.bt-shell--panel .bt-shell__workspace {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius-md);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--bt-text);
  background: none;
}
.bt-shell--panel .bt-shell__search {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bt-bg);
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius-md);
  padding: 8px 12px;
  color: var(--bt-disabled-text);
}
.bt-shell--panel .bt-shell__search input {
  border: none;
  background: transparent;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--bt-text);
}
.bt-shell--panel .bt-shell__search input::placeholder { color: var(--bt-disabled-text); }
.bt-shell--panel .bt-shell__kbd {
  font-family: var(--bt-font-mono);
  font-size: 10px;
  color: var(--bt-disabled-text);
  border: 1px solid var(--bt-border);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}
.bt-shell--panel .bt-shell__topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.bt-shell--panel .bt-shell__icon-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: var(--bt-radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--bt-secondary);
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
}
.bt-shell--panel .bt-shell__icon-btn:hover { background: var(--bt-divider); }
.bt-shell--panel .bt-shell__icon-btn .bt-shell__dot {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: var(--bt-radius-pill);
  background: var(--bt-danger);
  border: 1.5px solid var(--bt-surface);
}

/* Trigger del menú de cuenta: <button> real (accesible por teclado) que
   solo envuelve el avatar, sin borde/fondo propios. */
.bt-shell--panel .bt-shell__avatar-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
}

/* Menú de cuenta (dropdown del avatar): posición y contenido. */
.bt-shell--panel .bt-shell__account-menu { right: 0; min-width: 220px; }
.bt-shell--panel .bt-shell__account-info { padding: 8px 10px; }
.bt-shell--panel .bt-shell__account-name { font-size: 13px; font-weight: 700; }
.bt-shell--panel .bt-shell__account-email { font-size: 12px; color: var(--bt-text-muted); }
.bt-shell--panel .bt-shell__account-divider { border-top: 1px solid var(--bt-border); margin: 4px 0; }
.bt-shell--panel .bt-shell__account-logout-form { margin: 0; }

.bt-shell--panel .bt-shell__body { display: flex; flex: 1; min-height: 0; }

.bt-shell--panel .bt-shell__sidebar {
  width: 216px;
  background: var(--bt-surface);
  border-right: 1px solid var(--bt-border);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 2px;
  flex-shrink: 0;
  overflow-y: auto;
}
.bt-shell--panel .bt-shell__nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--bt-radius-md);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--bt-secondary);
  cursor: pointer;
}
.bt-shell--panel .bt-shell__nav-item:hover { background: var(--bt-divider); }
.bt-shell--panel .bt-shell__nav-item.is-active {
  background: var(--bt-primary-tint);
  color: var(--bt-primary);
  font-weight: 600;
}
.bt-shell--panel .bt-shell__nav-item__icon { width: 16px; text-align: center; font-size: 13px; flex-shrink: 0; }
.bt-shell--panel .bt-shell__nav-item__label { flex: 1; }
.bt-shell--panel .bt-shell__nav-item__count {
  font-size: 11px;
  font-weight: 700;
  color: #FFFFFF;
  background: var(--bt-danger);
  border-radius: var(--bt-radius-pill);
  padding: 1px 7px;
}

.bt-shell--panel .bt-shell__plan {
  margin-top: auto;
  border: 1px solid var(--bt-border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bt-shell--panel .bt-shell__plan-row { display: flex; justify-content: space-between; font-size: 12px; }
.bt-shell--panel .bt-shell__plan-meter { height: 4px; border-radius: 2px; background: var(--bt-divider); overflow: hidden; }
.bt-shell--panel .bt-shell__plan-meter span { display: block; height: 100%; background: var(--bt-warning); }
.bt-shell--panel .bt-shell__plan-label { font-weight: 600; }
.bt-shell--panel .bt-shell__plan-badge { margin-left: 6px; }
/* "Mejorar" pasa de <a> a <button disabled> (fix review: no fingir que
   lleva a algún lado) — reset de estilos default de <button> para
   conservar la apariencia de link del mockup, ya en tono "deshabilitado"
   (mismo tratamiento que .bt-settings__link-btn[disabled] en settings.css). */
.bt-shell--panel .bt-shell__plan-upgrade {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--bt-font-ui);
  background: none;
  border: none;
  padding: 0;
  color: var(--bt-disabled-text);
  cursor: not-allowed;
}
/* Override puntual de .bt-caption (mayúsculas + tracking) para el uso de IA. */
.bt-shell--panel .bt-shell__plan-usage { text-transform: none; letter-spacing: normal; display: flex; justify-content: space-between; }

.bt-shell--panel .bt-shell__content { flex: 1; overflow: auto; padding: 24px 28px; }

@media (max-width: 1024px) {
  .bt-shell--panel .bt-shell__sidebar { width: 64px; }
  .bt-shell--panel .bt-shell__nav-item__label,
  .bt-shell--panel .bt-shell__nav-item__count,
  .bt-shell--panel .bt-shell__plan { display: none; }
}
@media (max-width: 768px) {
  .bt-shell--panel .bt-shell__search { display: none; }
}

/* ==========================================================================
   Tab bar móvil (<768px, Task 14) — Bitto Mobile.dc.html M-D01/M-D02.
   Reemplaza el sidebar de escritorio: navegación inferior fija con los 4
   destinos que sí tienen ruta real (ver comentario junto a $mobileTabs en
   views/layouts/panel.php). No aplica al backoffice (sin variante mobile en
   el handoff, fuera de alcance de esta tarea).
   ========================================================================== */
.bt-shell__mobile-tabbar { display: none; }

@media (max-width: 768px) {
  .bt-shell--panel:not(.bt-shell--backoffice) { height: auto; min-height: 100vh; overflow: visible; }
  .bt-shell--panel:not(.bt-shell--backoffice) .bt-shell__sidebar { display: none; }
  .bt-shell--panel:not(.bt-shell--backoffice) .bt-shell__body { overflow: visible; }
  .bt-shell--panel:not(.bt-shell--backoffice) .bt-shell__content {
    /* min-width:0 es necesario, no cosmético (Task 14 fix): .bt-shell__content
       es un item de .bt-shell__body (flex row); overflow:auto en el bloque
       de escritorio activa la regla de flexbox que pone su "automatic
       minimum size" en 0, pero al cambiar aquí a overflow:visible (para que
       la página completa haga scroll, no un panel interno) esa regla deja
       de aplicar y el item vuelve a su mínimo por CONTENIDO — si algún
       descendiente pide ser ancho (ej. .bt-settings__nav, una fila de tabs
       con overflow-x:auto propio), todo el flex item se ensancha y desborda
       el viewport en vez de solo hacer scroll interno en ese descendiente.
       Visto en /settings/index a 390px: sin esto, .bt-shell__content medía
       ~1039px real. */
    min-width: 0;
    overflow: visible;
    padding: 16px 16px calc(76px + 16px);
  }

  .bt-shell--panel:not(.bt-shell--backoffice) .bt-shell__mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--bt-surface);
    border-top: 1px solid var(--bt-border);
    z-index: 60;
  }
  .bt-shell__mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 44px;
    color: var(--bt-secondary);
    text-decoration: none;
  }
  .bt-shell__mobile-tab:hover { color: var(--bt-secondary); text-decoration: none; }
  .bt-shell__mobile-tab__icon { font-size: 17px; line-height: 1; }
  .bt-shell__mobile-tab__label { font-size: 10px; font-weight: 600; }
  .bt-shell__mobile-tab.is-active { color: var(--bt-primary); }
  .bt-shell__mobile-tab.is-active .bt-shell__mobile-tab__label { font-weight: 700; }
}

/* Topbar angosta (≤480px): se retiran acciones redundantes con el tab bar
   ("+ Nuevo ticket" ya está en la barra inferior como "Nuevo") y de menor
   prioridad (Ayuda) para que quepan avatar + notificaciones + tema sin
   desbordar — mismo criterio del header mobile del mockup (M-D01: solo
   logo+nombre, campana, avatar). */
@media (max-width: 480px) {
  .bt-shell--panel .bt-shell__topbar { padding: 0 12px; gap: 8px; }
  .bt-shell--panel .bt-shell__topbar-actions { gap: 8px; }
  .bt-shell--panel .bt-shell__topbar-actions > a.bt-btn { display: none; }
  .bt-shell--panel .bt-shell__icon-btn[title="Ayuda"] { display: none; }
  .bt-shell--panel .bt-shell__workspace { padding: 6px 8px; gap: 6px; }
  .bt-shell--panel .bt-shell__workspace svg { display: none; }
  .bt-shell--panel .bt-shell__workspace span:not(.bt-shell__logo) {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ==========================================================================
   Shell E — Backoffice de Bitto (Shells.dc.html líneas 310-362)
   Variante del panel: sin sidebar de tenant, banner administrativo, tema
   oscuro forzado (el backoffice no sigue el toggle de tema del tenant).
   ========================================================================== */
.bt-shell--panel.bt-shell--backoffice {
  background: #10171C;
  color: #ECF1F2;
}
.bt-shell--panel.bt-shell--backoffice .bt-shell__admin-banner {
  height: 34px;
  background: var(--bt-warning);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #10171C;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  text-align: center;
  padding: 0 12px;
}
.bt-shell--panel.bt-shell--backoffice .bt-shell__topbar {
  height: 52px;
  background: #151F26;
  border-bottom: 1px solid #24312F;
  gap: 20px;
}
.bt-shell--panel.bt-shell--backoffice .bt-shell__logo { background: #3D93A3; color: #0C1214; border-radius: 7px; width: 24px; height: 24px; }
.bt-shell--panel.bt-shell--backoffice .bt-shell__wordmark { font-size: 14px; color: #ECF1F2; }
.bt-shell--panel.bt-shell--backoffice .bt-shell__wordmark strong { color: var(--bt-warning); font-weight: 700; }
.bt-shell--panel.bt-shell--backoffice .bt-shell__admin-nav { display: flex; gap: 4px; font-size: 13px; font-weight: 600; }
.bt-shell--panel.bt-shell--backoffice .bt-shell__admin-nav a { color: #8FA0A8; padding: 7px 12px; border-radius: 7px; }
.bt-shell--panel.bt-shell--backoffice .bt-shell__admin-nav a.is-active { color: #ECF1F2; background: rgba(255, 255, 255, 0.08); }
.bt-shell--panel.bt-shell--backoffice .bt-shell__admin-nav a:hover { color: #ECF1F2; }
.bt-shell--panel.bt-shell--backoffice .bt-shell__content { background: #10171C; }
.bt-shell--panel.bt-shell--backoffice .bt-avatar { background: #3D93A3; color: #0C1214; }

/* ==========================================================================
   Shell legacy (main.php) — wrapper mínimo, no forma parte de los 4 shells
   del handoff. Reusa la tipografía/tokens bt- sin las medidas de un shell
   específico (ver decisión de controlador en task-2-report.md).
   ========================================================================== */
.bt-shell--legacy .bt-shell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--bt-surface);
  border-bottom: 1px solid var(--bt-border);
}
.bt-shell--legacy .bt-shell__brand { display: flex; align-items: center; gap: 8px; }
.bt-shell--legacy .bt-shell__nav { display: flex; align-items: center; gap: 20px; font-size: 14px; font-weight: 500; }
.bt-shell--legacy .bt-shell__nav a { color: var(--bt-secondary); }
.bt-shell--legacy .bt-shell__actions { display: flex; align-items: center; gap: 12px; }
.bt-shell--legacy .bt-shell__logout-form { display: inline-flex; margin: 0; }
.bt-shell--legacy .bt-shell__main { flex: 1; padding: 32px 24px; }
.bt-shell--legacy .bt-shell__container { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.bt-shell--legacy .bt-shell__breadcrumbs { display: flex; gap: 6px; }
.bt-shell--legacy .bt-shell__breadcrumbs a { color: var(--bt-text-muted); }
.bt-shell--legacy .bt-shell__footer {
  padding: 16px 24px;
  border-top: 1px solid var(--bt-border);
  background: var(--bt-bg);
  font-size: 12px;
  color: var(--bt-text-muted);
  text-align: center;
}
