/* Base, accesibilidad WCAG 2.2 AA y componentes reutilizables */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body.cf-body {
  margin: 0;
  font-family: var(--p12-font-sans);
  background: var(--p12-bg);
  color: var(--p12-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.cf-no-scroll {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--p12-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--p12-primary-hover);
}

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

.cf-sr-only {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cf-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 0.65rem 1rem;
  background: var(--p12-primary);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--p12-radius-sm) 0;
}

.cf-skip:focus {
  left: 0;
}

.cf-container {
  width: 100%;
  max-width: var(--p12-container);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header compacto estilo herramienta práctica */
.cf-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--p12-surface);
  border-bottom: 1px solid var(--p12-border);
}

.cf-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 62px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  flex-wrap: wrap;
}

.cf-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--p12-text);
}

.cf-brand__logo {
  display: block;
  height: 36px;
  width: auto;
}

.cf-brand__logo--dark {
  display: none;
}

:root[data-theme='dark'] .cf-brand__logo--light {
  display: none;
}

:root[data-theme='dark'] .cf-brand__logo--dark {
  display: block;
}

.cf-nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.cf-nav__link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--p12-text);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border-radius: var(--p12-radius-sm);
}

.cf-nav__link:hover {
  background: var(--p12-surface-alt);
  color: var(--p12-primary);
}

.cf-nav__link--pro {
  color: var(--p12-pro);
  background: var(--p12-pro-soft);
  font-weight: 600;
}

/* Tarjetas, botones, controles */
.cf-card {
  background: var(--p12-surface);
  border: 1px solid var(--p12-border);
  border-radius: var(--p12-radius);
  box-shadow: var(--p12-shadow);
}

.cf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.52rem 0.95rem;
  font-family: var(--p12-font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--p12-text);
  background: var(--p12-surface);
  border: 1px solid var(--p12-border-strong);
  border-radius: var(--p12-radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cf-btn:hover:not(:disabled) {
  background: var(--p12-surface-alt);
  border-color: var(--p12-primary);
}

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

.cf-btn--primary {
  background: var(--p12-primary);
  border-color: var(--p12-primary);
  color: #ffffff;
}

.cf-btn--primary:hover:not(:disabled) {
  background: var(--p12-primary-hover);
  border-color: var(--p12-primary-hover);
  color: #ffffff;
}

.cf-btn--accent {
  background: var(--p12-accent);
  border-color: var(--p12-accent);
  color: #ffffff;
}

.cf-btn--small {
  padding: 0.38rem 0.72rem;
  font-size: 0.82rem;
}

.cf-select,
.cf-input {
  font-family: var(--p12-font-sans);
  font-size: 0.88rem;
  color: var(--p12-text);
  background: var(--p12-surface);
  border: 1px solid var(--p12-border-strong);
  border-radius: var(--p12-radius-sm);
  padding: 0.45rem 0.7rem;
}

.cf-select--compact {
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
}

.cf-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  font-family: var(--p12-font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--p12-accent-soft);
  color: var(--p12-accent);
}

.cf-badge--pro {
  background: var(--p12-pro-soft);
  color: var(--p12-pro);
}

.cf-badge--neutral {
  background: var(--p12-surface-alt);
  color: var(--p12-text-muted);
}

.cf-muted {
  color: var(--p12-text-muted);
  font-size: 0.9rem;
}

.cf-tag {
  display: inline-block;
  font-family: var(--p12-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--p12-accent);
  background: var(--p12-accent-soft);
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
}

/* Toast accesible */
.cf-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 200;
  max-width: 360px;
  padding: 0.7rem 1rem;
  border-radius: var(--p12-radius-sm);
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.cf-toast--show {
  opacity: 1;
  transform: translateY(0);
}

/* Dialog modal */
.cf-dialog {
  width: min(720px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  overflow: auto;
  padding: 1.35rem;
  border: 1px solid var(--p12-border);
  border-radius: var(--p12-radius-lg);
  background: var(--p12-surface);
  color: var(--p12-text);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
}

.cf-dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
}

.cf-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.cf-dialog__title {
  margin: 0 0 0.65rem;
  font-family: var(--p12-font-display);
  font-size: 1.3rem;
}
