/* ══════════════════════════════════════════════════════════
   components.css — Botones, nav, formularios, tablas, modales,
   toasts, badges, login. Capa 3 de 5.
   ══════════════════════════════════════════════════════════ */

/* ---------- Hamburguesa (móvil) ---------- */
.topbar-mobile-toggle {
  display: none;
  background: none; border: none;
  padding: 6px; border-radius: var(--radius-sm);
}
.topbar-mobile-toggle:hover { background: var(--gray-100); }
.hamburger { display: block; width: 20px; height: 14px; position: relative; }
.hamburger span {
  position: absolute; left: 0; height: 2px; width: 100%;
  background: var(--text); border-radius: 2px;
}
.hamburger span:nth-child(1) { top: 0; }
.hamburger span:nth-child(2) { top: 6px; }
.hamburger span:nth-child(3) { top: 12px; }

/* ---------- Toggle de tema ---------- */
.theme-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
  transition: var(--transition);
}
.theme-toggle-btn:hover { background: var(--gray-100); color: var(--text); }

/* ---------- Toggle de organización ---------- */
.org-toggle {
  display: inline-flex; padding: 3px;
  background: var(--gray-100); border-radius: var(--radius-sm);
}
.org-btn {
  border: none; background: none;
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  color: var(--text-muted); border-radius: 5px;
  transition: var(--transition);
}
.org-btn:hover { color: var(--text); }
.org-btn.active {
  background: var(--surface); color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}

/* ---------- Menú de usuario ---------- */
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-contrast);
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.user-info { text-align: left; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 180px; z-index: 300;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; background: none;
  font-size: 13px; font-weight: 500; color: var(--text);
  border-radius: var(--radius-sm); text-align: left;
}
.dropdown-item:hover { background: var(--gray-100); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-weak); }

/* ---------- Breadcrumb ---------- */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .crumb-sep { color: var(--gray-300); }
.breadcrumb .crumb-current { color: var(--text); font-weight: 600; }

/* ---------- Navegación del sidebar ---------- */
.nav-section-label {
  padding: 14px 12px 6px; font-size: 10px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--gray-400);
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 2px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  border-radius: var(--radius-sm); transition: var(--transition);
}
.nav-link:hover { background: var(--gray-100); color: var(--text); }
.nav-link.active { background: var(--accent-weak); color: var(--accent-strong); font-weight: 600; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link .nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 10px;
  background: var(--gray-200); color: var(--text-muted);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  transition: var(--transition); white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-100); }
.btn-ghost { background: none; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.stat-card { padding: 18px 20px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ---------- Toolbar de página ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Tablas ---------- */
.data-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-100); }
.data-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; font-size: 11px; font-weight: 600; border-radius: 20px;
}
.badge-success { background: var(--success-weak); color: var(--success); }
.badge-muted   { background: var(--gray-200); color: var(--text-muted); }
.badge-warning { background: var(--warning-weak); color: var(--warning); }
.badge-accent  { background: var(--accent-weak); color: var(--accent-strong); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; gap: 16px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.col-span-2 { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 11px; color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; font-size: 13px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: var(--transition);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.textarea { resize: vertical; min-height: 88px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }

/* ---------- Toasts ---------- */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 500; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 360px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 13px;
  animation: toast-in 200ms ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; color: var(--text-muted); padding: 48px 20px; }
.empty-state-icon { display: inline-flex; color: var(--gray-300); margin-bottom: 12px; }
.empty-state-icon svg { width: 48px; height: 48px; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 4px; }
.empty-state-text { font-size: 13px; margin: 0; }

/* ---------- Spinner ---------- */
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px; color: var(--text-muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- LOGIN ---------- */
#login-view {
  position: fixed; inset: 0; z-index: 600;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .login-logo { height: 40px; margin: 0 auto 12px; }
.login-brand h1 { font-size: 18px; }
.login-brand p { font-size: 13px; color: var(--text-muted); margin: 4px 0 0; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; }
.login-error {
  display: none; margin-bottom: 16px; padding: 10px 12px;
  background: var(--danger-weak); color: var(--danger);
  border-radius: var(--radius-sm); font-size: 12px;
}
.login-error.show { display: block; }
.login-notice {
  margin-top: 16px; padding: 10px 12px; font-size: 11px;
  background: var(--warning-weak); color: var(--warning); border-radius: var(--radius-sm);
}
