/* ========================================
   T.SERRA-GES - COMPONENTS CSS
   Componentes Reutilizables
   ======================================== */

/* === INPUTS === */
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='time'],
input[type='datetime-local'],
input[type='tel'],
input[type='url'],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--borde-input);
  border-radius: var(--radio-md);
  font-size: var(--texto-base);
  background: var(--bg-input);
  color: var(--texto-principal);
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--borde-focus);
  background: var(--bg-card);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg-hover);
  color: var(--texto-disabled);
  cursor: not-allowed;
  opacity: 0.6;
}

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

/* === BOTONES === */
.btn {
  padding: 9px 20px;
  border-radius: var(--radio-md);
  font-size: var(--texto-md);
  font-weight: var(--peso-medium);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: var(--espacio-sm);
  justify-content: center;
  text-decoration: none;
}

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

.btn-principal {
  background: var(--color-naranja-principal);
  color: #ffffff;
}

.btn-principal:hover:not(:disabled) {
  background: var(--color-naranja-hover);
}

.btn-secundario {
  background: var(--bg-card);
  color: var(--texto-principal);
  border: 1px solid var(--borde-principal);
}

.btn-secundario:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-exito {
  background: var(--color-exito);
  color: #ffffff;
}

.btn-exito:hover:not(:disabled) {
  background: #16a34a;
}

.btn-error {
  background: var(--color-error);
  color: #ffffff;
}

.btn-error:hover:not(:disabled) {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 14px;
  font-size: var(--texto-sm);
}

.btn-lg {
  padding: 12px 28px;
  font-size: var(--texto-md);
}

/* === CARDS === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--borde-principal);
  border-radius: var(--radio-lg);
  padding: var(--espacio-xl);
  box-shadow: var(--sombra-sm);
  transition:
    background var(--transition-normal),
    border-color var(--transition-normal);
}

.card-header {
  font-size: var(--texto-xl);
  font-weight: var(--peso-semibold);
  margin-bottom: var(--espacio-lg);
  display: flex;
  align-items: center;
  gap: var(--espacio-sm);
}

.card-body {
  /* Contenido principal */
}

.card-footer {
  margin-top: var(--espacio-xl);
  padding-top: var(--espacio-lg);
  border-top: 1px solid var(--borde-principal);
  display: flex;
  gap: var(--espacio-md);
  justify-content: flex-end;
}

/* === BADGES === */
.badge {
  display: inline-block;
  font-size: var(--texto-xs);
  padding: 3px 10px;
  border-radius: var(--radio-full);
  font-weight: var(--peso-medium);
}

.badge-exito {
  background: var(--color-exito-bg);
  color: var(--color-exito-text);
}

.badge-error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
}

.badge-info {
  background: var(--color-info-bg);
  color: var(--color-info-text);
}

.badge-neutral {
  background: var(--bg-hover);
  color: var(--texto-secundario);
}

/* === ALERTAS === */
.alerta {
  padding: 12px 16px;
  border-radius: var(--radio-md);
  font-size: var(--texto-sm);
  display: flex;
  align-items: center;
  gap: var(--espacio-sm);
  margin-bottom: var(--espacio-lg);
}

.alerta svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.alerta-exito {
  background: var(--color-exito-bg);
  color: var(--color-exito-text);
  border: 1px solid #86efac;
}

.alerta-error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border: 1px solid #fca5a5;
}

.alerta-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid #fcd34d;
}

.alerta-info {
  background: var(--color-info-bg);
  color: var(--color-info-text);
  border: 1px solid #93c5fd;
}

/* === FORMULARIOS === */
.form-group {
  margin-bottom: var(--espacio-lg);
}

.form-label {
  display: block;
  font-size: var(--texto-sm);
  color: var(--texto-secundario);
  margin-bottom: 6px;
  font-weight: var(--peso-medium);
}

.form-hint {
  font-size: var(--texto-xs);
  color: var(--texto-disabled);
  margin-top: 4px;
}

.form-error {
  font-size: var(--texto-xs);
  color: var(--color-error);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--espacio-md);
}

/* === TABLAS === */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--texto-sm);
}

thead {
  background: var(--bg-hover);
  border-bottom: 2px solid var(--borde-principal);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: var(--peso-semibold);
  color: var(--texto-secundario);
  font-size: var(--texto-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--borde-principal);
  color: var(--texto-principal);
}

tbody tr:hover {
  background: var(--bg-hover);
}

/* Alineación de números y cantidades */
.text-right,
th.text-right,
td.text-right {
  text-align: right !important;
}

/* Botones de acción en tablas */
.btn-action {
  padding: 6px 10px;
  border-radius: var(--radio-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--texto-xs);
  font-weight: var(--peso-medium);
  transition: opacity var(--transition-fast);
  margin-right: 4px;
}

.btn-action:hover {
  opacity: 0.8;
}

.btn-action svg {
  width: 14px;
  height: 14px;
}

/* Colores específicos por tipo de acción */
.btn-crear {
  background: #22c55e;
  color: #ffffff;
} /* Verde */
.btn-editar {
  background: #ff7f1e;
  color: #ffffff;
} /* Naranja */
.btn-eliminar {
  background: #ef4444;
  color: #ffffff;
} /* Rojo */
.btn-ver {
  background: #3b82f6;
  color: #ffffff;
} /* Azul */
.btn-pdf {
  background: #d946ef;
  color: #ffffff;
} /* Fucsia */

/* === MODAL === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--transition-normal),
    visibility var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radio-lg);
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sombra-xl);
  transform: scale(0.9);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.modal-overlay.open .modal {
  transform: scale(1);
}

/* Modal Content - Para modales creados dinámicamente */
.modal-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

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

.modal-header {
  padding: var(--espacio-xl);
  border-bottom: 1px solid var(--borde-principal);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: var(--texto-xl);
  font-weight: var(--peso-semibold);
  color: var(--texto-principal);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radio-md);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
}

.modal-close svg {
  width: 20px;
  height: 20px;
  color: var(--texto-secundario);
}

.modal-body {
  padding: var(--espacio-xl);
}

.modal-footer {
  padding: var(--espacio-xl);
  border-top: 1px solid var(--borde-principal);
  display: flex;
  gap: var(--espacio-md);
  justify-content: flex-end;
}

/* === LOADING === */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--borde-input);
  border-top-color: var(--color-naranja-principal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* === UTILIDADES === */
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.text-left {
  text-align: left;
}

.mt-0 {
  margin-top: 0;
}
.mt-sm {
  margin-top: var(--espacio-sm);
}
.mt-md {
  margin-top: var(--espacio-md);
}
.mt-lg {
  margin-top: var(--espacio-lg);
}
.mt-xl {
  margin-top: var(--espacio-xl);
}

.mb-0 {
  margin-bottom: 0;
}
.mb-sm {
  margin-bottom: var(--espacio-sm);
}
.mb-md {
  margin-bottom: var(--espacio-md);
}
.mb-lg {
  margin-bottom: var(--espacio-lg);
}
.mb-xl {
  margin-bottom: var(--espacio-xl);
}

.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.justify-center {
  justify-content: center;
}
.gap-sm {
  gap: var(--espacio-sm);
}
.gap-md {
  gap: var(--espacio-md);
}
.gap-lg {
  gap: var(--espacio-lg);
}

/* === TOAST NOTIFICATIONS === */
#toast-container {
  position: fixed;
  top: var(--espacio-lg);
  right: var(--espacio-lg);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--espacio-sm);
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--espacio-md);
  padding: var(--espacio-md) var(--espacio-lg);
  background: var(--bg-card);
  border: 1px solid var(--borde-principal);
  border-radius: var(--radio-md);
  box-shadow: var(--sombra-lg);
  opacity: 0;
  transform: translateX(100%);
  transition: all var(--transition-normal);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

.toast-message {
  flex: 1;
  font-size: var(--texto-sm);
  color: var(--texto-principal);
}

.toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
}

.toast-close svg {
  width: 100%;
  height: 100%;
  color: var(--texto-secundario);
}

/* Toast Types */
.toast-success {
  border-left: 4px solid #22c55e;
}
.toast-success .toast-icon svg {
  color: #22c55e;
}

.toast-error {
  border-left: 4px solid #ef4444;
}
.toast-error .toast-icon svg {
  color: #ef4444;
}

.toast-warning {
  border-left: 4px solid #f59e0b;
}
.toast-warning .toast-icon svg {
  color: #f59e0b;
}

.toast-info {
  border-left: 4px solid #3b82f6;
}
.toast-info .toast-icon svg {
  color: #3b82f6;
}

/* ========================================
   MODALES DE ALERTA (ALERT MODAL)
   ======================================== */

.alert-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--espacio-xl);
  border-radius: var(--radio-lg);
  position: relative;
}

.alert-modal .alert-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--espacio-lg);
  flex-shrink: 0;
}

.alert-modal .alert-icon svg {
  width: 32px;
  height: 32px;
  stroke-width: 2;
}

.alert-modal.alert-success {
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-modal.alert-success .alert-icon {
  background: rgba(34, 197, 94, 0.1);
}

.alert-modal.alert-success .alert-icon svg {
  color: #22c55e;
}

.alert-modal.alert-success .modal-title {
  color: #22c55e;
}

.alert-modal.alert-error {
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-modal.alert-error .alert-icon {
  background: rgba(239, 68, 68, 0.1);
}

.alert-modal.alert-error .alert-icon svg {
  color: #ef4444;
}

.alert-modal.alert-error .modal-title {
  color: #ef4444;
}

.alert-modal.alert-warning {
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-modal.alert-warning .alert-icon {
  background: rgba(245, 158, 11, 0.1);
}

.alert-modal.alert-warning .alert-icon svg {
  color: #f59e0b;
}

.alert-modal.alert-warning .modal-title {
  color: #f59e0b;
}

.alert-modal.alert-info {
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.alert-modal.alert-info .alert-icon {
  background: rgba(59, 130, 246, 0.1);
}

.alert-modal.alert-info .alert-icon svg {
  color: #3b82f6;
}

.alert-modal.alert-info .modal-title {
  color: #3b82f6;
}
