/* Kelixa — layout escritorio (≥1024px). Móvil/PWA sin cambios. */

@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --max-width: 640px;
  }
}

@media (min-width: 1024px) {
  :root {
    --sidebar-width: 260px;
    --content-max: 1200px;
    --nav-height: 0px;
  }

  body.has-app-nav {
    --nav-height: 0px;
  }

  .app-frame {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    align-items: start;
  }

  .desktop-sidebar {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 16px 20px;
    background: rgba(255, 255, 255, 0.98);
    border-right: 1px solid rgba(91, 45, 139, 0.08);
    box-shadow: 4px 0 24px rgba(91, 45, 139, 0.04);
    z-index: 30;
  }

  .desktop-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(91, 45, 139, 0.08);
  }

  .desktop-sidebar__brand img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .desktop-sidebar__brand span {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--purple-dark);
    letter-spacing: -0.02em;
  }

  .desktop-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    padding: 8px 0;
  }

  .desktop-sidebar__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .desktop-sidebar__item:hover {
    background: rgba(91, 45, 139, 0.06);
    color: var(--purple-dark);
  }

  .desktop-sidebar__item.is-active {
    background: rgba(91, 45, 139, 0.1);
    color: var(--purple);
    font-weight: 700;
  }

  .desktop-sidebar__icon {
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
  }

  .desktop-sidebar__register {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(91, 45, 139, 0.08);
  }

  .desktop-sidebar__fab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--purple), var(--purple-light));
    color: var(--white);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(91, 45, 139, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  .desktop-sidebar__fab:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(91, 45, 139, 0.35);
  }

  .desktop-sidebar__fab-icon {
    font-size: 1.2rem;
  }

  .bottom-nav {
    display: none !important;
  }

  .app-shell {
    grid-column: 2;
    grid-row: 1;
    max-width: var(--content-max);
    width: 100%;
    margin: 0;
    padding: 32px 40px 40px;
    min-height: 100vh;
  }

  .coach-home .app-shell {
    padding-top: 28px;
  }

  .keli-page--fullscreen .app-shell {
    padding-bottom: 32px;
    min-height: 100vh;
  }

  .keli-chat {
    min-height: calc(100vh - 64px);
  }

  .keli-chat--fullscreen {
    min-height: calc(100vh - 64px);
  }

  /* Subnavegación de módulos: pills en fila en lugar de scroll */
  .module-nav {
    flex-wrap: wrap;
    overflow: visible;
    gap: 10px;
  }

  .module-nav__item {
    font-size: 0.84rem;
    padding: 10px 16px;
  }

  /* Dashboard home: dos columnas para tarjetas */
  .dashboard-page .app-shell {
    column-count: 2;
    column-gap: 24px;
  }

  .dashboard-page .app-shell > .dashboard-greeting,
  .dashboard-page .app-shell > .celebration-card,
  .dashboard-page .app-shell > .module-section-head,
  .dashboard-page .app-shell > .module-nav,
  .dashboard-page .app-shell > .stats-grid {
    column-span: all;
  }

  .dashboard-page .app-shell > section,
  .dashboard-page .app-shell > nav {
    break-inside: avoid;
    margin-bottom: 20px;
  }

  .dashboard-balance__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dashboard-balance__item--full {
    grid-column: 1 / -1;
  }

  .patrimonio-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .patrimonio-grid__result {
    grid-column: auto;
  }

  .module-links {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  /* Panel Registrar: modal centrado en escritorio */
  .register-sheet {
    align-items: center;
    padding: 24px;
  }

  .register-sheet__panel {
    width: min(100%, 480px);
    max-height: 85vh;
    border-radius: 24px;
    transform: translateY(16px) scale(0.98);
  }

  .register-sheet.is-open .register-sheet__panel {
    transform: translateY(0) scale(1);
  }

  .register-sheet__primary--four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .register-option--wide {
    grid-column: 1 / -1;
  }

  /* Formularios y listas */
  .auth-card {
    max-width: 440px;
    margin: 0 auto;
  }

  .asset-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1400px) {
  :root {
    --content-max: 1280px;
  }

  .app-shell {
    padding-left: 48px;
    padding-right: 48px;
  }
}

/* Ocultar sidebar en móvil/tablet */
@media (max-width: 1023px) {
  .desktop-sidebar {
    display: none;
  }
}
