/* Base: tipografía, enlaces, botones y formularios */

/* ================================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.rot180 { transform: rotate(180deg); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.pad { padding: 16px; }
.spacer { flex: 1; }
.link { color: var(--accent); font-weight: 550; font-size: 13px; }
.link:hover { text-decoration: underline; }

/* ================================================================ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-weight: 560; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-danger-ghost { background: transparent; color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-danger-ghost:hover { background: var(--danger-soft); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .icon { width: 15px; height: 15px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger-text); }

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

/* ================================================================ formularios */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input:not([type=checkbox]):not([type=color]):not([type=radio]), textarea, select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.input-group { position: relative; display: flex; }
.input-group input { padding-right: 44px !important; }
.input-group .icon-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 34px !important; }
.form-error {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger-text); font-size: 13px; font-weight: 500;
}

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 34px; height: 20px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface); color: var(--muted); font: 600 11px/1.4 var(--mono); text-align: center;
}
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
