/* ─────────────────────────────────────────────
   base.css
   Tokens, reset, tipografía y componentes que se
   repiten en toda la app: botones, campos, tags,
   modal, toast, interruptores.
─────────────────────────────────────────────── */

:root {
  /* superficies */
  --paper:     #EEF4F5; /* fondo principal, toda la página */
  --container: #F7FAFB; /* panel grande (galería) */
  --surface:   #FCFCFC; /* tarjetas, inputs, modal */

  /* tinta */
  --ink-950: #171717; /* texto principal + superficies oscuras */
  --ink-800: #2B2B2B;
  --ink-700: #404040;
  --ink-600: #555555; /* texto secundario */
  --ink-400: #909090; /* texto terciario */

  /* bordes */
  --line:        #DDEBED;
  --line-soft:   #EDF5F6;
  --line-strong: #C9D9DC;

  /* acento: naranja institucional */
  --accent:       #FF5100;
  --accent-hover: #E04600;
  --accent-soft:  #FFE7D9;

  /* ilustración (solo como fondo de portada de tarjeta) */
  --illus-blue: #BFD9F4;
  --illus-sand: #F1DDC0;

  /* estados */
  --seal:      #E0384A;
  --seal-soft: #FCE4E7;
  --ok:        #1FA968;
  --ok-soft:   #DFF3E8;

  /* tipografía */
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', 'SF Mono', monospace;

  /* radios: cada familia de componente tiene el suyo */
  --r-xs:   10px;  /* filas de interfaz chicas */
  --r-sm:   16px;  /* inputs */
  --r-md:   20px;  /* tarjetas, modal */
  --r-lg:   32px;  /* contenedor principal */
  --r-pill: 999px; /* botones, chips, badges, buscador */

  /* sombras */
  --shadow-sm: 0 2px 8px rgba(23, 23, 23, .04);
  --shadow-md: 0 10px 28px rgba(23, 23, 23, .08);
  --shadow-lg: 0 28px 64px rgba(23, 23, 23, .18);

  /* layout */
  --topbar-h: 60px;
}


/* ───── reset ───── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink-950);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--ink-950);
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

button {
  border: 0;
}

a {
  color: inherit;
}

svg {
  display: block;
}


/* ───── scrollbar ───── */

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

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

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

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


/* ───── utilidad: texto tipo folio ───── */

.folio {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-600);
}


/* ───── botones: píldora ───── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;

  padding: 10px 20px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;

  cursor: pointer;

  transition:
    background .15s,
    border-color .15s,
    color .15s,
    opacity .15s;

  white-space: nowrap;
  line-height: 1;
}

.btn i {
  font-size: 15px;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--ink-800);
}

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

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-800);
  border-color: var(--line);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(23, 23, 23, .03);
}

.btn-danger {
  background: transparent;
  color: var(--seal);
  border-color: var(--seal-soft);
}

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

.btn-sm {
  padding: 7px 14px;
  font-size: 12px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;

  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-700);

  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 15px;

  transition:
    border-color .15s,
    background .15s,
    color .15s;
}

.btn-icon:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(23, 23, 23, .03);
}

.btn-icon:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.btn-icon.active {
  background: var(--ink-950);
  color: #fff;
  border-color: var(--ink-950);
}

.btn-block {
  width: 100%;
}


/* ───── campos de formulario ───── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-600);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="date"],
.field input[type="month"],
.field select,
.field textarea {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink-950);

  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);

  padding: 10px 13px;
  outline: none;
  width: 100%;

  transition:
    border-color .12s,
    box-shadow .12s;
}

.field textarea {
  resize: vertical;
  min-height: 70px;
  font-family: var(--font-mono);
  line-height: 1.5;
}

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

.field-hint {
  font-size: 11.5px;
  color: var(--ink-400);
}


/* ───── tags / badges ───── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;

  font-size: 11px;
  font-weight: 500;

  padding: 4px 10px;
  border-radius: var(--r-pill);
}

.tag-cat {
  background: var(--ink-950);
  color: var(--paper);
}

.tag-soft {
  background: var(--accent-soft);
  color: var(--accent-hover);
}


/* ───── switch ───── */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  cursor: pointer;
  user-select: none;
}

.switch input {
  display: none;
}

.switch-track {
  width: 34px;
  height: 20px;

  border-radius: 20px;
  background: var(--line-strong);

  position: relative;
  transition: background .15s;

  flex-shrink: 0;
}

.switch-track::after {
  content: '';

  position: absolute;
  top: 2px;
  left: 2px;

  width: 16px;
  height: 16px;

  border-radius: 50%;
  background: #fff;

  transition: transform .15s;

  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

.switch input:checked + .switch-track {
  background: var(--seal);
}

.switch input:checked + .switch-track::after {
  transform: translateX(14px);
}

.switch-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-700);
}


/* ───── tabs ───── */

.tabs {
  display: flex;
  gap: 2px;

  background: var(--paper);
  padding: 3px;

  border-radius: var(--r-pill);
}

.tab {
  flex: 1;

  text-align: center;

  padding: 7px 10px;
  border-radius: var(--r-pill);

  font-size: 12.5px;
  font-weight: 500;

  color: var(--ink-600);

  cursor: pointer;

  border: none;
  background: transparent;

  font-family: var(--font-body);

  transition:
    background .12s,
    color .12s;
}

.tab.active {
  background: var(--surface);
  color: var(--ink-950);
  box-shadow: var(--shadow-sm);
}


/* ───── modal ───── */

.overlay {
  display: none;

  position: fixed;
  inset: 0;

  background: rgba(23, 23, 23, .5);
  backdrop-filter: blur(3px);

  z-index: 300;

  align-items: center;
  justify-content: center;

  padding: 20px;
}

.overlay.show {
  display: flex;
}

.modal {
  background: var(--surface);

  border-radius: var(--r-md);
  padding: 28px;

  width: 100%;
  max-width: 420px;

  box-shadow: var(--shadow-lg);

  animation: popIn .22s cubic-bezier(.2, .9, .3, 1);
}

.modal input {
  width: 100%;

  padding: 10px 14px;

  border: 1px solid #ddd;
  border-radius: 12px;

  outline: none;

  font-size: 14px;
  box-sizing: border-box;
}

.modal input:focus {
  border-color: #999;
}

.modal h3 {
  font-size: 17px;
  margin-bottom: 8px;
}

.modal p {
  color: var(--ink-600);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(.96) translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}


/* ───── toast ───── */

.toast {
  position: fixed;

  bottom: 24px;
  right: 24px;

  background: var(--ink-950);
  color: var(--paper);

  padding: 12px 20px;
  border-radius: var(--r-pill);

  font-size: 13px;
  font-weight: 500;

  display: flex;
  align-items: center;
  gap: 10px;

  box-shadow: var(--shadow-lg);

  z-index: 999;

  opacity: 0;
  pointer-events: none;

  transform: translateY(10px);

  transition:
    opacity .2s,
    transform .2s;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.toast-icon {
  font-size: 17px;
  color: #5FD79A;
  flex-shrink: 0;
}

.toast-icon.err {
  color: #F0806E;
}


/* ───── vista: galería / editor / fill ───── */

.view {
  display: none;
}

.view.active {
  display: block;
}

#view-editor.active {
  display: flex;
}

#view-fill.active {
  display: flex;
}


/* ───── spinner ───── */

.ph-spin {
  animation: dl-spin .8s linear infinite;
  display: inline-block;
}

@keyframes dl-spin {
  to {
    transform: rotate(360deg);
  }
}


/* ───── responsive táctil ───── */

@media (max-width: 860px) {
  .btn-icon {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .btn {
    min-height: 40px;
  }
}


@media (max-width: 720px) {
  .modal {
    padding: 22px;
    max-height: 88vh;
    overflow-y: auto;
  }
}


@media (max-width: 420px) {
  .modal {
    padding: 18px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }
}