/* ============================================
   Herramientas Excel — Suite multifunción
   (z-index bajo el header global para no tapar submenús)
   ============================================ */

body.page-excel-tools .excel-app {
  position: relative;
  z-index: 1;
  isolation: isolate;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* Hero */
.excel-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 22px 24px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(99, 102, 241, 0.08), rgba(16, 185, 129, 0.06));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.excel-hero::before {
  content: "";
  position: absolute;
  inset: -40% 60% 40% -20%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.18), transparent 65%);
  pointer-events: none;
  animation: excelHeroGlow 8s ease-in-out infinite alternate;
}

@keyframes excelHeroGlow {
  from { opacity: 0.5; transform: translate(0, 0); }
  to { opacity: 1; transform: translate(12px, -8px); }
}

@media (prefers-reduced-motion: reduce) {
  .excel-hero::before { animation: none; opacity: 0.35; }
}

.excel-hero-main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: min(100%, 280px);
}

.excel-eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  opacity: 0.95;
}

.excel-hero-main h1 {
  margin: 0 0 10px;
  font-size: clamp(1.55rem, 3vw, 2.05rem);
  line-height: 1.15;
}

.excel-lead {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 62ch;
  line-height: 1.55;
}

.excel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.excel-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.22);
  color: var(--text);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

body.dark .excel-chip {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.28);
}

.excel-chip:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.excel-kbd-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.9;
}

.excel-kbd-hint kbd {
  display: inline-block;
  padding: 2px 7px;
  margin: 0 2px;
  border-radius: 6px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
}

.excel-theme-toggle {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  align-self: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.excel-theme-toggle:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.excel-theme-toggle:active {
  transform: scale(0.98);
}

/* Tabs */
.excel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 22px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  padding: 10px 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease, transform 0.18s ease, box-shadow 0.22s ease;
  scroll-snap-align: start;
  position: relative;
}

.tab-btn::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2, #6366f1));
  opacity: 0;
  transform: scaleX(0.4);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.tab-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

.tab-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2, #2563eb));
  color: white;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.tab-btn.active::after {
  opacity: 0;
}

body.dark .tab-btn:hover {
  background: rgba(96, 165, 250, 0.14);
}

body.dark .tab-btn.active {
  box-shadow: 0 6px 22px rgba(96, 165, 250, 0.25);
}

.excel-main {
  margin-bottom: 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: tabFade 0.28s ease;
}

@keyframes tabFade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tab-panel.active {
    animation: none;
  }
}

.excel-main .card h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.muted-desc {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-rule,
.sort-rule {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.filter-rule select,
.filter-rule input,
.sort-rule select {
  min-width: 140px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-rule select:focus-visible,
.filter-rule input:focus-visible,
.sort-rule select:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-replace-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.search-replace-row input {
  flex: 1;
  min-width: 180px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.excel-main .hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 4px 0 12px;
}

.btn.small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* Resultados */
.excel-results {
  display: none;
}

.excel-results.visible {
  display: block;
}

.excel-results .metrics-grid {
  margin-bottom: 16px;
}

.excel-results .results-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.excel-results .results-toolbar input[type="text"] {
  min-width: 200px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.excel-results .results-toolbar select {
  min-width: 140px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.excel-results .pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.excel-results .pagination select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

@media (max-width: 768px) {
  body.page-excel-tools .excel-app {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-bottom: max(48px, env(safe-area-inset-bottom, 0px));
  }

  .excel-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .tab-btn {
    white-space: nowrap;
    min-height: 44px;
    scroll-snap-align: start;
  }

  .filter-rule,
  .sort-rule {
    flex-direction: column;
    align-items: stretch;
  }

  .search-replace-row {
    flex-direction: column;
  }

  .excel-hero {
    padding: 18px max(16px, env(safe-area-inset-left, 0px)) 18px max(16px, env(safe-area-inset-right, 0px));
  }
}

/* --- Intro lectura rápida --- */
.excel-reading-intro {
  margin-bottom: 22px;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.06), transparent 55%);
  box-shadow: var(--shadow);
}

.excel-subhead {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.excel-steps-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  counter-reset: excelstep;
}

.excel-steps-overview li {
  counter-increment: excelstep;
  position: relative;
  margin: 0;
  padding: 12px 14px 12px 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.excel-steps-overview li::before {
  content: counter(excelstep);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2, #6366f1));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
}

.excel-reading-note {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.06);
  border-left: 3px solid rgba(99, 102, 241, 0.45);
}

body.dark .excel-reading-note {
  background: rgba(99, 102, 241, 0.1);
}

/* --- Acordeón “Pasos y ejemplo” --- */
.excel-howto {
  margin-bottom: 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(59, 130, 246, 0.05);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

body.dark .excel-howto {
  background: rgba(96, 165, 250, 0.07);
}

.excel-howto summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  user-select: none;
  transition: background 0.2s ease;
}

.excel-howto summary::-webkit-details-marker {
  display: none;
}

.excel-howto summary::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: auto;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid var(--muted);
  opacity: 0.75;
  transition: transform 0.22s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.excel-howto[open] summary::after {
  transform: rotate(180deg);
}

.excel-howto summary:hover {
  background: rgba(59, 130, 246, 0.08);
}

body.dark .excel-howto summary:hover {
  background: rgba(96, 165, 250, 0.1);
}

.excel-howto summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.excel-howto-title {
  flex: 1;
  min-width: 200px;
}

.excel-howto-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--text);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.excel-howto-inner {
  padding: 0 18px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.excel-howto-lead {
  margin: 14px 0 12px;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
}

.excel-howto-steps {
  margin: 0 0 16px;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
}

.excel-howto-steps li {
  margin-bottom: 6px;
}

.excel-howto-steps kbd {
  display: inline-block;
  padding: 2px 7px;
  margin: 0 2px;
  border-radius: 6px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
}

.excel-example-block {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px dashed rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.04);
}

body.dark .excel-example-block {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(96, 165, 250, 0.06);
}

.excel-example-label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
}

.excel-example-desc {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
}

.excel-example-desc code {
  font-size: 0.82em;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
}

body.dark .excel-example-desc code {
  background: rgba(255, 255, 255, 0.06);
}

.excel-mini-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.excel-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.excel-mini-table th,
.excel-mini-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.excel-mini-table th {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(59, 130, 246, 0.06);
}

body.dark .excel-mini-table th {
  background: rgba(96, 165, 250, 0.1);
}

.excel-mini-table tr:last-child td {
  border-bottom: none;
}

/* --- Tarjetas de herramienta --- */
.excel-main .excel-tool-card {
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.excel-main .excel-tool-card:hover {
  border-color: rgba(59, 130, 246, 0.28);
  box-shadow: 0 8px 28px rgba(59, 130, 246, 0.08);
}

body.dark .excel-main .excel-tool-card:hover {
  border-color: rgba(96, 165, 250, 0.3);
}

.excel-tool-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.excel-results-card {
  margin-top: 4px;
}

.excel-results .excel-results-card {
  border-radius: 16px;
}
