/* css/layout.css — shell: sidebar, topbar y área de contenido.
   Desktop ≥1100: sidebar completo · Tablet 768–1099: sidebar compacto ·
   Móvil <768: drawer. */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #2A2522;
  color: #EFE9E1;
  padding: 18px 14px;
  gap: 18px;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 10px;
  color: inherit;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--brand);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; color: #fff; }
.brand-sub { font-size: var(--fs-xs); color: #B9AFA3; letter-spacing: 0.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: #8F857A; padding: 8px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: #D9D1C7;
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  position: relative;
}
.nav a svg { width: 20px; height: 20px; flex: none; opacity: 0.9; }
.nav a:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: rgba(184, 92, 56, 0.22); color: #fff; }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav .nav-count {
  margin-left: auto; font-size: var(--fs-xs); font-weight: 650;
  background: rgba(255,255,255,0.12); color: #fff; border-radius: 999px; padding: 1px 8px;
}
.nav .nav-count.is-alert { background: var(--danger); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.demo-pill {
  font-size: var(--fs-xs); color: #CBBFB2; border: 1px dashed #5A5049;
  border-radius: var(--r-md); padding: 10px 12px; line-height: 1.4;
}
.demo-pill strong { color: #fff; display: block; font-size: var(--fs-sm); }
.sidebar .btn-reset {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 1px solid #4A423C; color: #E7DFD5;
  border-radius: var(--r-md); padding: 9px 12px; font-size: var(--fs-sm); text-align: left;
}
.sidebar .btn-reset:hover { background: rgba(255,255,255,0.06); }
.sidebar .btn-reset svg { width: 18px; height: 18px; flex: none; }

/* ---------- Columna principal ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: rgba(247, 244, 239, 0.9);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 650; font-size: var(--fs-lg); white-space: nowrap; }
.topbar-spacer { flex: 1; }
.topbar .menu-btn { display: none; }

.global-search { position: relative; width: min(420px, 38vw); }
.global-search input {
  width: 100%; height: 40px; padding: 0 12px 0 38px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.global-search input:focus { border-color: var(--brand); outline: none; box-shadow: var(--focus); }
.global-search > svg { position: absolute; left: 13px; top: 11px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; padding: 6px; z-index: 50;
}
.search-group { font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); padding: 8px 10px 4px; }
.search-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 8px 10px; border-radius: var(--r-md);
}
.search-item:hover, .search-item.is-active { background: var(--surface-sunken); }
.search-item img { width: 32px; height: 32px; border-radius: 8px; }
.search-empty { padding: 14px; color: var(--ink-2); font-size: var(--fs-sm); }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  transition: background 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-sunken); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot-count {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.6875rem; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

.user-btn {
  display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); text-align: left;
}
.user-btn:hover { background: var(--surface-sunken); }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center;
  background: var(--olive); color: #fff; font-size: var(--fs-xs); font-weight: 700; flex: none;
}
.user-meta { line-height: 1.15; }
.user-meta strong { display: block; font-size: var(--fs-sm); }
.user-meta span { font-size: var(--fs-xs); color: var(--ink-2); }

.popover {
  position: absolute; top: calc(var(--topbar-h) - 6px); right: 20px; z-index: 60;
  width: min(400px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop-in 0.16s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.content { padding: 28px; max-width: 1480px; width: 100%; margin: 0 auto; }
.content:focus { outline: none; }

/* ---------- Drawer móvil ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(28, 22, 18, 0.45); z-index: 25;
  animation: fade-in 0.18s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Tablet: sidebar compacto */
@media (max-width: 1099px) {
  .app { grid-template-columns: var(--sidebar-compact-w) minmax(0, 1fr); }
  .sidebar { padding: 16px 10px; align-items: center; }
  .brand { padding: 0 0 6px; justify-content: center; }
  .brand-text, .nav-label, .nav a span, .nav .nav-count, .demo-pill, .sidebar .btn-reset span { display: none; }
  .nav a { justify-content: center; padding: 12px; }
  .nav a[aria-current="page"]::before { left: -10px; }
  .nav a .nav-dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 99px; background: var(--danger); }
  .sidebar .btn-reset { justify-content: center; padding: 10px; }
  .topbar { padding: 0 20px; }
  .content { padding: 22px 20px; }
  .user-meta { display: none; }
  .user-btn { padding: 4px; }
}
@media (min-width: 1100px) { .nav a .nav-dot { display: none; } }

/* Móvil: drawer */
@media (max-width: 767px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 84vw);
    transform: translateX(-102%); transition: transform 0.22s var(--ease);
    align-items: stretch; padding: 18px 14px; box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: none; }
  .sidebar .brand { justify-content: flex-start; padding: 4px 8px 10px; }
  .sidebar .brand-text { display: flex; }
  .sidebar .nav-label, .sidebar .nav a span, .sidebar .nav .nav-count,
  .sidebar .demo-pill, .sidebar .btn-reset span { display: initial; }
  .sidebar .nav a { justify-content: flex-start; padding: 12px; }
  .sidebar .nav a .nav-dot { display: none; }
  .sidebar .btn-reset { justify-content: flex-start; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; }
  .global-search { display: none; }
  .global-search.is-mobile-open {
    display: block; position: fixed; left: 0; right: 0; top: var(--topbar-h); width: auto;
    padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .global-search.is-mobile-open > svg { left: 25px; top: 21px; }
  .global-search.is-mobile-open .search-results { left: 12px; right: 12px; }
  .search-toggle { display: inline-grid !important; }
  .pos-quick span { display: none; }
  .pos-quick { width: 40px; padding: 0 !important; justify-content: center; }
  .content { padding: 16px; }
}
.search-toggle { display: none !important; }

/* ---------- Ajustes de presentación 1.0 ---------- */
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-sub { white-space: nowrap; font-size: 0.6875rem; }
.demo-caption { font-size: 0.6875rem; color: #9C9187; text-align: center; letter-spacing: .02em; }
@media (max-width: 1099px) { .demo-caption { display: none; } }
@media (max-width: 767px) { .sidebar .demo-caption { display: block; } }
.user-btn.is-switched { animation: switched 1.2s var(--ease); }
@keyframes switched {
  0% { box-shadow: 0 0 0 0 rgba(102, 113, 90, .55); }
  60% { box-shadow: 0 0 0 8px rgba(102, 113, 90, 0); }
  100% { box-shadow: none; }
}

/* ---------- Portada ---------- */
#cover-root { display: none; }
body.on-cover #cover-root { display: block; }
body.on-cover .app, body.on-cover .sr-only[href="#view"] { display: none; }
.cover {
  min-height: 100vh; display: flex; flex-direction: column; gap: 40px;
  padding: 32px clamp(20px, 6vw, 88px) 28px;
  background:
    radial-gradient(900px 500px at 85% 20%, rgba(217, 154, 62, .14), transparent 60%),
    radial-gradient(700px 500px at 10% 90%, rgba(184, 92, 56, .10), transparent 60%),
    var(--bg);
}
.cover-top { display: flex; align-items: center; gap: 12px; }
.cover-name { display: block; font-family: var(--font-display); font-size: 1.375rem; }
.cover-sub { display: block; font-size: var(--fs-xs); color: var(--ink-2); letter-spacing: .02em; }
.cover-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px; align-items: center; max-width: 1280px; width: 100%; margin: 0 auto; }
.cover-copy h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 3.6vw, 3.25rem); line-height: 1.08; letter-spacing: -0.02em; max-width: 16ch; }
.cover-lead { margin-top: 18px; font-size: var(--fs-lg); color: var(--ink-2); max-width: 46ch; line-height: 1.5; }
.cover-ctas { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 30px; align-items: center; }
.cover-ctas .btn-ghost { color: var(--ink-2); }
.cover-visual { position: relative; min-height: 460px; }
.cv-card { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); }
.cv-product { left: 0; top: 0; width: 60%; overflow: hidden; z-index: 1; }
.cv-product img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.cv-body { padding: 14px 18px 18px; }
.cv-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.cv-levels div { border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 10px; }
.cv-levels b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.cv-levels span { font-size: var(--fs-xs); color: var(--ink-2); }
.cv-levels .is-transit { background: var(--info-bg); border-color: transparent; color: var(--info); }
.cv-levels .is-transit span { color: var(--info); }
.cv-arrival { right: 0; top: 36px; z-index: 2; display: flex; gap: 12px; align-items: center; padding: 12px 16px; }
.cv-arrival div { display: flex; flex-direction: column; font-size: var(--fs-sm); }
.cv-arrival span { color: var(--ink-2); font-size: var(--fs-xs); }
.cv-chip { background: var(--info-bg); color: var(--info); font-weight: 750; border-radius: 10px; padding: 8px 10px; font-size: var(--fs-sm); }
.cv-progress { right: 0; bottom: 0; width: 54%; z-index: 2; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-sm); }
.cv-muted { font-size: var(--fs-xs); color: var(--warn); font-weight: 600; }
.cv-float { position: absolute; width: 150px; border-radius: var(--r-lg); box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.cv-float.f1 { right: 3%; top: 250px; width: 128px; }
.cv-float.f2 { right: 22%; top: 128px; width: 128px; z-index: 0; }
.cover-pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 1280px; width: 100%; margin: 0 auto; }
.cover-pillars article { display: flex; gap: 14px; padding: 18px 20px; background: rgba(255,255,255,.7); border: 1px solid var(--border); border-radius: var(--r-lg); }
.cp-ico { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.cp-ico svg { width: 22px; height: 22px; }
.cover-pillars h2 { font-size: var(--fs-md); margin-bottom: 4px; }
.cover-pillars p { font-size: var(--fs-sm); color: var(--ink-2); }
.cover-foot { text-align: center; font-size: var(--fs-xs); color: var(--ink-3); }
.tour-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tour-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); }
.tour-list li div { flex: 1; display: flex; flex-direction: column; font-size: var(--fs-sm); }
.tour-list li div span { color: var(--ink-2); }
.tour-list em { font-style: normal; font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }
.tour-n { width: 26px; height: 26px; flex: none; border-radius: 99px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700; }
@media (max-width: 1023px) {
  .cover-main { grid-template-columns: 1fr; gap: 28px; }
  .cover-visual { min-height: 360px; max-width: 560px; width: 100%; margin: 0 auto; }
}
@media (max-width: 767px) {
  .cover { gap: 26px; padding: 20px 16px; }
  .cover-pillars { grid-template-columns: 1fr; }
  .cover-visual { min-height: 400px; }
  .cv-product { width: 88%; left: 0; }
  .cv-arrival { display: none; }
  .cv-progress { width: 70%; }
  .cv-float { display: none; }
  .cover-ctas .btn { width: 100%; }
}

/* Enlace de salida opcional (appConfig.backLink) */
.back-out { display: block; text-align: center; font-size: var(--fs-xs); color: #CBBFB2; padding: 6px 8px; border-radius: var(--r-md); }
.back-out:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
@media (max-width: 1099px) and (min-width: 768px) { .back-out { font-size: 0; padding: 8px; } .back-out::before { content: "←"; font-size: var(--fs-md); } }
.cover-back { margin-left: auto; font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; padding: 8px 12px; border-radius: var(--r-md); }
.cover-back:hover { background: rgba(0,0,0,.04); text-decoration: none; color: var(--ink); }
