/* ============================================================================
   ribbon.css — Cinta de opciones, QAT, menús desplegables, paletas, menú
   contextual, diálogo base, backstage y (al final, secciones comentadas)
   estilos de la barra de hojas y la barra de estado.

   Todas las medidas/colores provienen de css/tokens.css (var(--xl-*)), según
   plan §2.1/§2.2: pestañas 33px, cuerpo ~94px, hover #EDEBE9 (—xl-hover-solid),
   píldora blanca en la pestaña activa, Segoe UI 12px.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. Contenedor de la cinta y fila de pestañas
   ------------------------------------------------------------------------- */

#ribbon {
  flex: none;
  background: var(--xl-ribbon-bg);
  border-bottom: 1px solid var(--xl-separator);
  user-select: none;
  font-family: var(--xl-font-ui);
  font-size: var(--xl-fontsize-ui);
}

.rb-tabs {
  height: var(--xl-ribbon-tabs-h);
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 8px;
  background: var(--xl-ribbon-bg);
}

.rb-tab {
  border: none;
  background: none;
  font: inherit;
  color: var(--xl-text-2);
  padding: 6px 12px 7px;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  white-space: nowrap;
}
.rb-tab:hover { background: var(--xl-hover-solid); }
/* Píldora blanca de la pestaña activa (se funde con el cuerpo blanco). */
.rb-tab.is-active {
  background: var(--xl-ribbon-tab-active-bg);
  color: var(--xl-text);
  font-weight: 600;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.06);
}
/* Pestaña Archivo: botón verde de marca. */
.rb-tab-file {
  background: var(--xl-green);
  color: #fff;
  border-radius: 4px;
  margin: 3px 6px 4px 0;
  padding: 4px 16px 5px;
}
.rb-tab-file:hover { background: #0B5C30; }

/* ---------------------------------------------------------------------------
   2. Cuerpo de la cinta, paneles y grupos
   ------------------------------------------------------------------------- */

.rb-body {
  height: var(--xl-ribbon-body-h);
  background: #fff;
  overflow: hidden;
}
.rb-body.is-disabled { pointer-events: none; opacity: 0.45; }

.rb-panel {
  display: flex;
  align-items: stretch;
  height: 100%;
  padding: 3px 8px 0;
  overflow: hidden;
}

.ribbon-group {
  display: flex;
  flex-direction: column;
  padding: 0 6px;
  border-right: 1px solid #E1DFDD; /* separador entre grupos */
}
.ribbon-group:last-child { border-right: none; }

.rg-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Etiqueta inferior del grupo (+ lanzador de diálogo opcional). */
.rg-label {
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--xl-text-secondary);
  white-space: nowrap;
}
.rg-launcher {
  border: none;
  background: none;
  font-size: 9px;
  line-height: 1;
  color: var(--xl-text-secondary);
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 2px;
}
.rg-launcher:hover { background: var(--xl-hover-solid); color: var(--xl-text); }

/* Maquetación interna de los grupos. */
.rg-row { display: flex; align-items: center; gap: 2px; }
.rg-col { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.rg-vsep { width: 1px; height: 18px; background: #E1DFDD; margin: 0 3px; }

/* ---------------------------------------------------------------------------
   3. Botones de la cinta
   ------------------------------------------------------------------------- */

.rb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  border-radius: 4px;
  color: var(--xl-text-2);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.rb-btn:hover { background: var(--xl-hover-solid); }
.rb-btn:active { background: var(--xl-pressed); }
.rb-btn:disabled { color: var(--xl-text-disabled); cursor: default; }
.rb-btn:disabled:hover { background: none; }
.rb-btn svg { flex: none; }

/* Estado de conmutador activo (N/K/S, alineaciones, ajustar texto…). */
.rb-btn.is-active {
  background: #D6EBDF;
  box-shadow: inset 0 0 0 1px #9FCEB5;
}
.rb-btn.is-active:hover { background: #C8E4D4; }

/* Botón pequeño 24×24 (icono 16). */
.rb-small { width: 24px; height: 24px; }
.rb-has-arrow { width: 34px; }
.rb-has-arrow svg:last-child { width: 10px; height: 10px; margin-left: -2px; }

/* Botón dividido pequeño: zona principal + flecha. */
.rb-split { display: inline-flex; }
.rb-split-main { width: 24px; height: 24px; border-radius: 4px 0 0 4px; }
.rb-split-arrow { width: 13px; height: 24px; border-radius: 0 4px 4px 0; }
.rb-split-arrow svg { width: 9px; height: 9px; }
.rb-split-arrow.is-open, .is-open { background: var(--xl-pressed); }

/* Botón grande (icono arriba, etiqueta de hasta 2 líneas abajo). */
.rb-big {
  flex-direction: column;
  justify-content: flex-start;
  width: 62px;
  min-height: 66px;
  padding: 6px 2px 3px;
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  gap: 3px;
}
.rb-big > svg { width: 26px; height: 26px; }
.rb-big-label {
  display: inline-block;
  white-space: normal;
  color: var(--xl-text-2);
}
.rb-big-label svg { width: 9px; height: 9px; vertical-align: -1px; }

/* Botón grande dividido (Pegar): zona superior + inferior con etiqueta. */
.rb-bigsplit {
  display: flex;
  flex-direction: column;
  width: 52px;
  height: 66px;
}
.rb-big-top { flex: 1; border-radius: 4px 4px 0 0; }
.rb-big-top svg { width: 26px; height: 26px; }
.rb-big-bottom {
  height: 28px;
  border-radius: 0 0 4px 4px;
  flex-direction: column;
  gap: 0;
  font-size: 11px;
}
.rb-big-bottom svg { width: 9px; height: 9px; }

/* Botón mediano (icono + texto + flecha), filas de 22px. */
.rb-med {
  height: 22px;
  padding: 0 6px;
  font-size: 11.5px;
  justify-content: flex-start;
  white-space: nowrap;
}
.rb-med svg:last-child:not(:first-child) { width: 9px; height: 9px; }

/* Checkbox de la cinta (Vista → Mostrar). */
.rb-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--xl-text-2);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.rb-check:hover { background: var(--xl-hover-solid); }
.rb-check input { accent-color: var(--xl-accent); margin: 0; }

/* ---------------------------------------------------------------------------
   4. Cuadros combinados (fuente, tamaño, formato de número)
   ------------------------------------------------------------------------- */

.rb-combo {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border: 1px solid #C8C6C4;
  border-radius: 2px;
  background: #fff;
  overflow: hidden;
}
.rb-combo:hover { border-color: #A19F9D; }
.rb-combo:focus-within { border-color: var(--xl-accent); }
.rb-combo input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font: inherit;
  font-size: 11.5px;
  padding: 0 5px;
  color: var(--xl-text);
  background: none;
}
.rb-combo-value {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  padding: 0 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rb-combo-arrow {
  width: 15px;
  height: 100%;
  border: none;
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--xl-text-secondary);
  flex: none;
}
.rb-combo-arrow:hover { background: var(--xl-hover-solid); }
.rb-combo-arrow svg { width: 9px; height: 9px; }

/* ---------------------------------------------------------------------------
   5. Desplegables propios de la cinta (listas, paletas, galerías)
   ------------------------------------------------------------------------- */

.xl-dropdown {
  position: fixed;
  z-index: 3000;
  background: #fff;
  border: 1px solid #C8C6C4;
  border-radius: 4px;
  box-shadow: 0 6.4px 14.4px rgba(0, 0, 0, 0.13), 0 1.2px 3.6px rgba(0, 0, 0, 0.11);
  padding: 4px;
  max-height: 70vh;
  overflow: auto;
  font-family: var(--xl-font-ui);
  font-size: 12px;
}

/* Lista simple (fuentes, tamaños). */
.xl-list { display: flex; flex-direction: column; min-width: 150px; }
.xl-list-narrow { min-width: 56px; }
.xl-list-item {
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 2px;
  color: var(--xl-text-2);
  white-space: nowrap;
}
.xl-list-item:hover { background: var(--xl-hover-solid); }

/* Lista de formatos de número: nombre + ejemplo. */
.xl-list-numfmt { min-width: 210px; }
.xl-numfmt-item { display: flex; flex-direction: column; gap: 1px; }
.nf-name { font-weight: 600; }
.nf-sample { font-size: 11px; color: var(--xl-text-secondary); }
.nf-more { border-top: 1px solid #E1DFDD; margin-top: 4px; color: var(--xl-accent); }

/* Paleta de colores (tema 10×6 + estándar). */
.xl-palette { width: 216px; padding: 4px; }
.xl-pal-title {
  font-size: 11px;
  color: var(--xl-text-secondary);
  margin: 6px 2px 3px;
}
.xl-pal-grid {
  display: grid;
  grid-template-columns: repeat(10, 18px);
  gap: 2px;
}
.xl-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 2px;
  padding: 0;
  cursor: pointer;
  display: inline-block;
}
.xl-swatch:hover {
  outline: 2px solid var(--xl-accent);
  outline-offset: 0;
}
.xl-pal-special {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  font: inherit;
  font-size: 12px;
  padding: 5px 6px;
  cursor: pointer;
  border-radius: 2px;
  color: var(--xl-text-2);
}
.xl-pal-special:hover { background: var(--xl-hover-solid); }

/* Miniaturas de formato condicional (barras de datos / escalas). */
.xl-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  gap: 4px;
  padding: 4px;
}
.xl-thumb {
  width: 34px;
  height: 30px;
  border: 1px solid #C8C6C4;
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: flex-start;
  padding: 3px;
}
.xl-thumb:hover { outline: 2px solid var(--xl-accent); }
.xl-thumb .db-bar { display: block; height: 5px; border-radius: 1px; }
.xl-thumb-scale { padding: 0; }

/* Galerías (formato como tabla, estilos de celda). */
.xl-gallery { padding: 4px 6px; max-width: 340px; }
.xl-gallery-row { display: flex; flex-wrap: wrap; gap: 6px; }
.xl-table-thumb {
  width: 46px;
  height: 38px;
  border: 1px solid #C8C6C4;
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  padding: 2px;
  gap: 1px;
}
.xl-table-thumb:hover { outline: 2px solid var(--xl-accent); }
.xl-table-thumb .tt-row { display: block; flex: 1; border-radius: 1px; }
.xl-cs-grid { display: grid; grid-template-columns: repeat(4, 74px); gap: 4px; }
.xl-cs-chip {
  height: 24px;
  border: 1px solid #D9D9D9;
  border-radius: 2px;
  font-family: var(--xl-font-ui);
  font-size: 11px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}
.xl-cs-chip:hover { outline: 2px solid var(--xl-accent); }

/* ---------------------------------------------------------------------------
   6. QAT (barra de acceso rápido, dentro de #titlebar)
   ------------------------------------------------------------------------- */

.qat-btn { width: 26px; height: 26px; border-radius: 4px; color: var(--xl-text-2); }
.qat-btn:hover { background: var(--xl-hover-solid); }

/* ---------------------------------------------------------------------------
   7. Menú contextual (ui/contextmenu.js)
   ------------------------------------------------------------------------- */

.xl-cm {
  position: fixed;
  z-index: 4000;
  min-width: 180px;
  max-width: 320px;
  background: #fff;
  border: 1px solid #C8C6C4;
  border-radius: 4px;
  box-shadow: 0 6.4px 14.4px rgba(0, 0, 0, 0.13), 0 1.2px 3.6px rgba(0, 0, 0, 0.11);
  padding: 4px 0;
  font-family: var(--xl-font-ui);
  font-size: 12px;
  user-select: none;
}
.xl-cm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 8px;
  color: var(--xl-text-2);
  cursor: default;
  white-space: nowrap;
}
.xl-cm-item:hover:not(.is-disabled) { background: var(--xl-hover-solid); }
.xl-cm-item.is-disabled { color: var(--xl-text-disabled); }
.xl-cm-ico { width: 16px; height: 16px; flex: none; display: inline-flex; }
.xl-cm-label { flex: 1; }
.xl-cm-sc { margin-left: 24px; font-size: 11px; color: var(--xl-text-secondary); }
.xl-cm-sub { width: 10px; display: inline-flex; }
.xl-cm-sub svg { width: 10px; height: 10px; }
.xl-cm-sep { height: 1px; background: #E1DFDD; margin: 4px 8px; }
.xl-cm-custom { padding: 4px 8px; }

/* ---------------------------------------------------------------------------
   8. Diálogo modal base (ui/dialogs/dialog.js)
   ------------------------------------------------------------------------- */

.xl-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
}
.xl-dialog {
  position: fixed;
  background: #fff;
  border: 1px solid #B5B3B1;
  border-radius: 6px;
  box-shadow: 0 25.6px 57.6px rgba(0, 0, 0, 0.22), 0 4.8px 14.4px rgba(0, 0, 0, 0.18);
  font-family: var(--xl-font-ui);
  font-size: 12px;
  color: var(--xl-text);
  display: flex;
  flex-direction: column;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  outline: none;
}
.xl-dialog-title {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 14px;
  cursor: move;
  border-bottom: 1px solid #EDEBE9;
  border-radius: 6px 6px 0 0;
  background: #fff;
}
.xl-dialog-title-text { font-size: 13px; font-weight: 600; }
.xl-dialog-close {
  width: 32px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  color: var(--xl-text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.xl-dialog-close:hover { background: #E81123; color: #fff; }
.xl-dialog-body { padding: 14px; overflow: auto; }
.xl-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px 14px;
}
.xl-btn {
  min-width: 78px;
  height: 26px;
  border: 1px solid #8A8886;
  border-radius: 2px;
  background: #fff;
  font: inherit;
  cursor: pointer;
  color: var(--xl-text);
  padding: 0 12px;
}
.xl-btn:hover { background: #F3F2F1; }
.xl-btn.primary {
  background: var(--xl-accent);
  border-color: var(--xl-accent);
  color: #fff;
}
.xl-btn.primary:hover { background: #185C38; }

/* ---------------------------------------------------------------------------
   9. Backstage (pestaña Archivo)
   ------------------------------------------------------------------------- */

.xl-backstage {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: flex;
  font-family: var(--xl-font-ui);
}
.xl-bs-side {
  width: 230px;
  background: var(--xl-green);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
  flex: none;
}
.xl-bs-back {
  height: 44px;
  border: none;
  background: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 22px;
}
.xl-bs-back svg { width: 18px; height: 18px; }
.xl-bs-back:hover { background: rgba(255, 255, 255, 0.12); }
.xl-bs-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  background: none;
  color: #fff;
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 10px 24px;
  cursor: pointer;
}
.xl-bs-item:hover { background: rgba(255, 255, 255, 0.12); }
.xl-bs-item svg { flex: none; }
.xl-bs-sep { height: 1px; background: rgba(255, 255, 255, 0.25); margin: 8px 16px; }
.xl-bs-main { flex: 1; background: #fff; padding: 48px 56px; overflow: auto; }
.xl-bs-main h1 {
  margin: 0 0 12px;
  font-size: 26px;
  font-weight: 600;
  color: var(--xl-text);
}
.xl-bs-hint { color: var(--xl-text-secondary); font-size: 13px; }

/* ---------------------------------------------------------------------------
   10. BARRAS — Barra de hojas (ui/sheetbar.js)
   Se incluye aquí (y no en un css aparte) para no tocar index.html.
   ------------------------------------------------------------------------- */

.sb { display: flex; align-items: stretch; }

.sb-nav { display: flex; align-items: center; padding: 0 2px; flex: none; }
.sb-navbtn {
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  font-size: 8px;
  color: var(--xl-text-secondary);
  cursor: pointer;
  border-radius: 3px;
}
.sb-navbtn:hover:not(:disabled) { background: var(--xl-hover-solid); color: var(--xl-text); }
.sb-navbtn:disabled { color: var(--xl-text-disabled); cursor: default; }

.sb-tabs {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  position: relative;
  scroll-behavior: smooth;
}

.sb-tab {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 12px;
  color: var(--xl-text-2);
  background: var(--xl-sheettab-bg);
  border-right: 1px solid var(--xl-separator);
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
}
.sb-tab:hover { background: var(--xl-hover-solid); }
/* Pestaña activa: blanca con subrayado verde de 2px. */
.sb-tab.is-active {
  background: var(--xl-sheettab-active-bg);
  color: var(--xl-accent);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--xl-accent);
}
.sb-tab.is-dragging { opacity: 0.55; }
.sb-label { overflow: hidden; text-overflow: ellipsis; }

/* Franja inferior con el color de etiqueta. */
.sb-color {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
}
.sb-tab.is-active .sb-color { height: 2px; }

.sb-rename-input {
  width: 90px;
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--xl-accent);
  border-radius: 2px;
  outline: none;
  padding: 1px 4px;
}

.sb-drop-marker {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: var(--xl-accent);
  pointer-events: none;
  z-index: 2;
}

.sb-add {
  width: 26px;
  border: none;
  background: none;
  font-size: 15px;
  color: var(--xl-text-secondary);
  cursor: pointer;
  flex: none;
}
.sb-add:hover { background: var(--xl-hover-solid); color: var(--xl-text); }

/* Paleta del menú «Color de etiqueta» (submenú del menú contextual). */
.sb-tabcolor-palette {
  display: grid;
  grid-template-columns: repeat(5, 18px);
  gap: 3px;
  padding: 2px;
}
.sb-tabcolor-none {
  display: block;
  width: 100%;
  border: none;
  background: none;
  font: inherit;
  font-size: 12px;
  text-align: left;
  padding: 5px 4px 2px;
  cursor: pointer;
  color: var(--xl-text-2);
}
.sb-tabcolor-none:hover { background: var(--xl-hover-solid); }

/* ---------------------------------------------------------------------------
   11. BARRAS — Barra de estado (ui/statusbar.js)
   ------------------------------------------------------------------------- */

.st { justify-content: flex-start; }

.st-mode { min-width: 72px; color: var(--xl-text-2); }
.st-spacer { flex: 1; }

.st-aggs { display: flex; gap: 18px; color: var(--xl-text-2); }

.st-zoom { display: flex; align-items: center; gap: 6px; flex: none; }
.st-zoom-btn {
  width: 18px;
  height: 18px;
  border: none;
  background: none;
  font-size: 13px;
  line-height: 1;
  color: var(--xl-text-2);
  cursor: pointer;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.st-zoom-btn:hover { background: var(--xl-hover-solid); }

.st-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 2px;
  background: #8A8886;
  border-radius: 1px;
  outline: none;
  cursor: pointer;
}
.st-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: #605E5C;
  border: 1px solid #FFFFFF;
}
.st-slider::-webkit-slider-thumb:hover { background: var(--xl-accent); }
.st-slider::-moz-range-thumb {
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: #605E5C;
  border: 1px solid #FFFFFF;
}
.st-zoom-pct {
  min-width: 46px;
  border: none;
  background: none;
  font: inherit;
  font-size: 12px;
  text-align: right;
  color: var(--xl-text-2);
  cursor: pointer;
  border-radius: 3px;
  padding: 2px 4px;
}
.st-zoom-pct:hover { background: var(--xl-hover-solid); }

/* ---------------------------------------------------------------------------
   12. Cuadro de nombres: aviso de referencia inválida (ui/namebox.js)
   ------------------------------------------------------------------------- */

#namebox.is-invalid { animation: nb-invalid 0.6s; }
@keyframes nb-invalid {
  0%, 100% { background: transparent; }
  25%, 75% { background: #FDE7E9; }
}
