/* ============================================================
   BASE — LAYOUT, RESPONSIVE, NAVEGACIÓN
   v1.2 — Drawer móvil + bottom bar rediseñada
   ============================================================ */

*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Epilogue', sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
}

/* ============================================================
   LAYOUT — APP SHELL
   ============================================================ */

.app-shell {
  display: flex;
  flex-direction: column;  /* Por defecto móvil = apilado vertical */
  min-height: 100vh;
  width: 100%;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-top: 22px;   /* Aire arriba ya que no hay header */
  padding-bottom: 84px;  /* Aire para no chocar con bottom bar */
}

/* ============================================================
   DRAWER MÓVIL (menú lateral deslizable)
   ============================================================ */

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 249;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: 78%;
  max-width: 320px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 250;
  padding: 28px 0 20px;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.drawer.open { transform: translateX(0); }

/* Cuando es móvil el drawer usa estas estilos */
.drawer-brand {
  padding: 6px 24px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  color: var(--text);
}

.drawer-brand svg { display: block; margin-bottom: 6px; }

.drawer-sub {
  font-size: 10px;
  font-weight: 300;
  color: var(--text-3);
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.drawer-nav {
  flex: 1;
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
}

/* Reset de estilos cuando el drawer-item es <button> */
.drawer-item-btn {
  border: none;
  background: transparent;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.drawer-item:hover { background: var(--surface-2); color: var(--text); }
.drawer-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.drawer-item.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.drawer-item.active svg { stroke: var(--accent); }

.drawer-divider {
  margin: 14px 24px;
  height: 1px;
  background: var(--border);
}

.drawer-version {
  font-family: 'Syne', sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  padding: 14px 24px 0;
  letter-spacing: 0.1em;
}

/* ============================================================
   SIDEBAR (desktop only) — parte del flujo flex en desktop,
   se centra correctamente con el app-shell
   ============================================================ */

.sidebar {
  display: none;
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  /* En desktop será sticky dentro del flex; en móvil está oculta */
  align-self: flex-start;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 200;
  flex-direction: column;
  padding: 28px 0 20px;
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  color: var(--text);
}

.sidebar-brand svg { display: block; margin-bottom: 6px; }

.sidebar-sub {
  font-size: 10px;
  font-weight: 300;
  color: var(--text-3);
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
}

/* Reset de estilos cuando el sidebar-item es <button> */
.sidebar-item-btn {
  border: none;
  background: transparent;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.sidebar-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sidebar-item.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.sidebar-item.active svg { stroke: var(--accent); }

.sidebar-divider {
  margin: 12px 12px;
  height: 1px;
  background: var(--border);
}

.sidebar-version {
  font-family: 'Syne', sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  padding: 12px 24px 0;
  letter-spacing: 0.1em;
}

/* ============================================================
   BOTTOM BAR (móvil) — nueva estructura
   [ ≡ menú ]    [ MÓDULO ACTUAL ]    [ ⚙ ajustes ]
   ============================================================ */

.bottombar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  padding: 8px 12px 22px;
  z-index: 100;
  gap: 8px;
}

.bb-btn {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  justify-self: center;
}

.bb-btn:hover { background: var(--surface-3); color: var(--text); }
.bb-btn:active { transform: scale(0.93); }
.bb-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bb-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.bb-module {
  text-align: center;
  min-width: 0;
  overflow: hidden;
  padding: 0 4px;
}

.bb-module-name {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.bb-module-tag {
  font-family: 'Syne', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 1px;
}

/* ============================================================
   THEME PANEL (sin cambios)
   ============================================================ */

.theme-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 299;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}

.theme-overlay.open { opacity: 1; pointer-events: all; }

.theme-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border);
  z-index: 300;
  padding: 0 0 32px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.theme-panel.open { transform: translateY(0); }

.panel-handle {
  width: 36px; height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  margin: 12px auto 20px;
}

.panel-title {
  font-family: 'Syne', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-3);
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--border);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 16px 20px;
}

.theme-swatch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-2);
}

.theme-swatch:hover { border-color: var(--border-2); }
.theme-swatch.selected { border-color: var(--accent); }

.swatch-dot {
  width: 32px; height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
}

.swatch-dot-accent {
  position: absolute;
  bottom: 0; right: 0;
  width: 50%; height: 50%;
  border-radius: 4px 0 0 0;
}

.swatch-info { min-width: 0; flex: 1; }

.swatch-name {
  font-family: 'Syne', sans-serif;
  font-size: 12px; font-weight: 600;
  color: var(--text);
  display: block;
}

.swatch-desc {
  font-size: 10px;
  color: var(--text-3);
  font-weight: 300;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   CONTENT WRAPPER
   ============================================================ */

.content-wrap {
  flex: 1;
  max-width: 100%;
}

.content-inner {
  padding: 0;
  max-width: 100%;
}

/* ============================================================
   RESPONSIVE — TABLET (≥768px)
   ============================================================ */

@media (min-width: 768px) {
  body { display: flex; justify-content: center; }

  .app-shell {
    width: 100%;
    max-width: 1280px;
  }

  .bottombar {
    max-width: 520px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .content-inner {
    max-width: 720px;
    margin: 0 auto;
  }

  .theme-panel {
    max-width: 520px;
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(100%);
  }

  .theme-panel.open { transform: translateX(-50%) translateY(0); }

  .theme-grid { grid-template-columns: repeat(3, 1fr); }

  .drawer { max-width: 360px; }
}

/* ============================================================
   RESPONSIVE — DESKTOP (≥1024px)
   ============================================================ */

@media (min-width: 1024px) {
  .app-shell { flex-direction: row; }

  .sidebar { display: flex; }

  .main-area {
    /* Ya no hace falta margin-left porque la sidebar es flex item */
    padding-top: 0;
    padding-bottom: 40px;
    min-width: 0;
  }

  /* Ocultar elementos de navegación móvil */
  .bottombar { display: none; }
  .drawer { display: none; }
  .drawer-overlay { display: none; }

  .content-inner {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 32px;
  }

  .theme-panel {
    left: auto; right: 24px;
    bottom: 24px;
    transform: translateY(calc(100% + 48px));
    width: 380px;
    max-width: 380px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }

  .theme-panel.open { transform: translateY(0); }

  .theme-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.hidden { display: none !important; }

/* Desactivar scroll cuando el drawer o el theme panel están abiertos */
body.no-scroll { overflow: hidden; }
