/* ============================================================
   MULTICOTIZADOR BTG — Layout
   AppShell · SideNavBar · TopNavBar · Grids · Page patterns
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   APP SHELL
   Sidebar 256px fijo izquierda + Header 104px fijo arriba
   ───────────────────────────────────────────────────────────── */

.app-shell {
  min-height: 100vh;
}

/* ─────────────────────────────────────────────────────────────
   TOP NAV BAR (Header)
   Confirmado Figma: 1284px ancho × 104px alto
   Background levemente más oscuro que el sidebar
   ───────────────────────────────────────────────────────────── */

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--height-header);   /* 104px — confirmado Figma */
  background: var(--color-header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-5);         /* 24px — mismo que sidebar */
  z-index: 100;
}

/* Logo izquierda — BTG icon + "Black Tower Group" */
.top-nav-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.top-nav-logo .btg-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.top-nav-logo .btg-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.top-nav-logo .btg-text span {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  line-height: 1.3;
  letter-spacing: 0.02em;
}

/* Íconos derecha */
.top-nav-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.top-nav-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-default);
  transition: var(--transition);
  font-size: 20px;
  position: relative;
}

.top-nav-icon-btn:hover {
  color: rgba(255,255,255,1);
  background: rgba(255,255,255,0.08);
}

.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--color-error);
  border-radius: 50%;
  border: 1.5px solid var(--color-header-bg);
}

/* ─────────────────────────────────────────────────────────────
   SIDE NAV BAR (Aside)
   Confirmado Figma: 256px ancho × full height
   Background: #0c1a27 · border-right: #1e293b
   El sidebar comienza en top:0 y el logo tiene padding-top:150px
   para alinearse debajo del header
   ───────────────────────────────────────────────────────────── */

.side-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--width-sidebar);     /* 256px — confirmado Figma */
  background: var(--color-shell-bg);
  border-right: 1px solid var(--color-shell-border);
  box-shadow: var(--shadow-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 90;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Área logo (ocupa el espacio del header) ── */
.side-nav-brand {
  padding: var(--height-header) var(--sp-5) var(--sp-6);
  /* padding-top coincide con height-header para quedar debajo del header */
  flex-shrink: 0;
}

.side-nav-brand .brand-title {
  font-family: var(--font-display);
  font-weight: 900;              /* Raleway Black — confirmado Figma */
  font-size: 18px;               /* confirmado Figma */
  color: #ffffff;
  line-height: 1.3;
  margin-bottom: 2px;
}

.side-nav-brand .brand-role {
  font-family: var(--font-body);
  font-weight: 600;              /* Open Sans SemiBold — confirmado Figma */
  font-size: var(--text-caption); /* 12px — confirmado Figma */
  color: var(--color-accent);    /* #22d3ee — confirmado Figma */
  line-height: 1.4;
}

/* ── Área de navegación ── */
.side-nav-links {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;                      /* confirmado Figma */
  padding: 0 0 var(--sp-3);
}

/* ── Nav item base ── */
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);              /* 12px — confirmado Figma */
  padding: var(--sp-3) var(--sp-5); /* 12px 24px — confirmado Figma */
  font-family: var(--font-body);
  font-size: 14px;               /* confirmado Figma */
  font-weight: 400;
  color: var(--color-nav-inactive); /* #94a3b8 — confirmado Figma */
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  border-left: 4px solid transparent;
  user-select: none;
  line-height: 1;
}

.nav-link:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.05);
}

/* ── Nav item ACTIVO — confirmado Figma ── */
.nav-link.active {
  background: var(--color-nav-active-bg);   /* rgba(255,255,255,0.10) */
  border-left: 4px solid var(--color-accent); /* #22d3ee */
  color: var(--color-accent);               /* #22d3ee */
  font-weight: 600;
  padding-left: 20px; /* 24px - 4px border = 20px para compensar el border-left */
}

.nav-link .nav-icon {
  font-size: 24px;               /* confirmado Figma: icon size 24px */
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Logo text dentro del sidebar ── */
.side-nav-logo { display: flex; align-items: center; gap: 10px; }
.logo-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 2px;
}
.logo-sub {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12px;
  color: var(--color-accent);
  line-height: 1.4;
}

/* ── Etiquetas de sección del sidebar ── */
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 16px 24px 4px;
  flex-shrink: 0;
}

/* ── Grupo de nav items ── */
.side-nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Badge de contador en nav items ── */
.nav-badge {
  background: rgba(232,76,61,0.85);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 6px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Logout link ── */
.nav-link-logout {
  color: var(--color-nav-inactive);
}
.nav-link-logout:hover { color: rgba(255,255,255,0.8); }

/* ── Footer: Cerrar sesión ── */
.side-nav-footer {
  border-top: 1px solid var(--color-nav-divider); /* rgba(255,255,255,0.05) — Figma */
  padding: 25px var(--sp-5) var(--sp-5);          /* padding-top: 25px — Figma */
  flex-shrink: 0;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-3);              /* 12px — Figma */
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-nav-inactive); /* #94a3b8 — Figma */
  font-family: var(--font-body);
  font-size: 14px;
  transition: var(--transition);
  padding: 0;
  text-decoration: none;
}

.logout-btn:hover {
  color: rgba(255,255,255,0.8);
}

.logout-btn .nav-icon {
  font-size: 18px;               /* confirmado Figma */
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─────────────────────────────────────────────────────────────
   MAIN CONTENT AREA
   ───────────────────────────────────────────────────────────── */

.main-content {
  margin-left: var(--width-sidebar);    /* 256px */
  margin-top: var(--height-header);     /* 104px */
  padding: var(--sp-6) var(--sp-7);    /* 32px 48px */
  min-height: calc(100vh - var(--height-header));
  background: var(--color-bg-surface);
}

/* ─────────────────────────────────────────────────────────────
   PAGE HEADER (dentro de main-content)
   ───────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.page-header-left { flex: 1; min-width: 0; }

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--color-title);
  line-height: 1.2;
  margin-bottom: 0;
}

.page-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-body-s);
  color: var(--color-muted);
  margin-top: var(--sp-1);
  line-height: 1.5;
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────
   BREADCRUMB
   ───────────────────────────────────────────────────────────── */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  font-size: var(--text-body-s);
  color: var(--color-muted);
}

.breadcrumb a,
.breadcrumb .bc-link {
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.breadcrumb a:hover,
.breadcrumb .bc-link:hover {
  color: var(--color-title);
}

.breadcrumb .bc-sep {
  color: var(--color-border);
  font-size: 12px;
}

.breadcrumb .bc-current {
  color: var(--color-title);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────
   GRIDS DE CONTENIDO
   ───────────────────────────────────────────────────────────── */

/* KPI grid — 4 columnas */
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

/* KPI grid — 3 columnas (Package Management) */
.kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

/* Charts bento — ~55% + ~40% */
.charts-bento {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  align-items: start;
}

/* Charts 3 columnas (dashboard agente) */
.charts-row-3 {
  display: grid;
  grid-template-columns: 1fr 280px 240px;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  align-items: start;
}

/* Create Package — 2 columnas */
.create-pkg-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--sp-5);
  align-items: start;
}

/* ─────────────────────────────────────────────────────────────
   SECTION BOX (contenedor de tabla o card de contenido)
   ───────────────────────────────────────────────────────────── */

.section-box {
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.section-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
  gap: var(--sp-3);
}

.section-box-title {
  font-family: var(--font-display);
  font-size: var(--text-h4);
  font-weight: 600;
  color: var(--color-title);
}

.section-box-body {
  padding: var(--sp-5);
}

/* ─────────────────────────────────────────────────────────────
   TOOLBAR DE TABLA (búsqueda + filtros + acciones)
   ───────────────────────────────────────────────────────────── */

.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.table-toolbar .search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.table-toolbar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  font-size: 16px;
  pointer-events: none;
}

.table-toolbar .search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-default);
  font-size: var(--text-body-s);
  font-family: var(--font-body);
  color: var(--color-body);
  background: var(--color-bg-surface);
  outline: none;
  transition: border-color 0.15s;
}

.table-toolbar .search-input::placeholder { color: var(--color-muted); }
.table-toolbar .search-input:focus        { border-color: var(--color-accent); background: #fff; }

/* ─────────────────────────────────────────────────────────────
   TABS (content tabs — Gestión de Agentes, Performance)
   ───────────────────────────────────────────────────────────── */

.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--sp-5);
  gap: 0;
}

.tab-nav-item {
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-body);
  font-size: var(--text-body-m);
  font-weight: 400;
  color: var(--color-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.tab-nav-item:hover { color: var(--color-title); }

.tab-nav-item.active {
  color: var(--color-title);
  font-weight: 600;
  border-bottom-color: var(--color-accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─────────────────────────────────────────────────────────────
   PERIOD TABS (filtros de periodo en gráficas)
   ───────────────────────────────────────────────────────────── */

.period-tabs {
  display: flex;
  gap: 2px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
  padding: 3px;
}

.period-tab {
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.period-tab:hover  { color: var(--color-body); }
.period-tab.active {
  background: var(--color-bg-white);
  color: var(--color-title);
  box-shadow: var(--shadow-sm);
}

/* ─────────────────────────────────────────────────────────────
   STEP INDICATOR (Cotizador)
   ───────────────────────────────────────────────────────────── */

.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: var(--sp-6);
  max-width: 480px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
}

.step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  border: 2px solid var(--color-border);
  color: var(--color-muted);
  background: var(--color-bg-white);
  transition: var(--transition);
}

.step-item.active .step-circle {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-title);
  box-shadow: 0 0 0 4px rgba(34,211,238,0.20);
}

.step-item.completed .step-circle {
  background: var(--color-title);
  border-color: var(--color-title);
  color: #fff;
}

.step-label {
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}

.step-item.active    .step-label { color: var(--color-title); }
.step-item.completed .step-label { color: var(--color-success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--color-border);
  margin-top: -20px; /* alinear con centro de los círculos */
  min-width: 60px;
}

.step-connector.completed { background: var(--color-title); }

/* ─────────────────────────────────────────────────────────────
   COTIZADOR SHELL (formulario centrado)
   ───────────────────────────────────────────────────────────── */

.cotizador-shell {
  max-width: 900px;
  margin: 0 auto;
}

/* ─────────────────────────────────────────────────────────────
   LOGIN LAYOUT
   ───────────────────────────────────────────────────────────── */

.login-shell {
  display: flex;
  min-height: 100vh;
}

.login-left {
  flex: 1;
  background: var(--color-shell-bg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: var(--sp-8);
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: rgba(34,211,238,0.06);
}

.login-left::after {
  content: '';
  position: absolute;
  bottom: -100px; left: -100px;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: rgba(34,211,238,0.04);
}

.login-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-surface);
  padding: var(--sp-7);
}

.login-form-card {
  background: var(--color-bg-white);
  border-radius: var(--radius-card);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

/* ─────────────────────────────────────────────────────────────
   PAGINACIÓN
   ───────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.pagination-info {
  font-size: var(--text-body-s);
  color: var(--color-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.page-btn {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-white);
  font-size: var(--text-body-s);
  font-family: var(--font-body);
  color: var(--color-body);
  cursor: pointer;
  transition: var(--transition);
  padding: 0 var(--sp-2);
}

.page-btn:hover    { background: var(--color-bg-surface); border-color: var(--color-accent); }
.page-btn.active   { background: var(--color-title); color: #fff; border-color: var(--color-title); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─────────────────────────────────────────────────────────────
   MOBILE — Sidebar drawer
   ───────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  /* Sidebar como drawer */
  .side-nav {
    transform: translateX(-100%);
    z-index: 200;
    transition: transform 0.3s ease;
  }

  body.sidebar-open .side-nav { transform: translateX(0); }

  /* Overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12,26,39,0.5);
    z-index: 199;
  }
  body.sidebar-open .sidebar-overlay { display: block; }

  /* Header sin left offset */
  .top-nav { left: 0; }

  /* Main content sin left margin */
  .main-content {
    margin-left: 0;
    padding: var(--sp-5) var(--sp-4) var(--sp-7);
  }

  /* Grids colapsan a 1 columna */
  .kpi-grid-4, .kpi-grid-3 { grid-template-columns: 1fr 1fr; }
  .charts-bento, .charts-row-3, .create-pkg-layout { grid-template-columns: 1fr; }

  /* Paginación */
  .pagination { flex-direction: column; align-items: flex-start; }
}

/* ─────────────────────────────────────────────────────────────
   HAMBURGER (mobile only)
   ───────────────────────────────────────────────────────────── */

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  font-size: 22px;
  padding: 4px;
  align-items: center;
  justify-content: center;
}

@media (max-width: 767px) {
  .hamburger-btn { display: flex; }
}
