/* ============================================================
   Casos de soporte — hoja de estilos única

   Dos temas completos con la paleta del logo:
   azul #0080b1, verde #7b913d y ámbar #d68f00.
   ============================================================ */

:root {
  --bg: #0f1420;
  --bg-2: #151b2b;
  --bg-3: #1c2333;
  --bg-hover: #232d42;
  --border: #2b3649;
  --border-soft: #222b3c;
  --text: #e7ecf6;
  --text-dim: #9dabc1;
  --text-faint: #6d7a8d;

  --accent: #2fa5d6;
  --accent-soft: rgba(47, 165, 214, 0.18);
  --accent-line: rgba(47, 165, 214, 0.45);
  --ok: #93b155;
  --ok-soft: rgba(147, 177, 85, 0.16);
  --warn: #e0a52a;
  --warn-soft: rgba(214, 143, 0, 0.22);
  --danger: #ef5f5f;
  --danger-soft: rgba(239, 95, 95, 0.15);
  --mark: rgba(214, 143, 0, 0.45);

  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --radius: 10px;
  --radius-sm: 7px;
  --mono: 'Cascadia Mono', 'Consolas', 'SF Mono', 'Menlo', monospace;
  --sans: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
}

[data-theme='light'] {
  --bg: #eef2f8;
  --bg-2: #ffffff;
  --bg-3: #e9eef6;
  --bg-hover: #dfe8f5;
  --border: #c9d4e3;
  --border-soft: #e4eaf3;
  --text: #141d2b;
  --text-dim: #4e5c73;
  --text-faint: #7f8da2;

  --accent: #0080b1;
  --accent-soft: rgba(0, 128, 177, 0.12);
  --accent-line: rgba(0, 128, 177, 0.4);
  --ok: #61782f;
  --ok-soft: rgba(123, 145, 61, 0.16);
  --warn: #9a6a00;
  --warn-soft: rgba(214, 143, 0, 0.2);
  --danger: #c62828;
  --danger-soft: rgba(198, 40, 40, 0.1);
  --mark: rgba(214, 143, 0, 0.42);

  --shadow: 0 14px 36px rgba(20, 30, 50, 0.16);
  --shadow-sm: 0 1px 3px rgba(20, 30, 50, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
}

input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

mark {
  background: var(--mark);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* -------------------------------- Acceso -------------------------------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 {
  margin: 14px 0 6px;
  font-size: 20px;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 13px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.login-error {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 12.5px;
}

/* Más específica que .brand-mark de la barra superior, que se define después. */
.login-card .brand-mark-lg {
  width: 46px;
  height: 52px;
  margin: 0 auto;
}

/* -------------------------------- Layout -------------------------------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 22px;
  height: 25px;
  display: block;
  flex: none;
}

.brand h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer,
.search-spacer {
  flex: 1;
}

.stat-chip {
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

.theme-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  flex: none;
}

.theme-switch button {
  padding: 4px 11px;
  border: none;
  background: none;
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11.5px;
  white-space: nowrap;
}

.theme-switch button:hover {
  color: var(--text);
}

.theme-switch button.is-active {
  background: var(--bg-2);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ------------------------------- Búsqueda ------------------------------- */

.searchbar {
  position: sticky;
  top: 48px;
  z-index: 15;
  padding: 14px 20px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 260px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-faint);
  font-size: 17px;
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding: 10px 34px 10px 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14.5px;
}

.search-field input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* El navegador añade su propia cruz en los input[type=search]: sobra, porque
   ya tenemos un botón propio que además relanza la búsqueda. */
.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration {
  appearance: none;
  display: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
}

.search-clear:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.control {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-width: 220px;
}

.control:focus {
  border-color: var(--accent);
  outline: none;
}

/* --------------------------------- Filtros ------------------------------ */

.filters {
  margin-top: 12px;
  padding: 13px 15px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-block {
  margin-bottom: 12px;
}

.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chip-toggles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.chip-toggle {
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.chip-toggle:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

.chip-toggle.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.summary {
  margin-top: 11px;
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 18px;
}

/* ------------------------------ Resultados ------------------------------ */

.results {
  flex: 1;
  padding: 18px 20px 30px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.case {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.06s ease;
}

.case:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-sm);
}

.case:active {
  transform: translateY(1px);
}

.case-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.case-no {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--accent);
}

.case-no.is-empty {
  color: var(--text-faint);
  font-weight: 400;
  font-style: italic;
}

.case-date {
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
}

.case-actions {
  margin-left: auto;
  display: flex;
  gap: 5px;
}

.case-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.case-field {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 12px;
  align-items: baseline;
}

@media (max-width: 720px) {
  .case-field {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

.case-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-faint);
  padding-top: 2px;
}

.case-text {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  /* Tres líneas por campo: suficiente para situarse sin alargar la tarjeta. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.case-text.is-empty {
  color: var(--text-faint);
  font-style: italic;
}

.case-meta {
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.chip-match {
  border-color: var(--accent-line);
  color: var(--accent);
  background: var(--accent-soft);
}

.chip-vector {
  border-color: var(--ok);
  color: var(--ok);
  background: var(--ok-soft);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 17px;
  color: var(--text-dim);
}

.empty-state p {
  margin: 0 auto;
  max-width: 460px;
}

.skeleton {
  height: 112px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.1s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 150% 0;
  }
  to {
    background-position: -150% 0;
  }
}

/* ------------------------------ Paginación ------------------------------ */

.pager {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}

.pager-info {
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------- Botones ------------------------------- */

.btn {
  padding: 8px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s ease, border-color 0.1s ease, transform 0.06s ease;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-faint);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.12);
  background: var(--accent);
}

.btn-primary:disabled {
  background: var(--bg-3);
  border-color: var(--border);
  color: var(--text-faint);
  font-weight: 400;
  opacity: 1;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
  background: var(--danger);
}

.btn-quiet {
  background: none;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-quiet.is-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* -------------------------- Formulario de caso -------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 22px;
}

.form-grid .field.is-wide {
  grid-column: 1 / -1;
}

@media (max-width: 820px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.field {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
  min-width: 0;
}

.field-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.field-name {
  font-size: 12.5px;
  font-weight: 700;
}

.field-type {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.field-count {
  font-size: 10.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.field-tools {
  display: flex;
  gap: 4px;
}

.field-input {
  width: 100%;
  padding: 8px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.field-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-input:disabled {
  background: var(--bg-3);
  color: var(--text-faint);
  cursor: not-allowed;
}

.field-input.is-dirty {
  border-color: var(--warn);
}

/* El alto lo ajusta Form.autoGrow() al contenido real del campo. */
.field-area {
  resize: vertical;
  line-height: 1.6;
  font-family: var(--sans);
  white-space: pre-wrap;
  overflow-y: auto;
}

.field-area.is-mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

/* Ha llegado al alto máximo: hay más texto del que se ve. */
.field-area.is-capped {
  border-left: 3px solid var(--accent-line);
}

.field.is-touched .field-name {
  color: var(--accent);
}

.field.is-touched .field-name::after {
  content: ' ●';
  font-size: 0.6em;
  color: var(--warn);
  vertical-align: 2px;
}

.field.has-error .field-input {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.field-error {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--danger);
  font-weight: 600;
}

.field-hint {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 5px;
}

.form-status {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

/* -------------------------------- Modales ------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.62);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 22px;
}

.modal {
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.modal.is-wide {
  max-width: 760px;
}

.modal.is-form {
  max-width: 940px;
}

.modal.is-full {
  max-width: 1100px;
  height: 92vh;
}

.modal-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
}

.modal-head p {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body.is-flush {
  display: flex;
  flex-direction: column;
  padding: 14px 20px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 20px;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.modal-foot .left {
  margin-right: auto;
}

.modal-warn {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  font-size: 12.5px;
  margin-bottom: 14px;
}

.modal-note {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  max-height: 240px;
  overflow: auto;
  margin-top: 10px;
}

.full-area {
  flex: 1;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  resize: none;
  white-space: pre-wrap;
}

/* -------------------------------- Toasts -------------------------------- */

.toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 200;
  max-width: 420px;
}

.toast {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: toast-in 0.16s ease-out;
}

.toast.is-ok {
  border-left-color: var(--ok);
}

.toast.is-warn {
  border-left-color: var(--warn);
}

.toast.is-error {
  border-left-color: var(--danger);
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 13px;
}

.toast-text {
  font-size: 12px;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  align-self: flex-start;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ------------------------------ Scrollbars ------------------------------ */

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 7px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: padding-box;
}
