/* ============================================================
   DATACODE Help Desk - base visual compartida (consola y app)
   Tipografía: Archivo (OFL). Colores de la marca DATACODE en azules.
   ============================================================ */

@font-face { font-family: 'Archivo'; src: url('fonts/Archivo-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Archivo'; src: url('fonts/Archivo-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Archivo'; src: url('fonts/Archivo-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Archivo'; src: url('fonts/Archivo-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Archivo Narrow'; src: url('fonts/ArchivoSemiCondensed-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Archivo Narrow'; src: url('fonts/ArchivoSemiCondensed-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  --font: 'Archivo', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --font-narrow: 'Archivo Narrow', 'Archivo', 'Segoe UI', sans-serif;

  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --ink: #0E2747;
  --text: #1F2937;
  --muted: #5B6B82;
  --line: #DCE3ED;
  --line-strong: #C3CEDD;
  --navy: #0E2747;
  --navy-2: #163463;
  --brand: #1F5EDB;
  --brand-hover: #1A50BD;
  --brand-soft: #E8EFFD;
  --on-brand: #FFFFFF;

  /* Estados (luces de equipo de red) */
  --st-nuevo: #1F5EDB;
  --st-proceso: #0891B2;
  --st-pendiente: #D97706;
  --st-atendido: #15803D;
  --st-cancelado: #B91C1C;
  --st-nuevo-bg: #E8EFFD;
  --st-proceso-bg: #E0F5FA;
  --st-pendiente-bg: #FEF3DC;
  --st-atendido-bg: #E3F6EA;
  --st-cancelado-bg: #FDE8E8;

  --btn-ok: #16A34A;
  --btn-ok-hover: #13893F;
  --btn-warn: #F5B700;
  --btn-warn-hover: #DEA500;
  --btn-warn-text: #3A2900;
  --btn-bad: #DC2626;
  --btn-bad-hover: #BE1E1E;

  --focus: 0 0 0 3px rgba(31, 94, 219, 0.35);
  --shadow-pop: 0 18px 50px rgba(14, 39, 71, 0.22), 0 2px 8px rgba(14, 39, 71, 0.10);
  --radius: 10px;
  --radius-sm: 7px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0A1424;
    --surface: #0F1D33;
    --surface-2: #13243F;
    --ink: #E9EFF9;
    --text: #D2DBE9;
    --muted: #8FA1BB;
    --line: #1E3255;
    --line-strong: #2B4470;
    --brand: #4F86F2;
    --brand-hover: #6B9AF5;
    --brand-soft: #172B4F;
    --st-nuevo: #6E9CF5;
    --st-proceso: #2CC4E0;
    --st-pendiente: #F2A93B;
    --st-atendido: #3FCB75;
    --st-cancelado: #F27070;
    --st-nuevo-bg: #172B4F;
    --st-proceso-bg: #0E2E3B;
    --st-pendiente-bg: #3A2A10;
    --st-atendido-bg: #0F3320;
    --st-cancelado-bg: #3D1717;
    --shadow-pop: 0 18px 50px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0A1424;
  --surface: #0F1D33;
  --surface-2: #13243F;
  --ink: #E9EFF9;
  --text: #D2DBE9;
  --muted: #8FA1BB;
  --line: #1E3255;
  --line-strong: #2B4470;
  --brand: #4F86F2;
  --brand-hover: #6B9AF5;
  --brand-soft: #172B4F;
  --st-nuevo: #6E9CF5;
  --st-proceso: #2CC4E0;
  --st-pendiente: #F2A93B;
  --st-atendido: #3FCB75;
  --st-cancelado: #F27070;
  --st-nuevo-bg: #172B4F;
  --st-proceso-bg: #0E2E3B;
  --st-pendiente-bg: #3A2A10;
  --st-atendido-bg: #0F3320;
  --st-cancelado-bg: #3D1717;
  --shadow-pop: 0 18px 50px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.2; }
p { margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------------- Botones ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.btn--quiet { background: transparent; color: var(--brand); padding: 0 8px; }
.btn--quiet:hover:not(:disabled) { background: var(--brand-soft); }
.btn--ok { background: var(--btn-ok); color: #fff; }
.btn--ok:hover:not(:disabled) { background: var(--btn-ok-hover); }
.btn--warn { background: var(--btn-warn); color: var(--btn-warn-text); }
.btn--warn:hover:not(:disabled) { background: var(--btn-warn-hover); }
.btn--bad { background: var(--btn-bad); color: #fff; }
.btn--bad:hover:not(:disabled) { background: var(--btn-bad-hover); }
.btn--sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn--lg { min-height: 46px; padding: 0 20px; font-size: 15px; }
.btn--block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .55); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn--ghost.is-busy::after, .btn--quiet.is-busy::after, .btn--warn.is-busy::after { border-color: var(--line-strong); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Formularios ---------------- */
.field { display: grid; gap: 6px; }
.field__label { font-weight: 600; font-size: 13px; color: var(--ink); }
.field__hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 8px 11px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input[aria-invalid='true'], .textarea[aria-invalid='true'] { border-color: var(--st-cancelado); }
.form-error {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--st-cancelado-bg); color: var(--st-cancelado); font-weight: 500;
}
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.segmented button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 6px;
  font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer;
}
.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(14, 39, 71, .12); }

/* ---------------- Luces de estado ---------------- */
.led {
  --c: var(--muted);
  display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent);
}
.led--nuevo { --c: var(--st-nuevo); }
.led--en_proceso { --c: var(--st-proceso); animation: led-pulse 1.6s ease-in-out infinite; }
.led--pendiente { --c: var(--st-pendiente); }
.led--atendido { --c: var(--st-atendido); }
.led--cancelado { --c: var(--st-cancelado); }
.led--online { --c: #22C55E; }
.led--offline { --c: #F59E0B; }
@keyframes led-pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 6%, transparent); opacity: .75; }
}

.status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.status--nuevo { background: var(--st-nuevo-bg); color: var(--st-nuevo); }
.status--en_proceso { background: var(--st-proceso-bg); color: var(--st-proceso); }
.status--pendiente { background: var(--st-pendiente-bg); color: var(--st-pendiente); }
.status--atendido { background: var(--st-atendido-bg); color: var(--st-atendido); }
.status--cancelado { background: var(--st-cancelado-bg); color: var(--st-cancelado); }

/* ---------------- Número de ticket ---------------- */
.tcode { font-family: var(--font-narrow); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .1px; white-space: nowrap; color: var(--muted); }
.tcode b { font-weight: 700; color: var(--ink); }
.tcode i { font-style: normal; font-weight: 700; }
.tcode i.EPC { color: var(--brand); }
.tcode i.CSC { color: #0E7490; }
:root[data-theme='dark'] .tcode i.CSC { color: #46C6DE; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .tcode i.CSC { color: #46C6DE; } }

.kind { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 5px; white-space: nowrap; }
.kind--EPC { background: var(--brand); color: #fff; }
.kind--CSC { border: 1px solid var(--line-strong); color: var(--muted); }

/* ---------------- Ticket con muescas ----------------
   Dos piezas: .stub-top (muescas abajo) y .stub-bottom (muescas arriba y línea de corte).
   Así las muescas siempre coinciden con la línea punteada, sea cual sea el alto del contenido. */
.stub-top, .stub-bottom { --notch: 11px; background: var(--stub-bg, var(--surface)); }
.stub-top {
  border-radius: 12px 12px 0 0;
  -webkit-mask: radial-gradient(circle var(--notch) at 0 100%, #0000 98%, #000), radial-gradient(circle var(--notch) at 100% 100%, #0000 98%, #000);
  -webkit-mask-composite: source-in;
  mask: radial-gradient(circle var(--notch) at 0 100%, #0000 98%, #000), radial-gradient(circle var(--notch) at 100% 100%, #0000 98%, #000);
  mask-composite: intersect;
}
.stub-bottom {
  position: relative;
  border-radius: 0 0 12px 12px;
  -webkit-mask: radial-gradient(circle var(--notch) at 0 0, #0000 98%, #000), radial-gradient(circle var(--notch) at 100% 0, #0000 98%, #000);
  -webkit-mask-composite: source-in;
  mask: radial-gradient(circle var(--notch) at 0 0, #0000 98%, #000), radial-gradient(circle var(--notch) at 100% 0, #0000 98%, #000);
  mask-composite: intersect;
}
.stub-bottom::before {
  content: ''; position: absolute; top: -1px; left: calc(var(--notch) + 6px); right: calc(var(--notch) + 6px);
  border-top: 2px dashed var(--line-strong);
}

/* ---------------- Avisos (toasts) ---------------- */
.toasts { position: fixed; z-index: 1000; right: 18px; bottom: 18px; display: grid; gap: 10px; width: min(380px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--navy); color: #fff; box-shadow: var(--shadow-pop);
  animation: toast-in .22s ease-out;
}
.toast--error { background: #8F1717; }
.toast--ok .led { --c: #4ADE80; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 700; }
.toast__text { opacity: .85; font-size: 13px; overflow-wrap: anywhere; }
.toast button { background: none; border: 0; color: #fff; opacity: .7; cursor: pointer; padding: 0 2px; font-size: 18px; line-height: 1; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Diálogos ---------------- */
dialog.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 0; border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
dialog.modal--wide { width: min(760px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(8, 18, 34, .55); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 12px; }
.modal__title { font-size: 18px; font-weight: 700; }
.modal__body { padding: 4px 22px 18px; display: grid; gap: 14px; overflow: auto; max-height: calc(100vh - 170px); }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------------- Utilidades ---------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.copy {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.copy:hover { background: var(--brand-soft); color: var(--brand); }
.copy svg { width: 15px; height: 15px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
