/* ==========================================================================
   Trébede · styles.css (nuevo proyecto)
   Clona la estética del Excel: campos azules editables, calculados en gris,
   KPIs en verde y layout multistep accesible.
   ========================================================================== */

/* ------------------------------
   Design tokens
--------------------------------*/
:root {
  /* Excel-like palette */
  --excel-blue: #cfe8ff;
  /* editable */
  --excel-blue-ink: #01357C;
  --excel-green: #eef5e0;
  /* KPI ok / totals */
  --excel-green-ink: #0b4d1a;
  --excel-grey: #F3F3F3;
  /* calculado / read-only */
  --excel-grey-ink: #3a3f52;

  --bg: #ffffff;
  --ink: #26304d;
  --muted: #f7f9fc;
  --line: #e4e9f2;
  --primary: #021345;
  /* branding header */
  --primary-2: #01357C;
  --warn: #b6422e;

  --ff: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial;
  --fs-xs: .80rem;
  --fs-sm: .92rem;
  --fs-md: 1rem;
  --fs-lg: 1.55rem;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 38px rgba(2, 19, 69, .08);

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 12px;
  --space-4: 14px;
  --space-5: 16px;
  --space-6: 18px;
  --space-7: 20px;
  --space-8: 24px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1224;
    --ink: #ebf0ff;
    --muted: #101834;
    --line: #1f2a4d;
    --shadow: 0 10px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* ------------------------------
   Base
--------------------------------*/
* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: var(--ff);
  background: var(--bg);
  color: var(--ink);
}

a {
  color: inherit
}

::selection {
  background: rgba(134, 168, 255, .35)
}

/* ------------------------------
   Header
--------------------------------*/
header {
  padding: var(--space-8) var(--space-5);
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background-image: linear-gradient(61deg, var(--primary) 30%, var(--primary-2) 30%) !important;
}

/* header .wrap{max-width:1200px; margin:0 auto} */
header h1 {
  margin: 0;
  font-size: var(--fs-lg);
  text-align: end;
}

header p {
  margin: .35rem 0 0;
  opacity: .9
}

/* ------------------------------
   Main / card
--------------------------------*/
main {
  max-width: 1200px;
  margin: 22px auto 80px;
  padding: 0 var(--space-5)
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#btnDescargarResumenPdf, #btnDescargarResumenPptx {
  margin-bottom: 30px;
}

@media (prefers-color-scheme: dark) {
  .card {
    background: #0f1730
  }
}

.content {
  padding: var(--space-7)
}

/* ------------------------------
   Stepper
--------------------------------*/
.steps {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: #fafbff;
  border-bottom: 1px solid var(--line);
}

@media (prefers-color-scheme: dark) {
  .steps {
    background: #0d142b
  }
}

.step {
  padding: var(--space-4) var(--space-2);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--ink);
  border-right: 1px solid var(--line);
  background: transparent;
  position: relative;
  cursor: pointer;
}

.step:last-child {
  border-right: 0
}

.step[aria-current="step"] {
  background: #fff;
  color: var(--primary);
  font-weight: 800
}

.step.done::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 6px;
  height: 3px;
  background: linear-gradient(90deg, #7fb6ff, #cde2ff);
  border-radius: 999px;
}

.step:focus-visible {
  outline: 2px solid #8ab4ff;
  outline-offset: -2px;
  border-radius: 6px
}


button#btnEnviarResumen {
    width: 100%;
    min-height: 52px;
    font-size: 1.1em;
    text-transform: uppercase;
    transition: .3s all ease-in-out;
    -webkit-transition: .3s all ease-in-out;
    -moz-transition: .3s all ease-in-out;
    -ms-transition: .3s all ease-in-out;
    -o-transition: .3s all ease-in-out;
}

button#btnEnviarResumen:hover {
    background-color: #373737;
}
/* ------------------------------
   Grid utils
--------------------------------*/
.grid {
  display: grid;
  gap: var(--space-4)
}

@media (min-width:900px) {
  .grid.cols-2 {
    grid-template-columns: 1fr 1fr
  }

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

  .grid.cols-4 {
    grid-template-columns: repeat(4, 1fr)
  }
}

.row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap
}

/* ------------------------------
   Form controls (excel-like)
--------------------------------*/
label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: var(--fs-md);
  border: 1px solid #cfd7e6;
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: inherit;
  transition: box-shadow .15s ease, border-color .15s ease, background-color .15s ease;
}

@media (prefers-color-scheme: dark) {

  input,
  select,
  textarea {
    background: #0e162e;
    border-color: #1f2a4d
  }
}

/* Estados */
input:focus,
select:focus,
textarea:focus {
  border-color: #8fb2ff;
  box-shadow: 0 0 0 3px rgba(2, 19, 69, .12);
}

/* ===== Convención de Excel ===== */
/* Editable (celdas azules) */
.editable {
  background: var(--excel-blue);
  border-color: #8db4ff;
  color: #0c245e;
}

.editable::placeholder {
  color: #1c3f8d;
  opacity: .7
}

.editable:focus {
  border-color: #3f7bff;
  box-shadow: 0 0 0 3px rgba(63, 123, 255, .18);
}

/* Calculado (gris claro) */
.calc {
  background: var(--excel-grey);
  color: var(--excel-grey-ink);
}

.calc[readonly],
.calc[disabled] {
  cursor: not-allowed
}

/* Descripción/ayuda */
.hint {
  font-size: var(--fs-xs);
  color: #4b5563;
  margin-top: 4px
}

.hint::before {
  content: "ℹ️ ";
  font-size: 12px;
  opacity: .9;
}

/* Si alguna vez quieres ocultarlas globalmente, añade .hints-off al <body> */
.hints-off .hint {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .hint {
    color: #9aa6c1
  }
}

/* Select CCAA destacado (editable) */
select.ccaa {
  background: var(--excel-blue);
  border-color: #8db4ff;
  color: #0c245e
}

/* Error/validación */
.is-invalid {
  border-color: var(--warn) !important;
  box-shadow: 0 0 0 3px rgba(182, 66, 46, .15)
}

.error-text {
  color: var(--warn);
  font-size: var(--fs-xs);
  margin-top: 4px
}

/* ------------------------------
   Badges / boxes
--------------------------------*/
.muted {
  background: var(--muted);
  border-radius: var(--radius-sm);
  padding: var(--space-4)
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #212651;
  font-weight: 800;
  font-size: var(--fs-xs)
}

.pillobligatorio {
  background: #dd0e0eba !important;
  color: #ffffff !important;
}

@media (prefers-color-scheme: dark) {
  .pill {
    background: #14224d;
    color: #cfe0ff
  }
}

/* ------------------------------
   Buttons / actions
--------------------------------*/
button {
  appearance: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 900;
  font-size: .92rem;
  cursor: pointer;
  transition: transform .06s ease, filter .15s ease;
}

.btn {
  background: var(--primary);
  color: #fff
}

.btn.secondary {
  background: #e9edf7;
  color: #223
}

.btn.ghost {
  background: transparent;
  color: #223
}

@media (prefers-color-scheme: dark) {
  .btn.secondary {
    background: #101a38;
    color: #dbe6ff
  }

  .btn.ghost {
    color: #dbe6ff
  }
}

button:hover {
  filter: brightness(1.03)
}

button:active {
  transform: translateY(1px)
}

button:focus-visible {
  outline: 2px solid #8ab4ff;
  outline-offset: 2px
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--line);
  background: #fafbff;
}

@media (prefers-color-scheme: dark) {
  .actions {
    background: #0d142b
  }
}

/* ------------------------------
   KPIs y tablas estilo Excel
--------------------------------*/
.kpi {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  background: var(--excel-green);
  color: var(--excel-green-ink);
}

.kpi h3 {
  margin: 0;
  font-size: var(--fs-sm)
}

.kpi p {
  margin: 6px 0 0;
  font-size: 1.35rem;
  font-weight: 900
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4)
}

.table th,
.table td {
  border-bottom: 1px solid #e5e7ef;
  padding: 8px 6px;
  text-align: right;
  font-size: .9rem;
}

/* Variantes de KPI para avisos */
.kpi.alert {
  background: #fde2e1;
  color: #7a1f13
}

/* rojo suave */
.kpi.warning {
  background: #fff4d6;
  color: #7a5b00
}

/* ámbar */
.kpi.neutral {
  background: var(--excel-grey);
  color: var(--excel-grey-ink)
}


.table th:first-child,
.table td:first-child {
  text-align: left
}

/* ------------------------------
   Disabled / locked fields (más visible)
--------------------------------*/
input[disabled],
select[disabled],
textarea[disabled] {
  background: var(--excel-grey) !important;
  color: var(--excel-grey-ink) !important;
  border-color: #d2d8e6 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  opacity: 1;
  /* que no se vea “apagado”, solo gris tipo Excel */
}

/* Si el campo es "editable" pero está bloqueado por lógica (p.ej. ITP/IVA) */
.editable:disabled {
  background: var(--excel-grey) !important;
  color: var(--excel-grey-ink) !important;
  border-color: #d2d8e6 !important;
}

/* Mantener placeholders legibles en deshabilitados */
input[disabled]::placeholder,
select[disabled]::placeholder,
textarea[disabled]::placeholder {
  color: #76809a !important;
  opacity: .9;
}

/* Pistas bajo campos deshabilitados: tono más suave */
input[disabled]~.hint,
select[disabled]~.hint,
textarea[disabled]~.hint {
  color: #7a8198;
}

/* También bloquea cualquier efecto :focus si el navegador lo aplica */
input[disabled]:focus,
select[disabled]:focus,
textarea[disabled]:focus {
  outline: none !important;
  box-shadow: none !important;
}

/* Campo bloqueado por lógica (ej. ITP o IVA inactivos) */
.locked {
  background: var(--excel-grey) !important;
  color: var(--excel-grey-ink) !important;
  border-color: #d2d8e6 !important;
  cursor: not-allowed !important;
}

.locked:focus {
  outline: none !important;
  box-shadow: none !important;
}

.logoTrebede {
  width: 200px;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logoTrebede img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

@media (prefers-color-scheme: dark) {

  .table th,
  .table td {
    border-bottom-color: #1f2a4d
  }
}

/* ------------------------------
   Debug
--------------------------------*/
details.debug {
  margin: var(--space-6) 0
}

details.debug>summary {
  cursor: pointer;
  font-weight: 800;
  list-style: none
}

details.debug>summary::-webkit-details-marker {
  display: none
}

pre.code {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: var(--space-4);
  overflow: auto;
  font-size: .85rem;
}

/* ------------------------------
   Helpers
--------------------------------*/
.invisible {
  display: none !important
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  margin-inline: 40px;
}

@media only screen and (max-width: 992px) {
  .steps {
    grid-template-columns: repeat(3, 1fr);

  }

  header {
    flex-direction: column;
    gap: var(--space-4);
    align-items: flex-start;
    background-image: linear-gradient(61deg, var(--primary) 53%, var(--primary-2) 30%) !important;
  }

  .logoTrebede {
    width: 100px;
    align-items: center;
    margin-inline: 0;
  }

  header h1 {
    text-align: start;
  }

  .wrap {
    margin-inline: 0px;
  }
}

/* Print */
@media print {

  header,
  .actions,
  .steps,
  #debugPanel {
    display: none !important
  }

  .card {
    border: 1px solid #ccc;
    box-shadow: none
  }
}