/*
 * CUBRA Design System — components.css
 * Buttons, cards, badges, nav, tabs, modal, search, hero, stat, timeline
 * Requiere: tokens.css + base.css
 */

/* ════════════════════════════════
   BUTTONS
   ════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-head);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 3px;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--brand-primary);
  color: var(--text-inverted);
  border-color: var(--brand-primary);
}
.btn-primary:hover {
  background: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
  color: var(--text-inverted);
}

/* Secondary */
.btn-secondary {
  background: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-secondary:hover {
  background: var(--brand-primary-10);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--brand-primary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--brand-primary-10);
}

/* Accent (CTA) */
.btn-accent {
  background: var(--brand-accent);
  color: var(--text);
  border-color: var(--brand-accent);
}
.btn-accent:hover {
  background: var(--brand-accent-dark);
  border-color: var(--brand-accent-dark);
  color: var(--text);
}

/* Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}
.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

/* Icon-only */
.btn-icon {
  padding: var(--space-2);
  width: 2.25rem;
  height: 2.25rem;
}


/* ════════════════════════════════
   BADGES
   ════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2em 0.65em;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  line-height: 1.4;
  white-space: nowrap;
}

.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-neutral { background: var(--surface-alt);color: var(--text-muted); border: 1px solid var(--border); }


/* ════════════════════════════════
   CARDS
   ════════════════════════════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-clickable {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.card-header h3,
.card-header h4 {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text);
}

.card-body {
  padding: var(--space-5) var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Card variante institucional */
.card-accent {
  border-left: 4px solid var(--brand-primary);
}

.card-accent-warm {
  border-left: 4px solid var(--brand-accent-warm);
}


/* ════════════════════════════════
   INPUTS
   ════════════════════════════════ */

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-10);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input {
  padding-left: var(--space-10);
}

.input-group .input-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--text-muted);
  pointer-events: none;
  width: 1.1rem;
  height: 1.1rem;
}

.label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.field {
  margin-bottom: var(--space-5);
}


/* ════════════════════════════════
   SEARCH INPUT
   ════════════════════════════════ */

.search-box {
  position: relative;
  width: 100%;
}

.search-box .search-input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
  font-size: var(--text-base);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.search-box .search-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-10);
}

.search-box .search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 1.1rem;
  height: 1.1rem;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  transition: background var(--transition-fast);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item[aria-selected="true"] {
  background: var(--brand-primary-10);
}

.search-result-item .result-code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}

.search-result-item .result-name {
  color: var(--text);
  margin-top: var(--space-1);
}


/* ════════════════════════════════
   NAVIGATION / HEADER
   ════════════════════════════════ */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: var(--space-4);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo img {
  height: 36px;
  width: auto;
}

.nav-logo-text {
  font-family: var(--font-head);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  color: var(--brand-primary);
  line-height: 1.1;
}

.nav-logo-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-normal);
}

.nav-menu {
  display: none;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: var(--space-1);
}

@media (min-width: 1024px) {
  .nav-menu {
    display: flex;
    align-items: center;
  }
}

.nav-menu a {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-menu a:hover,
.nav-menu a[aria-current="page"] {
  background: var(--brand-primary-10);
  color: var(--brand-primary);
}

.nav-cta {
  flex-shrink: 0;
}

/* Hamburger (mobile) */
.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.nav-toggle:hover {
  background: var(--surface-alt);
}

@media (min-width: 1024px) {
  .nav-toggle { display: none; }
}

/* Mobile drawer */
.nav-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
}

.nav-drawer.is-open {
  pointer-events: auto;
}

.nav-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: var(--surface-overlay);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.nav-drawer.is-open .nav-drawer-backdrop {
  opacity: 1;
}

.nav-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(320px, 80vw);
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform var(--transition-base);
  padding: var(--space-6);
  overflow-y: auto;
}

.nav-drawer.is-open .nav-drawer-panel {
  transform: translateX(0);
}

.nav-drawer-menu {
  list-style: none;
  padding: 0;
  margin: var(--space-8) 0 0;
}

.nav-drawer-menu li + li {
  border-top: 1px solid var(--border);
}

.nav-drawer-menu a {
  display: block;
  padding: var(--space-4) 0;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.nav-drawer-menu a:hover {
  color: var(--brand-primary);
}


/* ════════════════════════════════
   TABS
   ════════════════════════════════ */

.tabs {
  border-bottom: 2px solid var(--border);
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-family: var(--font-head);
  color: var(--text-muted);
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
}

.tab:hover {
  color: var(--brand-primary);
}

.tab[aria-selected="true"],
.tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.tab-panel {
  padding: var(--space-6) 0;
}

.tab-panel[hidden] {
  display: none;
}


/* ════════════════════════════════
   MODAL
   ════════════════════════════════ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-base);
}

.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: var(--text-lg);
  margin: 0;
}

.modal-close {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}


/* ════════════════════════════════
   HERO
   ════════════════════════════════ */

.hero {
  position: relative;
  background: var(--brand-primary);
  color: var(--text-inverted);
  padding: var(--space-16) 0;
  overflow: hidden;
}

@media (min-width: 768px) {
  .hero { padding: var(--space-20) 0; }
}

.hero-bg {
  position: absolute;
  inset: 0;
  object-fit: cover;
  width: 100%;
  height: 100%;
  opacity: 0.2;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-eyebrow {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-accent);
  margin-bottom: var(--space-3);
}

.hero h1 {
  color: var(--text-inverted);
  margin-bottom: var(--space-5);
  max-width: 680px;
}

.hero-description {
  font-size: var(--text-lg);
  color: rgba(255, 255, 255, 0.85);
  max-width: 560px;
  margin-bottom: var(--space-8);
  line-height: var(--leading-relaxed);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}


/* ════════════════════════════════
   STAT (numero grande + label)
   ════════════════════════════════ */

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat-value {
  font-family: var(--font-head);
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--brand-primary);
  line-height: 1;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}


/* ════════════════════════════════
   TIMELINE
   ════════════════════════════════ */

.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: calc(var(--space-3) - 1px);
  top: var(--space-2);
  bottom: var(--space-2);
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-8);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--space-8) + var(--space-2));
  top: var(--space-1);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--brand-primary);
}

.timeline-year {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--brand-accent);
  margin-bottom: var(--space-2);
}

.timeline-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.timeline-body {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}


/* ════════════════════════════════
   ALERT / NOTICE
   ════════════════════════════════ */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.alert-icon {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 2px;
}

.alert-info    { background: var(--info-bg);    border-color: var(--info);    color: var(--info);    }
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger);  color: var(--danger);  }

.alert p { color: inherit; margin: 0; }


/* ════════════════════════════════
   TABLE (zebra responsive)
   ════════════════════════════════ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.table-zebra tr:nth-child(even) td {
  background: var(--surface-alt);
}

.table-zebra tr:hover td {
  background: var(--brand-primary-10);
}

.table-code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--brand-primary-dark);
}
