/* ============================================================
   TRAVELDESK — Design System
   Variables, reset, tipografía, utilidades
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */

:root {
  /* Colores principales */
  --td-primary: #1B3D7A;
  --td-primary-light: #2452A0;
  --td-primary-dark: #122B57;
  --td-primary-50: #EEF2FF;
  --td-primary-100: #D4DFFE;

  --td-accent: #F0A500;
  --td-accent-light: #F8C03A;
  --td-accent-dark: #C98800;
  --td-accent-50: #FFFBEB;
  --td-accent-100: #FEF3C7;

  /* Escala de grises */
  --td-gray-50: #F8FAFC;
  --td-gray-100: #F1F5F9;
  --td-gray-200: #E2E8F0;
  --td-gray-300: #CBD5E1;
  --td-gray-400: #94A3B8;
  --td-gray-500: #64748B;
  --td-gray-600: #475569;
  --td-gray-700: #334155;
  --td-gray-800: #1E293B;
  --td-gray-900: #0F172A;

  /* Colores semánticos */
  --td-success: #10B981;
  --td-success-light: #D1FAE5;
  --td-success-dark: #059669;

  --td-warning: #F59E0B;
  --td-warning-light: #FEF3C7;
  --td-warning-dark: #D97706;

  --td-danger: #EF4444;
  --td-danger-light: #FEE2E2;
  --td-danger-dark: #DC2626;

  --td-info: #3B82F6;
  --td-info-light: #DBEAFE;
  --td-info-dark: #2563EB;

  /* Colores de estados de expediente */
  --status-pendiente: #F59E0B;
  --status-confirmado: #3B82F6;
  --status-emitido: #8B5CF6;
  --status-en-viaje: #10B981;
  --status-finalizado: #6B7280;
  --status-cancelado: #EF4444;

  /* Colores de tipos de servicio */
  --tipo-hotel: #3B82F6;
  --tipo-vuelo: #0EA5E9;
  --tipo-traslado: #F59E0B;
  --tipo-actividad: #8B5CF6;
  --tipo-seguro: #10B981;
  --tipo-extra: #6B7280;

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 60px;
  --header-height: 58px;
  --right-panel-width: 320px;

  /* Tipografía */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.70rem;
  --font-size-sm: 0.78rem;
  --font-size-base: 0.875rem;
  --font-size-md: 0.95rem;
  --font-size-lg: 1.05rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;

  /* Espaciado */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Bordes */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Transiciones */
  --transition-fast: 100ms ease;
  --transition: 150ms ease;
  --transition-slow: 250ms ease;

  /* Z-index */
  --z-dropdown: 100;
  --z-sidebar: 200;
  --z-header: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* ============================================================
   RESET Y BASE
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--td-gray-800);
  background: var(--td-gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--td-primary);
  text-decoration: none;
}

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

button {
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================================
   TIPOGRAFÍA
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
  color: var(--td-gray-900);
}

h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-md); }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

.text-muted { color: var(--td-gray-500); }
.text-primary { color: var(--td-primary); }
.text-accent { color: var(--td-accent-dark); }
.text-success { color: var(--td-success-dark); }
.text-danger { color: var(--td-danger); }
.text-warning { color: var(--td-warning-dark); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'Courier New', monospace; }

/* ============================================================
   BOTONES
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.45rem var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

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

.btn-primary {
  background: var(--td-primary);
  color: white;
  border-color: var(--td-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--td-primary-light);
  border-color: var(--td-primary-light);
  color: white;
}

.btn-accent {
  background: var(--td-accent);
  color: white;
  border-color: var(--td-accent);
}

.btn-accent:hover:not(:disabled) {
  background: var(--td-accent-light);
  color: white;
}

.btn-outline {
  background: white;
  color: var(--td-gray-700);
  border-color: var(--td-gray-300);
}

.btn-outline:hover:not(:disabled) {
  background: var(--td-gray-50);
  border-color: var(--td-gray-400);
  color: var(--td-gray-800);
}

.btn-ghost {
  background: transparent;
  color: var(--td-gray-600);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--td-gray-100);
  color: var(--td-gray-800);
}

.btn-danger {
  background: var(--td-danger);
  color: white;
  border-color: var(--td-danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--td-danger-dark);
  color: white;
}

.btn-success {
  background: var(--td-success);
  color: white;
  border-color: var(--td-success);
}

.btn-sm {
  padding: 0.3rem var(--space-3);
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: 0.65rem var(--space-6);
  font-size: var(--font-size-md);
}

.btn-icon {
  padding: 0.45rem;
  width: 32px;
  height: 32px;
  justify-content: center;
}

.btn-icon.btn-sm {
  width: 26px;
  height: 26px;
  padding: 0.2rem;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */

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

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--td-gray-700);
}

.form-label .required {
  color: var(--td-danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 0.45rem var(--space-3);
  font-size: var(--font-size-base);
  color: var(--td-gray-800);
  background: white;
  border: 1px solid var(--td-gray-300);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--td-primary);
  box-shadow: 0 0 0 3px rgb(27 61 122 / 0.12);
}

.form-control:disabled {
  background: var(--td-gray-100);
  color: var(--td-gray-500);
  cursor: not-allowed;
}

.form-control.is-invalid {
  border-color: var(--td-danger);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgb(239 68 68 / 0.12);
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--td-danger);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--td-gray-500);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1.25em;
  padding-right: 2.5rem;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  gap: var(--space-4);
}

.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* Checkbox y radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--td-primary);
  cursor: pointer;
}

/* ============================================================
   TABLAS
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--td-gray-200);
  background: white;
}

table.td-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.td-table thead {
  background: var(--td-gray-50);
  border-bottom: 1px solid var(--td-gray-200);
}

.td-table thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--td-gray-500);
  white-space: nowrap;
}

.td-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

.td-table thead th.sortable:hover {
  color: var(--td-primary);
}

.td-table tbody tr {
  border-bottom: 1px solid var(--td-gray-100);
  transition: background var(--transition-fast);
}

.td-table tbody tr:last-child {
  border-bottom: none;
}

.td-table tbody tr:hover {
  background: var(--td-gray-50);
}

.td-table tbody tr.selected {
  background: var(--td-primary-50);
}

.td-table tbody tr.clickable {
  cursor: pointer;
}

.td-table td {
  padding: var(--space-3) var(--space-4);
  color: var(--td-gray-700);
  vertical-align: middle;
}

.td-table td.actions {
  text-align: right;
  white-space: nowrap;
}

/* ============================================================
   BADGES Y ETIQUETAS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2rem var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-primary { background: var(--td-primary-100); color: var(--td-primary); }
.badge-accent { background: var(--td-accent-100); color: var(--td-accent-dark); }
.badge-success { background: var(--td-success-light); color: var(--td-success-dark); }
.badge-warning { background: var(--td-warning-light); color: var(--td-warning-dark); }
.badge-danger { background: var(--td-danger-light); color: var(--td-danger-dark); }
.badge-info { background: var(--td-info-light); color: var(--td-info-dark); }
.badge-gray { background: var(--td-gray-100); color: var(--td-gray-600); }

/* Badge de tipo de servicio */
.badge-hotel { background: #DBEAFE; color: #1D4ED8; }
.badge-vuelo { background: #E0F2FE; color: #0369A1; }
.badge-traslado { background: #FEF3C7; color: #B45309; }
.badge-actividad { background: #EDE9FE; color: #6D28D9; }
.badge-seguro { background: #D1FAE5; color: #065F46; }
.badge-extra { background: var(--td-gray-100); color: var(--td-gray-600); }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: white;
  border: 1px solid var(--td-gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--td-gray-100);
  background: var(--td-gray-50);
}

.card-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--td-gray-800);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--td-gray-100);
  background: var(--td-gray-50);
}

/* Stat cards para dashboard */
.stat-card {
  background: white;
  border: 1px solid var(--td-gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stat-card .stat-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--td-gray-500);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--td-gray-900);
  line-height: 1;
}

.stat-card .stat-change {
  font-size: var(--font-size-xs);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   MODALES
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden { display: none; }

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 150ms ease;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--td-gray-900);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--td-gray-500);
  transition: all var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  font-size: 1.2rem;
}

.modal-close:hover {
  background: var(--td-gray-100);
  color: var(--td-gray-800);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--td-gray-200);
  flex-shrink: 0;
}

/* ============================================================
   FILTROS Y BUSCADORES
   ============================================================ */

.filter-bar {
  background: white;
  border: 1px solid var(--td-gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--td-gray-400);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  padding: 0.45rem var(--space-3) 0.45rem 2rem;
  border: 1px solid var(--td-gray-300);
  border-radius: var(--radius);
  font-size: var(--font-size-base);
  transition: border-color var(--transition);
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--td-primary);
  box-shadow: 0 0 0 3px rgb(27 61 122 / 0.1);
}

/* ============================================================
   PAGINACIÓN
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
}

.pagination .page-info {
  color: var(--td-gray-500);
  margin: 0 var(--space-2);
}

.pagination button {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--td-gray-300);
  border-radius: var(--radius);
  background: white;
  color: var(--td-gray-600);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.pagination button:hover:not(:disabled) {
  background: var(--td-gray-50);
  border-color: var(--td-primary);
  color: var(--td-primary);
}

.pagination button.active {
  background: var(--td-primary);
  border-color: var(--td-primary);
  color: white;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   TOASTS / NOTIFICACIONES
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--td-primary);
  min-width: 280px;
  max-width: 400px;
  pointer-events: all;
  animation: toastIn 200ms ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-color: var(--td-success); }
.toast.error { border-color: var(--td-danger); }
.toast.warning { border-color: var(--td-warning); }

.toast .toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast .toast-content { flex: 1; }
.toast .toast-title { font-weight: 600; font-size: var(--font-size-sm); }
.toast .toast-msg { font-size: var(--font-size-xs); color: var(--td-gray-500); }

/* ============================================================
   DROPDOWN MENUS
   ============================================================ */

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: white;
  border: 1px solid var(--td-gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: var(--z-dropdown);
  overflow: hidden;
  animation: dropIn 100ms ease;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu.hidden { display: none; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--td-gray-700);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--td-gray-50);
  color: var(--td-gray-900);
}

.dropdown-item.danger { color: var(--td-danger); }
.dropdown-item.danger:hover { background: var(--td-danger-light); }

.dropdown-divider {
  height: 1px;
  background: var(--td-gray-200);
  margin: var(--space-1) 0;
}

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--td-gray-200);
  gap: 0;
}

.tab-item {
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--td-gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

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

.tab-item.active {
  color: var(--td-primary);
  border-bottom-color: var(--td-primary);
  font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
}

.alert-info { background: var(--td-info-light); color: var(--td-info-dark); border: 1px solid #BFDBFE; }
.alert-success { background: var(--td-success-light); color: var(--td-success-dark); border: 1px solid #A7F3D0; }
.alert-warning { background: var(--td-warning-light); color: var(--td-warning-dark); border: 1px solid #FDE68A; }
.alert-danger { background: var(--td-danger-light); color: var(--td-danger-dark); border: 1px solid #FECACA; }

/* ============================================================
   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;
  gap: var(--space-4);
}

.empty-state .empty-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.empty-state .empty-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--td-gray-600);
}

.empty-state .empty-desc {
  font-size: var(--font-size-sm);
  color: var(--td-gray-400);
  max-width: 300px;
}

/* ============================================================
   LOADING
   ============================================================ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--td-gray-200);
  border-top-color: var(--td-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

/* ============================================================
   UTILIDADES
   ============================================================ */

.hidden { display: none !important; }
.invisible { visibility: hidden; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

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

.w-full { width: 100%; }
.h-full { height: 100%; }

.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.rounded { border-radius: var(--radius); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-full { border-radius: var(--radius-full); }

.border { border: 1px solid var(--td-gray-200); }
.border-t { border-top: 1px solid var(--td-gray-200); }
.border-b { border-bottom: 1px solid var(--td-gray-200); }

.bg-white { background: white; }
.bg-gray-50 { background: var(--td-gray-50); }
.bg-primary { background: var(--td-primary); }

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

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }

.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }

/* Separador */
.divider {
  height: 1px;
  background: var(--td-gray-200);
  margin: var(--space-4) 0;
}

/* Color dot para estados */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Número de expediente en monospace */
.exp-number {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--td-primary);
  background: var(--td-primary-50);
  padding: 0.15rem var(--space-2);
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

/* Avatar de usuario */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--td-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: var(--font-size-md); }

/* Montos */
.amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.amount-positive { color: var(--td-success-dark); }
.amount-negative { color: var(--td-danger); }
.amount-neutral { color: var(--td-gray-700); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 {
    grid-template-columns: 1fr;
  }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .modal-md, .modal-lg, .modal-xl { max-width: 100%; }
}

/* ============================================================
   DENSIDAD COMPACTA (data-density="compact" en <html>)
   Redefine las variables de espaciado/fuente → aprieta toda la
   UI (tablas, tarjetas, KPIs, secciones) sin tocar cada regla.
   Por defecto la app arranca en "compact"; el usuario puede
   cambiar a "comfortable" desde el botón de densidad (se guarda).
   ============================================================ */
html[data-density="compact"] {
  --space-3: 0.5rem;
  --space-4: 0.65rem;
  --space-5: 0.8rem;
  --space-6: 0.95rem;
  --space-8: 1.25rem;
  --space-10: 1.5rem;
  --space-12: 1.75rem;
  --font-size-lg: 1rem;
  --font-size-xl: 1.15rem;
  --font-size-2xl: 1.35rem;
}
/* Tablas más densas (filas finas tipo GIAV) */
html[data-density="compact"] table.td-table th,
html[data-density="compact"] table.td-table td { padding-top: .38rem; padding-bottom: .38rem; }
/* Tarjetas de expediente y KPIs más bajas */
html[data-density="compact"] .exp-card-header,
html[data-density="compact"] .exp-card-body { padding: var(--space-3) var(--space-4); }
html[data-density="compact"] .stat-card,
html[data-density="compact"] .kpi-card { padding: var(--space-3) var(--space-4); }
