:root {
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-light: #EFF6FF;
  --primary-dark: #1D4ED8;
  --secondary: #8B5CF6;
  --secondary-light: #F5F3FF;
  --accent: #06B6D4;
  --accent-light: #ECFEFF;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --success: #10B981;
  --success-light: #ECFDF5;
  --info: #3B82F6;
  --info-light: #EFF6FF;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --sidebar-bg: #FFFFFF;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.06);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Text utilities ─── */
.text-accent { color: var(--accent) !important; }
.text-primary { color: var(--primary) !important; }
.text-secondary { color: var(--secondary) !important; }

.bg-primary-light { background: var(--primary-light) !important; }
.bg-accent-light { background: var(--accent-light) !important; }
.bg-secondary-light { background: var(--secondary-light) !important; }
.bg-warning-light { background: var(--warning-light) !important; }
.bg-danger-light { background: var(--danger-light) !important; }
.bg-success-light { background: var(--success-light) !important; }

/* ─── Ripple effect ─── */
.ripple {
  position: relative;
  overflow: hidden;
}
.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255,255,255,0.35) 10%, transparent 10%);
  background-size: 0;
  background-position: 50%;
  background-repeat: no-repeat;
  transition: background-size 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.ripple:active::after {
  background-size: 1000%;
  transition: background-size 0s;
}

/* ─── Hover lift ─── */
.hover-lift {
  transition: transform var(--transition), box-shadow var(--transition);
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ─── Animations ─── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideInLeft {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ─── Toast ─── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 420px;
  width: calc(100% - 40px);
}

.toast-custom {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideInRight 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 4px solid;
  position: relative;
}
.toast-custom.removing {
  animation: slideOutRight 0.3s ease forwards;
}
@keyframes slideOutRight {
  to { transform: translateX(120%); opacity: 0; }
}

.toast-success { background: var(--success-light); border-color: var(--success); }
.toast-error { background: var(--danger-light); border-color: var(--danger); }
.toast-info { background: var(--info-light); border-color: var(--primary); }
.toast-warning { background: var(--warning-light); border-color: var(--warning); }

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--primary); }
.toast-warning .toast-icon { color: var(--warning); }

.toast-text { flex: 1; font-size: 0.9rem; color: var(--text); line-height: 1.4; }
.toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 2px 0 0 8px; font-size: 1.2rem;
  transition: color 0.15s; line-height: 1; flex-shrink: 0;
}
.toast-close:hover { color: var(--text); }

/* ─── Bootstrap overrides ─── */
.btn {
  border-radius: 8px;
  font-weight: 500;
  padding: 0.5rem 1.2rem;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-outline-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239,68,68,0.25);
}

.form-control {
  border-radius: 8px;
  border: 1.5px solid var(--border);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.input-group-text {
  background: var(--border-light);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.input-group .form-control {
  border-left: none;
  border-radius: 0 8px 8px 0;
}
.input-group .form-control:focus {
  border-left: none;
}

.modal-content {
  border-radius: var(--radius-lg);
}
.modal-footer {
  gap: 8px;
}

.fw-medium { font-weight: 500; }

/* ─── Panel card ─── */
.panel-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

/* ─── Custom table ─── */
.table-custom thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  padding: 0.75rem 1rem;
  background: var(--bg);
  white-space: nowrap;
}
.table-custom tbody td {
  padding: 0.7rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
}
.table-custom tbody tr:last-child td {
  border-bottom: none;
}
.table-custom tbody tr {
  transition: background 0.12s ease;
}
.table-custom tbody tr:hover {
  background: var(--primary-light);
}

/* ─── Action buttons ─── */
.acciones-cell {
  white-space: nowrap;
  text-align: right;
}
.btn-action {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  margin: 0 2px;
  position: relative;
}
.btn-action i {
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}
.btn-action-ver {
  background: rgba(59,130,246,0.1);
  color: #3B82F6;
}
.btn-action-ver:hover {
  background: #3B82F6;
  color: #fff;
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 4px 12px rgba(59,130,246,0.35);
}
.btn-action-editar {
  background: rgba(245,158,11,0.12);
  color: #D97706;
}
.btn-action-editar:hover {
  background: #F59E0B;
  color: #fff;
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}
.btn-action-editar:hover i {
  transform: rotate(-20deg);
}
.btn-action-eliminar {
  background: rgba(239,68,68,0.1);
  color: #DC2626;
}
.btn-action-eliminar:hover {
  background: #EF4444;
  color: #fff;
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}
.btn-action-reactivar {
  background: rgba(16,185,129,0.12);
  color: #059669;
}
.btn-action-reactivar:hover {
  background: #10B981;
  color: #fff;
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}

/* ─── Status badges ─── */
.badge-activo {
  background: rgba(16,185,129,0.12);
  color: #059669;
  font-weight: 500;
  padding: 0.3em 0.7em;
  border-radius: 20px;
  font-size: 0.75rem;
  display: inline-block;
}
.badge-inactivo {
  background: rgba(148,163,184,0.12);
  color: #64748B;
  font-weight: 500;
  padding: 0.3em 0.7em;
  border-radius: 20px;
  font-size: 0.75rem;
  display: inline-block;
}

/* ─── Custom pagination ─── */
.pagination-custom {
  display: flex;
  gap: 3px;
}
.pagination-custom .page-item .page-link {
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px !important;
  transition: all 0.15s ease;
  background: var(--surface);
}
.pagination-custom .page-item .page-link:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.pagination-custom .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.pagination-custom .page-item.disabled .page-link {
  opacity: 0.4;
  pointer-events: none;
}
.table-info-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ─── Loading spinner overlay ─── */
.loading-row td {
  padding: 3rem 0;
}
.spinner-table {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Empty state ─── */
.empty-state-icon {
  font-size: 3rem;
  color: var(--text-muted);
  opacity: 0.4;
}

/* ─── Searchable Select ─── */
.searchable-wrapper {
  position: relative;
}
.searchable-original {
  display: none !important;
}
.searchable-input {
  cursor: pointer;
}
.searchable-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1060;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  margin-top: 2px;
}
.searchable-dropdown.show {
  display: block;
}
.searchable-option {
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.12s ease;
  border-bottom: 1px solid var(--border-light);
}
.searchable-option:last-child {
  border-bottom: none;
}
.searchable-option:hover {
  background: var(--primary-light);
}
.searchable-option.disabled {
  color: var(--text-muted);
  cursor: default;
  font-style: italic;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
