/* Dee — BASE: reinicio, letra, botones, campos, chips, tarjetas, ventanas (modales), avisos (toasts) y menús.
   Lo comparten la portada (index.html) y la aplicación (app/index.html). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: calc(15px * var(--fs));
  line-height: 1.55;
  color: var(--text);
  background: var(--window-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
/* enlaces dentro de un texto: subrayados (no solo por el color) */
p a, li a, label a, small a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
::selection { background: #89CBC466; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* barras de desplazamiento finas */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

.ico { flex: none; }

/* TEXTO DE MARCA: «Dee» con el degradado (como DICOM en el logotipo de tresD DICOM) */
.marca { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.marca > span:last-child { display: inline-flex; align-items: baseline; gap: 7px; }
.marca .tda { width: 30px; height: 30px; }
.marca-nombre { font-weight: 700; font-size: 21px; letter-spacing: -.02em; line-height: 1; }
.marca-de { font-weight: 300; font-size: 11px; letter-spacing: .12em; color: var(--hint); line-height: 1; margin-top: 3px; }
.grad-txt { background: var(--grad-marca); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* BOTONES (los de tresD DICOM: principal con degradado, secundario «fantasma» y de icono) */
.btn {
  --alto: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--alto); padding: 0 16px; border-radius: 10px;
  border: 1px solid transparent; background: none;
  font-weight: 500; font-size: calc(14px * var(--fs)); line-height: 1; white-space: nowrap;
  transition: background var(--t-rapida), border-color var(--t-rapida), color var(--t-rapida), box-shadow var(--t-rapida), transform var(--t-rapida);
  text-decoration: none !important; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-pri { background: var(--grad); color: var(--grad-text); box-shadow: 0 1px 0 #ffffff26 inset, var(--sombra-1); }
.btn-pri:hover:not([disabled]) { background: var(--grad-h); }
.btn-sec { background: var(--ghost-bg); border-color: var(--ghost-border); color: var(--ghost-text); }
.btn-sec:hover:not([disabled]) { background: var(--ghost-hover); }
.btn-txt { color: var(--ghost-text); padding: 0 10px; }
.btn-txt:hover:not([disabled]) { background: var(--ghost-hover); }
.btn-peligro { background: var(--bad-bg); border-color: var(--bad-bd); color: var(--bad-fg); }
.btn-s { --alto: 32px; padding: 0 12px; font-size: calc(13px * var(--fs)); border-radius: 8px; }
.btn-l { --alto: 48px; padding: 0 22px; font-size: calc(15px * var(--fs)); border-radius: 12px; }
.btn-bloque { width: 100%; }
.btn-ico {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border-radius: 10px; border: 1px solid transparent; background: none; color: var(--hint);
  transition: background var(--t-rapida), color var(--t-rapida);
}
.btn-ico:hover:not([disabled]) { background: var(--ghost-hover); color: var(--text); }
.btn-ico[aria-pressed="true"] { background: var(--seg-bg); color: var(--accent); border-color: var(--seg-border); }
.btn-ico.s { width: 30px; height: 30px; border-radius: 8px; }
.btn-ico[disabled] { opacity: .45; cursor: not-allowed; }

/* CAMPOS */
.campo { display: grid; gap: 6px; }
.campo > span, .etq { font-size: calc(13px * var(--fs)); font-weight: 500; color: var(--text2); }
.campo small, .ayuda-campo { font-size: calc(12px * var(--fs)); color: var(--hint); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  transition: border-color var(--t-rapida), box-shadow var(--t-rapida);
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-suave); }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237B8A88' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: calc(13.5px * var(--fs)); color: var(--text2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--green2); flex: none; }

/* interruptor (Ajustes) */
.interruptor { position: relative; width: 42px; height: 24px; flex: none; }
.interruptor input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.interruptor span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface3); border: 1px solid var(--border); transition: background var(--t-rapida); }
.interruptor span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--sombra-1); transition: transform var(--t-rapida); }
.interruptor input:checked + span { background: var(--green2); border-color: var(--green2); }
.interruptor input:checked + span::after { transform: translateX(18px); }
.interruptor input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* control segmentado (Tema, Fuentes…) */
.segm { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--seg-bg); border: 1px solid var(--seg-border); }
.segm button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: calc(13px * var(--fs)); font-weight: 500; color: var(--hint); display: inline-flex; gap: 6px; align-items: center; }
.segm button[aria-pressed="true"] { background: var(--surface); color: var(--seg-text); box-shadow: var(--sombra-1); }

/* CHIPS y ETIQUETAS */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  font-size: calc(12px * var(--fs)); font-weight: 500; line-height: 1.3; white-space: nowrap;
  background: var(--seg-bg); color: var(--seg-text); border: 1px solid var(--seg-border);
}
.chip.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.chip.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.chip.info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.chip.neutro { background: var(--surface2); color: var(--hint); border-color: var(--border); }
.chip.beta { background: var(--grad); color: var(--grad-text); border: 0; letter-spacing: .04em; text-transform: uppercase; font-size: calc(10px * var(--fs)); font-weight: 600; padding: 3px 8px; }
button.chip { cursor: pointer; }
button.chip:hover { background: var(--seg-hover); }

/* TARJETAS */
.tarjeta { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.aviso { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: calc(13px * var(--fs)); line-height: 1.5; border: 1px solid; }
.aviso .ico { margin-top: 1px; }
.aviso.info { background: var(--info-bg); border-color: var(--info-bd); color: var(--info-fg); }
.aviso.warn { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-fg); }
.aviso.ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg); }

/* VENTANAS (modales) — js/ui/modal.js */
.modal-bg {
  position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 20px;
  background: var(--velo); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: aparece var(--t-media) ease;
}
.modal {
  width: min(100%, var(--modal-w, 560px)); max-height: min(92vh, 900px); display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-l);
  box-shadow: var(--sombra-3); overflow: hidden; animation: sube var(--t-media) cubic-bezier(.2,.8,.2,1);
}
.modal-cab { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border-suave); }
.modal-cab h2 { font-size: calc(18px * var(--fs)); flex: 1; min-width: 0; }
.modal-cab .sub { font-size: calc(13px * var(--fs)); color: var(--hint); font-weight: 400; margin-top: 2px; }
.modal-cuerpo { padding: 18px 20px 20px; overflow: auto; flex: 1; }
.modal-pie { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border-suave); background: var(--side-bg); }
@keyframes aparece { from { opacity: 0; } to { opacity: 1; } }
@keyframes sube { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

/* pestañas dentro de ventanas y del panel */
.pestanas { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.pestanas::-webkit-scrollbar { display: none; }
.pestanas button {
  border: 0; background: none; padding: 10px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  font-size: calc(13.5px * var(--fs)); font-weight: 500; color: var(--hint); white-space: nowrap; display: inline-flex; gap: 7px; align-items: center;
}
.pestanas button:hover { color: var(--text); }
.pestanas button[aria-selected="true"] { color: var(--accent); border-bottom-color: currentColor; }
.pestanas .num { font-size: 11px; background: var(--surface2); color: var(--hint); border-radius: 99px; padding: 0 6px; line-height: 18px; }

/* AVISOS FLOTANTES (toasts) — js/ui/toast.js */
.toasts { position: fixed; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--text); color: var(--window-bg); box-shadow: var(--sombra-2); font-size: calc(13.5px * var(--fs));
  animation: sube var(--t-media) ease;
}
.toast.sale { opacity: 0; transform: translateY(8px); transition: all var(--t-media); }
.toast .ico { margin-top: 1px; flex: none; }

/* MENÚS desplegables — js/ui/menu.js */
.menu {
  position: fixed; z-index: 950; min-width: 220px; max-width: 320px; padding: 6px;
  background: var(--menu-bg); color: var(--menu-text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--sombra-2);
  animation: aparece var(--t-rapida) ease;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px;
  font-size: calc(13.5px * var(--fs)); text-align: left; color: inherit; text-decoration: none !important;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--menu-sel); outline: none; }
.menu-item .ico { color: var(--hint); }
.menu-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--accent); font-weight: 600; }
.menu-sep { height: 1px; background: var(--border-suave); margin: 6px 4px; }
.menu-cab { padding: 8px 10px 6px; font-size: 12px; color: var(--hint); }
.menu-cab b { display: block; color: var(--text); font-size: 14px; font-weight: 600; }

/* botón de idioma (portada y aplicación) */
.btn-idioma { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--hint); font-size: 13px; font-weight: 500; }
.btn-idioma:hover { background: var(--ghost-hover); color: var(--text); }

/* BANDERAS (idiomas; js/ui/flags.js, copiado de tresD DICOM) */
.flag { border-radius: 3px; box-shadow: 0 0 0 1px #0000001f; flex: none; overflow: hidden; }

/* imágenes según el tema (logos de tresD DICOM, tresD Models y tresD) */
.solo-oscuro { display: none !important; }
:root[data-tema="oscuro"] .solo-claro { display: none !important; }
:root[data-tema="oscuro"] .solo-oscuro { display: block !important; }

/* utilidades */
.fila { display: flex; align-items: center; gap: 10px; }
.col { display: grid; gap: 12px; }
.sep { flex: 1; }
.tenue { color: var(--hint); }
.peque { font-size: calc(12.5px * var(--fs)); }
.centro { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
