/* ============================================================
   DESIGN SYSTEM — COMPONENTES BASE
   Inspirado en Squarespace Forma · 2026
   ============================================================ */

/* ─── RESET BASE ─── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family:  var(--font-sans);
  font-size:    var(--text-md);
  font-weight:  var(--weight-regular);
  line-height:  var(--leading-normal);
  color:        var(--text-primary);
  background:   var(--surface-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--bg-accent); color: var(--text-accent); }

/* ─── FOCUS RING GLOBAL ─── */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-md);
}

/* ─── TIPOGRAFÍA ─── */
.text-display { font-family: var(--font-sans); font-size: var(--text-3xl); font-weight: var(--weight-medium); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.text-heading  { font-family: var(--font-sans); font-size: var(--text-2xl); font-weight: var(--weight-medium); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.text-title    { font-family: var(--font-sans); font-size: var(--text-xl);  font-weight: var(--weight-medium); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.text-label    { font-family: var(--font-sans); font-size: var(--text-lg);  font-weight: var(--weight-medium); }
.text-body     { font-family: var(--font-sans); font-size: var(--text-md);  font-weight: var(--weight-regular); line-height: var(--leading-relaxed); }
.text-caption  { font-family: var(--font-sans); font-size: var(--text-sm);  font-weight: var(--weight-regular); color: var(--text-secondary); }
.text-eyebrow  { font-family: var(--font-sans); font-size: var(--text-xs);  font-weight: var(--weight-medium);  text-transform: uppercase; letter-spacing: var(--tracking-wider); color: var(--text-muted); }
.text-code     { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface-0); padding: 1px 5px; border-radius: var(--radius-sm); border: 0.5px solid var(--border); }

/* ─── BOTONES ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  height: 42px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 0.5px solid transparent;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-default),
    opacity    var(--duration-fast) var(--ease-default),
    transform  var(--duration-fast) var(--ease-default),
    box-shadow var(--duration-fast) var(--ease-default),
    border-color var(--duration-fast) var(--ease-default);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

/* Variantes */
.btn-primary {
  background: var(--fill-primary);
  color: var(--text-on-fill);
  border-color: var(--fill-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--fill-primary-hover); border-color: var(--fill-primary-hover); }

.btn-accent {
  background: var(--fill-accent);
  color: var(--text-on-fill);
  border-color: var(--fill-accent);
}
.btn-accent:hover:not(:disabled) { background: var(--fill-accent-hover); border-color: var(--fill-accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-0); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-0); color: var(--text-primary); }

.btn-danger {
  background: transparent;
  color: var(--text-danger);
  border-color: var(--border-danger);
}
.btn-danger:hover:not(:disabled) { background: var(--bg-danger); }

/* Tamaños */
.btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: var(--text-md); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-icon.btn-lg { width: 44px; }

/* Loading state */
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  color: var(--text-on-fill);
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ─── INPUTS ─── */
.input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition:
    border-color var(--duration-fast) var(--ease-default),
    box-shadow   var(--duration-fast) var(--ease-default);
}
.input::placeholder { color: var(--text-muted); }
.input:hover  { border-color: var(--border-strong); }
.input:focus  { border-color: var(--border-accent); box-shadow: var(--shadow-focus); }
.input.is-error { border-color: var(--border-danger); }
.input.is-error:focus { box-shadow: var(--shadow-focus-danger); }
.input:disabled { background: var(--surface-0); color: var(--text-disabled); cursor: not-allowed; }

.textarea {
  min-height: 80px;
  height: auto;
  padding: var(--space-2) var(--space-3);
  resize: vertical;
  line-height: var(--leading-normal);
}

.input-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}
.input-hint  { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }
.input-error { font-size: var(--text-xs); color: var(--text-danger);  margin-top: var(--space-1); }

/* ─── SELECT ─── */
.select {
  appearance: none;
  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='%23868e96' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  cursor: pointer;
}

/* ─── CARDS ─── */
.card {
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}
.card-sm { padding: var(--space-3) var(--space-4); }
.card-lg { padding: var(--space-6) var(--space-8); }
.card-hover {
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  cursor: pointer;
}
.card-hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

/* Metric card */
.metric-card {
  background: var(--surface-1);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.metric-card .metric-label { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-1); }
.metric-card .metric-value { font-size: 24px; font-weight: var(--weight-medium); color: var(--text-primary); line-height: 1; }
.metric-card .metric-change { font-size: var(--text-xs); margin-top: var(--space-1); }
.metric-card .metric-change.up   { color: var(--text-success); }
.metric-card .metric-change.down { color: var(--text-danger); }

/* ─── BADGES / PILLS ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.badge-neutral { background: var(--surface-0); color: var(--text-secondary); border: 0.5px solid var(--border); }
.badge-accent  { background: var(--bg-accent);  color: var(--text-accent); }
.badge-success { background: var(--bg-success); color: var(--text-success); }
.badge-danger  { background: var(--bg-danger);  color: var(--text-danger); }
.badge-warning { background: var(--bg-warning); color: var(--text-warning); }
.badge-pro     { background: var(--bg-pro);     color: var(--text-pro); }

/* ─── DIVIDER ─── */
.divider          { height: 0.5px; background: var(--border); margin: var(--space-4) 0; }
.divider-vertical { width: 0.5px;  background: var(--border); align-self: stretch; }

/* ─── SKELETON LOADERS ─── */
.skeleton {
  background: var(--surface-0);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.skeleton-text  { height: 12px; }
.skeleton-title { height: 20px; }
.skeleton-block { height: 80px; border-radius: var(--radius-md); }
.skeleton-avatar { border-radius: var(--radius-full); }

/* ─── TOOLTIPS ─── */
.tooltip {
  position: relative;
  display: inline-flex;
}
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-2);
  background: var(--color-neutral-900);
  color: var(--color-neutral-0);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast);
  z-index: var(--z-tooltip);
}
.tooltip:hover::after { opacity: 1; }

/* ─── TABLA ─── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  padding: var(--space-2) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  background: var(--surface-1);
  border-bottom: 0.5px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text-primary); }
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 0.5px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background var(--duration-fast);
}
.table tbody tr:hover { background: var(--surface-1); }
.table tbody tr.selected { background: var(--bg-accent); }

/* ─── TOAST / NOTIFICACIONES ─── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right:  var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  min-width: 280px;
  max-width: 420px;
  pointer-events: all;
  animation: toast-in var(--duration-normal) var(--ease-default);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.success { border-color: var(--border-success); }
.toast.danger  { border-color: var(--border-danger); }
.toast.warning { border-color: #fbbf24; }
.toast.info    { border-color: var(--border-accent); }

/* ─── AVATAR ─── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--bg-accent);
  color: var(--text-accent);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-sm  { width: 24px; height: 24px; font-size: var(--text-2xs); }
.avatar-md  { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg  { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar-xl  { width: 56px; height: 56px; font-size: var(--text-md); }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--surface-1);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--duration-normal) var(--ease-default);
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin: 1px var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast), color var(--duration-fast);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-item:hover  { background: var(--surface-0); color: var(--text-primary); }
.sidebar-item.active { background: var(--bg-accent); color: var(--text-accent); font-weight: var(--weight-medium); }
.sidebar-item .icon  { flex-shrink: 0; font-size: 18px; }

/* ─── HEADER ─── */
.header {
  height: var(--header-height);
  background: var(--surface-2);
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

/* ─── COMMAND PALETTE ─── */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}
.cmd-palette {
  width: 100%;
  max-width: 560px;
  background: var(--surface-popover);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  animation: cmd-in var(--duration-fast) var(--ease-default);
}
@keyframes cmd-in {
  from { opacity: 0; transform: scale(0.97) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.cmd-input {
  width: 100%;
  height: 52px;
  padding: 0 var(--space-4);
  font-size: var(--text-md);
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--border);
  color: var(--text-primary);
  outline: none;
}
.cmd-results { max-height: 360px; overflow-y: auto; padding: var(--space-2) 0; }
.cmd-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
}
.cmd-item:hover, .cmd-item.active { background: var(--surface-0); color: var(--text-primary); }
.cmd-item .cmd-shortcut { margin-left: auto; font-size: var(--text-xs); color: var(--text-muted); background: var(--surface-0); padding: 1px 5px; border-radius: var(--radius-sm); border: 0.5px solid var(--border); }

/* ─── CHECKBOX / RADIO ─── */
.checkbox {
  width: 16px; height: 16px;
  border: 0.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-2);
  cursor: pointer;
  appearance: none;
  display: grid;
  place-items: center;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.checkbox:checked {
  background: var(--fill-accent);
  border-color: var(--fill-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M13.5 3.5L6 11 2.5 7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}
.checkbox:hover { border-color: var(--border-accent); }

/* ─── SWITCH / TOGGLE ─── */
.switch {
  width: 36px; height: 20px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  transition: background var(--duration-fast);
  appearance: none;
}
.switch::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform var(--duration-fast) var(--ease-spring);
  box-shadow: var(--shadow-xs);
}
.switch:checked { background: var(--fill-accent); }
.switch:checked::after { transform: translateX(16px); }

/* ─── DROPDOWN / MENÚ ─── */
.dropdown {
  background: var(--surface-popover);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  padding: var(--space-1) 0;
  min-width: 180px;
  z-index: var(--z-dropdown);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.dropdown-item:hover { background: var(--surface-0); color: var(--text-primary); }
.dropdown-item.danger { color: var(--text-danger); }
.dropdown-item.danger:hover { background: var(--bg-danger); }
.dropdown-separator { height: 0.5px; background: var(--border); margin: var(--space-1) 0; }
.dropdown-label { font-size: var(--text-xs); color: var(--text-muted); padding: var(--space-2) var(--space-3) var(--space-1); text-transform: uppercase; letter-spacing: var(--tracking-wider); }

/* ─── TABS ─── */
.tabs { display: flex; border-bottom: 0.5px solid var(--border); gap: 0; }
.tab-item {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -0.5px;
  transition: color var(--duration-fast), border-color var(--duration-fast);
  white-space: nowrap;
}
.tab-item:hover  { color: var(--text-primary); }
.tab-item.active { color: var(--text-primary); border-bottom-color: var(--fill-primary); font-weight: var(--weight-medium); }

/* ─── PROGRESS BAR ─── */
.progress {
  width: 100%;
  height: 4px;
  background: var(--surface-0);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--fill-accent);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-default);
}
.progress-bar.success { background: var(--fill-success); }
.progress-bar.danger  { background: var(--fill-danger); }

/* ─── EMPTY STATE ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: var(--space-4); opacity: 0.4; }
.empty-state .empty-title { font-size: var(--text-md); font-weight: var(--weight-medium); color: var(--text-secondary); margin-bottom: var(--space-2); }
.empty-state .empty-body  { font-size: var(--text-sm); color: var(--text-muted); max-width: 320px; margin-bottom: var(--space-5); }
