/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-2) 100%);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(124, 58, 237, 0.30);
}

/* Botón ámbar para destacar (quick-win / CTA secundario de marca) */
.btn-accent {
  background: var(--color-secondary);
  color: var(--color-bg-primary);
}
.btn-accent:hover:not(:disabled) {
  background: var(--color-secondary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-bg-primary);
  color: var(--color-text-inverse);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg-secondary);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-border);
  color: var(--color-text-primary);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

/* Botones sobre fondos oscuros (headers) */
.btn-on-dark {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.btn-on-dark:hover:not(:disabled) {
  background: rgba(255,255,255,0.22);
}
.btn-outline-on-dark {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.35);
  color: #fff;
}
.btn-outline-on-dark:hover:not(:disabled) {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1.0625rem;
}

.btn-full {
  width: 100%;
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  color: var(--color-bg-primary);
}

/* Cards */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: 1.0625rem;
  font-weight: 700;
}

.card-muted {
  background: var(--color-bg-surface);
  box-shadow: none;
  border: 1px solid var(--color-border);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-muted   { background: #F1F5F9; color: #475569; }

.badge-maturity-1 { background: #FEE2E2; color: #991B1B; }
.badge-maturity-2 { background: #FFEDD5; color: #9A3412; }
.badge-maturity-3 { background: #FEF9C3; color: #854D0E; }
.badge-maturity-4 { background: #ECFCCB; color: #3F6212; }
.badge-maturity-5 { background: #D1FAE5; color: #065F46; }

/* Toast */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  min-width: 280px;
  max-width: 380px;
  background: var(--color-bg-card);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.125rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease;
}

.toast.toast-error { border-left-color: var(--color-danger); }
.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-warning { border-left-color: var(--color-warning); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg { font-size: 0.875rem; line-height: 1.5; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,37,84,0.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  animation: slideUp 0.25s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.modal-box { max-height: 90vh; overflow-y: auto; }
.modal-box .form-group { margin-bottom: 0.9rem; }
/* Formularios dentro de modales: campos apilados a todo el ancho (buen táctil en móvil) */
.modal-box .form-label { display: block; margin-bottom: 0.35rem; }
.modal-box .form-input,
.modal-box .form-select,
.modal-box textarea { display: block; width: 100%; box-sizing: border-box; }
.modal-box .modal-actions .btn { flex: 1; }

@media (max-width: 560px) {
  .modal-overlay { padding: 0.75rem; align-items: flex-start; }
  .modal-box { padding: 1.4rem 1.15rem; border-radius: 16px; margin-top: 0.5rem; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

.code-block {
  display: inline-block;
  font-family: var(--font-data);
  background: var(--color-bg-primary);
  color: #fff;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  user-select: all;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: 1.25rem 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  margin: 1.25rem 0;
}

.divider-text::before, .divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Stats */
.stat-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-data);
  color: var(--color-bg-primary);
  line-height: 1;
}

.stat-sub {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  background: var(--color-bg-surface);
  color: var(--color-text-muted);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--color-bg-surface);
}

/* Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.page-loading {
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--color-text-muted);
}

.hidden { display: none !important; }
