/*
 * TEMA "COCINA" PARA LOS FORMULARIOS INDEX Y DATA
 *
 * Solo cambia el aspecto: colores, tipografía, bordes y sombras. No mueve
 * botones, solapas ni campos. Se activa con la clase "tema-gc" en <body>
 * (ver header.php) y el modo oscuro con "tema-gc-oscuro".
 *
 * Identidad propia: tinta, azafrán y papel, la misma familia que los
 * informes PDF, con tarjetas limpias y campos con caja.
 */

body.tema-gc {
  --gc-bg: #f5f2ec;          /* fondo de página */
  --gc-surface: #ffffff;     /* tarjetas */
  --gc-surface-2: #faf8f3;   /* campos, cabeceras de tabla */
  --gc-ink: #24231f;         /* texto principal, botón principal */
  --gc-ink-2: #5b584e;       /* etiquetas, texto secundario */
  --gc-ink-3: #8b8778;       /* ayudas */
  --gc-line: #e3ddcf;        /* bordes suaves */
  --gc-line-2: #cfc8b6;      /* bordes de campos */
  --gc-accent: #c68a2e;      /* azafrán: foco, solapa activa, enlaces */
  --gc-accent-soft: #f6ead3;
  --gc-sage: #4a5539;        /* acciones positivas */
  --gc-wine: #7a2e2e;        /* borrar, errores */
  --gc-slate: #3d4b5c;       /* correo, acciones secundarias */
  --gc-row: #faf7f0;         /* fila alterna */
  --gc-hover: #f3ecdc;
  --gc-row-hover: #f1e6cc;  /* fila bajo el ratón */
  --gc-shadow: 0 1px 2px rgba(36,35,31,.06), 0 6px 18px rgba(36,35,31,.06);
  --gc-radius: 10px;
  --gc-font-title: "Fraunces", Georgia, "Times New Roman", serif;
  --gc-font-label: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  /* estados */
  --gc-st-ok: #3f6b3a;     --gc-st-ok-bg: #e4eedc;
  --gc-st-warn: #8a5a0f;   --gc-st-warn-bg: #f6e6c6;
  --gc-st-bad: #8a2f2f;    --gc-st-bad-bg: #f4dcd8;
  --gc-st-info: #2f4f6f;   --gc-st-info-bg: #dfe8f1;
  --gc-st-none: #5b584e;   --gc-st-none-bg: #ece7da;

  background: var(--gc-bg);
  color: var(--gc-ink);
}

body.tema-gc.tema-gc-oscuro {
  --gc-bg: #18181a;
  --gc-surface: #222225;
  --gc-surface-2: #2a2a2e;
  --gc-ink: #ece8de;
  --gc-ink-2: #b6b0a2;
  --gc-ink-3: #8a857a;
  --gc-line: #34343a;
  --gc-line-2: #45454c;
  --gc-accent: #e3a94e;
  --gc-accent-soft: #3a2f1d;
  --gc-sage: #8fae76;
  --gc-wine: #d98a80;
  --gc-slate: #8fa6c0;
  --gc-row: #26262a;
  --gc-hover: #2e2b24;
  --gc-row-hover: #3d3424;
  --gc-shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
  --gc-st-ok: #a9cf96;   --gc-st-ok-bg: #26341f;
  --gc-st-warn: #f0c072; --gc-st-warn-bg: #3b2f17;
  --gc-st-bad: #f0a59b;  --gc-st-bad-bg: #3e2220;
  --gc-st-info: #a6c2e0; --gc-st-info-bg: #1f2c3a;
  --gc-st-none: #c3bdb0; --gc-st-none-bg: #2f2e2b;
}

/* ---------- Variante verde (prueba): ?tema=verde, se quita con ?tema=cocina ---------- */
body.tema-gc.tema-gc-verde {
  --gc-bg: #f1f4ec;
  --gc-surface: #ffffff;
  --gc-surface-2: #f6f8f2;
  --gc-ink: #1c2a12;
  --gc-ink-2: #4f5b45;
  --gc-ink-3: #7d8873;
  --gc-line: #dde5d3;
  --gc-line-2: #c3cfb6;
  --gc-accent: #4e7a28;
  --gc-accent-soft: #e6eedb;
  --gc-sage: #3a5a1c;
  --gc-slate: #3d4b5c;
  --gc-row: #f6f8f1;
  --gc-hover: #eaf1e1;
  --gc-row-hover: #dfe9d2;
}
body.tema-gc.tema-gc-verde.tema-gc-oscuro {
  --gc-bg: #141d0d;
  --gc-surface: #1d2914;
  --gc-surface-2: #253419;
  --gc-ink: #e9efe2;
  --gc-ink-2: #b4c0a8;
  --gc-ink-3: #85917a;
  --gc-line: #2f3f22;
  --gc-line-2: #3d5029;
  --gc-accent: #8cc152;
  --gc-accent-soft: #2a3a1b;
  --gc-sage: #a3c97f;
  --gc-row: #1a2511;
  --gc-hover: #25331a;
  --gc-row-hover: #31451f;
}

/* ---------- Inicio de sesión, recuperar y cambiar contraseña ---------- */
body.tema-gc form.login-form {
  max-width: 420px;
  margin: 10px auto 0;
  background: var(--gc-surface);
  border: 1px solid var(--gc-line);
  border-radius: 14px;
  box-shadow: var(--gc-shadow);
  padding: 26px 30px 18px;
}
body.tema-gc form.login-form .row { margin-bottom: 6px; }
body.tema-gc form.login-form button.btn {
  background: var(--gc-ink) !important;
  color: var(--gc-surface) !important;
  min-width: 180px;
}
body.tema-gc form.login-form button.btn:hover { background: var(--gc-accent) !important; color: #1c1b17 !important; }
body.tema-gc form.login-form a { color: var(--gc-accent); }
body.tema-gc form.login-form label[style] { color: var(--gc-ink-2); }
/* Separador "----- O -----" (es texto): en una sola línea y recortado al ancho de la tarjeta */
body.tema-gc form.login-form label[data-lang="APP_SSO_ESP"] { display: block; white-space: nowrap; overflow: hidden; font-size: 14px !important; color: var(--gc-ink-3); }

/* ---------- Página y títulos ---------- */
body.tema-gc .wrapper { background: var(--gc-bg); }
body.tema-gc .wrapper > .row > .s12 > .row:first-child { margin-bottom: 14px; }
body.tema-gc h5 {
  font-family: var(--gc-font-title);
  font-weight: 600;
  font-size: 1.65rem;
  color: var(--gc-ink);
  letter-spacing: -.01em;
}
body.tema-gc h5 span + span { color: var(--gc-ink); }
/* El título de la página va en una columna estrecha: que no se parta y ocupe el hueco libre de al lado */
body.tema-gc .wrapper .col.s3 > h5 { white-space: nowrap; position: relative; z-index: 1; }
body.tema-gc a { color: var(--gc-accent); }
body.tema-gc .blue-link, body.tema-gc .icon-link { color: var(--gc-ink-2) !important; }
body.tema-gc .icon-link:hover { color: var(--gc-accent) !important; }

/* ---------- Botones (mismo sitio, colores de la casa) ---------- */
body.tema-gc .btn, body.tema-gc .btn-large {
  border-radius: 8px;
  box-shadow: none;
  background-color: var(--gc-ink);
  color: #fff;
  text-transform: none;
  font-weight: 500;
  letter-spacing: .01em;
}
body.tema-gc.tema-gc-oscuro .btn, body.tema-gc.tema-gc-oscuro .btn-large { color: #18181a; }
body.tema-gc .btn:hover, body.tema-gc .btn-large:hover { box-shadow: 0 2px 8px rgba(36,35,31,.18); filter: brightness(1.08); }
body.tema-gc .btn.blue, body.tema-gc .btn.blue.darken-4 { background-color: var(--gc-ink) !important; }
body.tema-gc .btn.blue.darken-4 { background-color: var(--gc-slate) !important; }
body.tema-gc .btn.green, body.tema-gc .btn.green.darken-1 { background-color: var(--gc-sage) !important; }
body.tema-gc .btn.light-blue, body.tema-gc .btn.cyan, body.tema-gc .btn.teal, body.tema-gc .btn.indigo { background-color: var(--gc-slate) !important; }
body.tema-gc .btn.orange, body.tema-gc .btn.amber { background-color: var(--gc-accent) !important; }
body.tema-gc .btn.red { background-color: var(--gc-wine) !important; }
body.tema-gc .btn.light-green { background-color: #8a9f68 !important; }
body.tema-gc .dropdown-button.btn { background-color: var(--gc-accent) !important; }
body.tema-gc .btn-floating { background-color: var(--gc-accent); box-shadow: none; }
body.tema-gc .btn-flat { border-radius: 8px; text-transform: none; }
body.tema-gc .btn-flat.green { background-color: var(--gc-sage) !important; color: #fff !important; }
body.tema-gc .btn-flat.red { background-color: var(--gc-wine) !important; color: #fff !important; }
body.tema-gc .btn.disabled, body.tema-gc .disabled .btn { background-color: var(--gc-line) !important; color: var(--gc-ink-3) !important; }

/* ---------- Solapas ---------- */
body.tema-gc .tabs {
  background: transparent;
  height: auto;
  padding: 4px;
  border-radius: 999px;
  display: inline-flex;
  width: auto;
  max-width: 100%;
  gap: 4px;
  background-color: var(--gc-surface);
  box-shadow: inset 0 0 0 1px var(--gc-line);
}
body.tema-gc .tabs.tabs-fixed-width { display: flex; }
body.tema-gc .tabs .tab { height: auto; line-height: 1; }
body.tema-gc .tabs .tab a {
  color: var(--gc-ink-2) !important;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  background: transparent !important;
}
body.tema-gc .tabs .tab a:hover { color: var(--gc-ink) !important; background: var(--gc-hover) !important; }
body.tema-gc .tabs .tab a.active { background: var(--gc-ink) !important; color: var(--gc-surface) !important; }
body.tema-gc .tabs .indicator { display: none; }
body.tema-gc .tabs .tab.disabled a { opacity: .45; }

/* ---------- Tarjetas: contenido de solapas, buscador y tablas ---------- */
body.tema-gc .tab-content,
body.tema-gc .search-bar.bordered,
body.tema-gc .portlet.bordered,
body.tema-gc .card,
body.tema-gc ul.collapsible {
  background: var(--gc-surface);
  border: 1px solid var(--gc-line);
  border-radius: var(--gc-radius);
  box-shadow: var(--gc-shadow);
}
body.tema-gc .tab-content { margin-top: 14px; padding: 18px 20px 8px; }
body.tema-gc .search-bar.bordered { padding: 14px 16px 2px; margin-bottom: 14px; }
body.tema-gc .portlet.bordered { padding: 6px 12px 12px; }
body.tema-gc ul.collapsible { overflow: hidden; }
body.tema-gc ul.collapsible .collapsible-header { background: var(--gc-surface); border-bottom: 1px solid var(--gc-line); color: var(--gc-ink); }
body.tema-gc ul.collapsible .collapsible-body { background: var(--gc-surface-2); border-bottom: 1px solid var(--gc-line); }

/* ---------- Campos con caja ---------- */
body.tema-gc .input-field label,
body.tema-gc label {
  color: var(--gc-ink-2);
  font-size: 13px;
}
body.tema-gc .input-field > label,
body.tema-gc .input-field label.active {
  font-family: var(--gc-font-label);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gc-ink-2);
}
body.tema-gc input[type=text]:not(.browser-default),
body.tema-gc input[type=number]:not(.browser-default),
body.tema-gc input[type=email]:not(.browser-default),
body.tema-gc input[type=password]:not(.browser-default),
body.tema-gc input[type=search]:not(.browser-default),
body.tema-gc input[type=tel]:not(.browser-default),
body.tema-gc textarea.materialize-textarea,
body.tema-gc .select-wrapper input.select-dropdown {
  background: var(--gc-surface-2);
  border: 1px solid var(--gc-line-2);
  border-radius: 8px;
  box-sizing: border-box;
  padding: 0 10px;
  color: var(--gc-ink);
  box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
}
body.tema-gc textarea.materialize-textarea { padding: 10px; min-height: 2.6rem; }
body.tema-gc .input-field > label:not(.active) { padding-left: 10px; }
body.tema-gc input:not(.browser-default):focus:not([readonly]),
body.tema-gc textarea.materialize-textarea:focus:not([readonly]),
body.tema-gc .select-wrapper input.select-dropdown:focus {
  border: 1px solid var(--gc-accent) !important;
  box-shadow: 0 0 0 3px var(--gc-accent-soft) !important;
}
body.tema-gc input:not(.browser-default):focus:not([readonly]) + label,
body.tema-gc textarea.materialize-textarea:focus:not([readonly]) + label { color: var(--gc-accent) !important; }
body.tema-gc input[readonly], body.tema-gc input:disabled { background: transparent; border-style: dashed; color: var(--gc-ink-2); }
body.tema-gc .select-wrapper span.caret { color: var(--gc-ink-2); right: 10px; }
body.tema-gc .help-input { color: var(--gc-ink-3); }
body.tema-gc .input-field div.cApp-error, body.tema-gc .cApp-error { color: var(--gc-wine); }
body.tema-gc input.invalid:not(.browser-default) { border-color: var(--gc-wine) !important; }
body.tema-gc [type="checkbox"].filled-in:checked + label:after,
body.tema-gc [type="checkbox"].filled-in:checked + span:not(.lever):after { border-color: var(--gc-accent); background-color: var(--gc-accent); }
body.tema-gc [type="checkbox"]:checked + label:before { border-right-color: var(--gc-accent); border-bottom-color: var(--gc-accent); }
body.tema-gc .switch label input[type=checkbox]:checked + .lever { background-color: var(--gc-accent-soft); }
body.tema-gc .switch label input[type=checkbox]:checked + .lever:after { background-color: var(--gc-accent); }

/* Desplegables y calendario */
body.tema-gc .dropdown-content { border-radius: 8px; box-shadow: var(--gc-shadow); background: var(--gc-surface); }
body.tema-gc .dropdown-content li > a, body.tema-gc .dropdown-content li > span { color: var(--gc-ink); }
body.tema-gc .dropdown-content li:hover, body.tema-gc .dropdown-content li.active { background: var(--gc-hover); }
body.tema-gc .picker__date-display, body.tema-gc .picker__weekday-display { background-color: var(--gc-ink); }
body.tema-gc .picker__day--selected, body.tema-gc .picker__day--selected:hover, body.tema-gc .picker--focused .picker__day--selected { background-color: var(--gc-accent); }
body.tema-gc .picker__day.picker__day--today { color: var(--gc-accent); }
body.tema-gc .picker__day.picker__day--selected { color: #fff; }
body.tema-gc .picker__close, body.tema-gc .picker__today { color: var(--gc-accent); }

/* Datos informativos en gris dentro de los formularios (fechas de envío,
   documentos asociados...): se muestran como etiquetas, en el mismo sitio */
body.tema-gc .input-field > span[id$="Lbl"] {
  font-family: var(--gc-font-label);
  font-size: 11px !important;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--gc-ink-3) !important;
}
body.tema-gc .input-field > span[id$="Lbl"] + span {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 10px; /* con muchos valores ocupa varias líneas: esquinas suaves en vez de píldora */
  line-height: 1.6;
  background: var(--gc-surface-2);
  border: 1px solid var(--gc-line);
  color: var(--gc-ink) !important;
  font-size: 13px !important;
}
body.tema-gc .input-field > span[id$="Lbl"] + span:empty { display: none; }

/* ---------- Tablas (Index y líneas de detalle) ---------- */
body.tema-gc table { border-collapse: separate; border-spacing: 0; }
body.tema-gc table thead th,
body.tema-gc table.dataTable thead th {
  background: var(--gc-surface-2);
  color: var(--gc-ink-2);
  font-family: var(--gc-font-label);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--gc-line-2) !important;
  padding: 12px 10px;
}
body.tema-gc table tbody td { border-bottom: 1px solid var(--gc-line); padding: 8px 10px; color: var(--gc-ink); }
body.tema-gc table tbody td:last-child { white-space: nowrap; }
body.tema-gc table.bordered > tbody > tr, body.tema-gc table.bordered > thead > tr { border-bottom: 0; }
/* DataTables pinta las filas en blanco: se fija el fondo de todas las filas */
body.tema-gc table tbody tr,
body.tema-gc table.dataTable tbody tr,
body.tema-gc table.dataTable.stripe tbody tr.odd,
body.tema-gc table.dataTable.display tbody tr.odd { background-color: transparent !important; }
body.tema-gc table tbody td { background: var(--gc-surface) !important; color: var(--gc-ink) !important; }
body.tema-gc table tbody tr:nth-child(even) td { background: var(--gc-row) !important; }
body.tema-gc table tbody tr:hover td { background: var(--gc-row-hover) !important; }
/* marca a la izquierda de la fila bajo el ratón, para que se vea también en modo noche */
body.tema-gc table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--gc-accent); }
body.tema-gc table.picker__table tbody tr:hover td:first-child { box-shadow: none; }
body.tema-gc table.highlight > tbody > tr:hover td, body.tema-gc table tbody tr:hover td { background: var(--gc-hover); }
/* El calendario también es una tabla: se le quita el estilo de las tablas para que conserve su tamaño */
body.tema-gc table.picker__table thead th,
body.tema-gc table.picker__table tbody td,
body.tema-gc table.picker__table tbody tr:nth-child(even) td,
body.tema-gc table.picker__table tbody tr:hover td {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  color: inherit !important;
  white-space: normal;
}
body.tema-gc table.picker__table thead th { font-family: inherit; letter-spacing: 0; text-transform: none; }
body.tema-gc table tfoot td { border-top: 2px solid var(--gc-ink); font-variant-numeric: tabular-nums; }
body.tema-gc td.al-right, body.tema-gc th.al-right { font-variant-numeric: tabular-nums; }
body.tema-gc table.dataTable tbody td a i,
body.tema-gc td .material-icons { color: var(--gc-ink-2); transition: color .15s; }
body.tema-gc table.dataTable tbody td a:hover i { color: var(--gc-accent); }
body.tema-gc td .btn-floating { background: transparent; box-shadow: none; }
body.tema-gc td .btn-floating i { color: var(--gc-ink-2); }
body.tema-gc .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.tema-gc .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--gc-ink) !important; color: var(--gc-surface) !important; border: 0; border-radius: 6px;
}
body.tema-gc .dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--gc-hover) !important; border-color: transparent; color: var(--gc-ink) !important; border-radius: 6px; }
body.tema-gc .dataTables_wrapper .dataTables_info { color: var(--gc-ink-3); }

/* ---------- Estado del documento (chip) ---------- */
body.tema-gc .gc-estado {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--gc-st-none-bg);
  color: var(--gc-st-none);
  vertical-align: middle;
}
body.tema-gc .gc-estado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
body.tema-gc .gc-estado.ok { background: var(--gc-st-ok-bg); color: var(--gc-st-ok); }
body.tema-gc .gc-estado.warn { background: var(--gc-st-warn-bg); color: var(--gc-st-warn); }
body.tema-gc .gc-estado.bad { background: var(--gc-st-bad-bg); color: var(--gc-st-bad); }
body.tema-gc .gc-estado.info { background: var(--gc-st-info-bg); color: var(--gc-st-info); }
body.tema-gc h5 .gc-estado { margin-left: 12px; font-family: Roboto, "Segoe UI", sans-serif; font-size: 13px; font-weight: 500; letter-spacing: 0; position: relative; top: -3px; }

/* ---------- Ventanas modales ---------- */
body.tema-gc .modal { border-radius: 14px; background: var(--gc-surface); color: var(--gc-ink); }
body.tema-gc .modal .modal-footer { background: var(--gc-surface-2); border-top: 1px solid var(--gc-line); }
body.tema-gc .modal h5 { font-size: 1.35rem; }

/* ---------- Avisos ---------- */
body.tema-gc #toast-container .toast { border-radius: 10px; background: var(--gc-ink); color: var(--gc-surface); }

/* ---------- Botones flotantes: zoom (+ / -) y modo oscuro ---------- */
body.tema-gc .gc-flotantes {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 990;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.tema-gc .gc-modo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--gc-line-2);
  background: var(--gc-surface);
  color: var(--gc-ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--gc-shadow);
}
body.tema-gc .gc-modo:hover { color: var(--gc-accent); }
body.tema-gc .gc-modo:focus-visible { outline: 2px solid var(--gc-accent); outline-offset: 2px; }
body.tema-gc .gc-modo:disabled { opacity: .4; cursor: default; }
body.tema-gc .gc-modo:disabled:hover { color: var(--gc-ink-2); }

/* ---------- Modo oscuro: ajustes de piezas de Materialize ---------- */
body.tema-gc.tema-gc-oscuro .grey-text, body.tema-gc.tema-gc-oscuro .text-darken-2 { color: var(--gc-ink-2) !important; }
body.tema-gc.tema-gc-oscuro .collection, body.tema-gc.tema-gc-oscuro .collection .collection-item { background: var(--gc-surface); border-color: var(--gc-line); color: var(--gc-ink); }
body.tema-gc.tema-gc-oscuro .picker__box, body.tema-gc.tema-gc-oscuro .picker__calendar-container { background: var(--gc-surface); color: var(--gc-ink); }
body.tema-gc.tema-gc-oscuro .picker__day { color: var(--gc-ink); }
body.tema-gc.tema-gc-oscuro .picker__date-display,
body.tema-gc.tema-gc-oscuro .picker__weekday-display { background-color: var(--gc-surface-2); color: var(--gc-ink); }
body.tema-gc.tema-gc-oscuro .picker__date-display * { color: var(--gc-ink); }
body.tema-gc.tema-gc-oscuro .picker__date-display .picker__year-display { color: var(--gc-ink-3); }
body.tema-gc.tema-gc-oscuro .picker__select--month,
body.tema-gc.tema-gc-oscuro .picker__select--year { background: var(--gc-surface-2); color: var(--gc-ink); border-color: var(--gc-line); }
body.tema-gc.tema-gc-oscuro .picker__clear { color: var(--gc-ink-2); }
body.tema-gc.tema-gc-oscuro .picker__day.picker__day--selected { color: #1a1a1a; }

@media (prefers-reduced-motion: reduce) {
  body.tema-gc * { transition: none !important; }
}
