/* ======= ESTILOS GENERALES DEL PERFIL ======= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f8f9fa;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

/* ======= CABECERA DEL PERFIL ======= */
.perfil-container {
  max-width: 1000px;
  margin: 2rem auto;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.perfil-header {
  display: flex;
  align-items: center;
  padding: 2rem;
  gap: 2rem;
  border-bottom: 1px solid #eaeaea;
  background-color: #f9f9f9;
}

.perfil-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #3b88ff;
  box-shadow: 0 3px 8px rgba(59, 136, 255, 0.2);
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
}

.perfil-avatar:hover {
  transform: scale(1.05);
}

.perfil-avatar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.perfil-avatar:hover .perfil-avatar-overlay {
  opacity: 1;
}

.perfil-avatar-overlay i {
  color: white;
  font-size: 1.5rem;
}

/* Campo oculto para subir imagen */
.avatar-upload {
  display: none;
}

.perfil-info {
  flex: 1;
}

.perfil-info h1 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  color: #333;
  font-weight: 600;
}

.perfil-info p {
  margin: 0.2rem 0;
  color: #666;
  font-size: 0.95rem;
}

/* ======= PESTAÑAS DE NAVEGACIÓN ======= */
.perfil-tabs {
  display: flex;
  border-bottom: 1px solid #e9ecef;
  background-color: #fff;
}

.perfil-tab {
  padding: 1rem 1.5rem;
  color: #555;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
}

.perfil-tab:hover {
  color: #3b88ff;
  background-color: rgba(59, 136, 255, 0.05);
}

.perfil-tab.active {
  color: #3b88ff;
  border-bottom: 2px solid #3b88ff;
  font-weight: 600;
}

/* ======= CONTENIDO DE LAS SECCIONES ======= */
.perfil-content {
  padding: 1.5rem;
}

.perfil-section {
  display: none;
  animation: fadeIn 0.4s ease;
}

.perfil-section.active {
  display: block;
}

.perfil-section h2 {
  font-size: 1.5rem;
  color: #333;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #eaeaea;
}

/* ======= MENSAJES DE ERROR Y ÉXITO ======= */
.errores, .exito {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 4px;
}

.errores {
  background-color: #ffebee;
  border-left: 4px solid #f44336;
  color: #d32f2f;
}

.exito {
  background-color: #e8f5e9;
  border-left: 4px solid #4caf50;
  color: #2e7d32;
}

.errores p, .exito p {
  margin: 0.5rem 0;
}

/* ======= FORMULARIOS ======= */
.editar-perfil-form,
.cambiar-password-form {
  max-width: 600px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #444;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus {
  border-color: #3b88ff;
  box-shadow: 0 0 0 3px rgba(59, 136, 255, 0.1);
  outline: none;
}

.form-group input[disabled] {
  background-color: #f9f9f9;
  color: #666;
  cursor: not-allowed;
}

.form-group small {
  display: block;
  margin-top: 0.5rem;
  color: #888;
  font-size: 0.85rem;
  font-style: italic;
}

.btn {
  display: inline-block;
  background-color: #3b88ff;
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-size: 0.95rem;
}

.btn:hover {
  background-color: #2a6fd1;
  box-shadow: 0 2px 8px rgba(42, 111, 209, 0.3);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-outline {
  background-color: transparent;
  color: #3b88ff;
  border: 1px solid #3b88ff;
}

.btn-outline:hover {
  background-color: #3b88ff;
  color: white;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}
/* Ajustes específicos para la sección de entregas */

/* Imagen dentro de la tarjeta de entrega */
.entrega-icon {
  width: 80px !important;
  height: 80px !important;
  min-width: 80px !important;  /* Previene que se expanda */
  object-fit: cover !important;
  border-radius: 8px !important;
  margin-right: 10px !important;
}

/* Tarjeta de entrega */
.entrega-card {
  display: flex !important;
  align-items: flex-start !important;
  background-color: #fff !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  overflow: hidden !important;
  padding: 15px !important;
  margin-bottom: 15px !important;
  transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

/* Ajuste para imagen grande que aparece directamente en la pestaña de entregas */
#entregas > img {
  max-width: 100% !important;
  height: auto !important;
  max-height: 300px !important;
  display: block !important;
  margin: 0 auto 20px !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

/* Información de la entrega */
.entrega-info {
  flex: 1 !important;
  padding-left: 10px !important;
}

.entrega-info h3 {
  margin: 0 0 5px !important;
  font-size: 1.1rem !important;
  color: #333 !important;
}

.entrega-fecha {
  font-size: 0.85rem !important;
  color: #777 !important;
  margin-bottom: 10px !important;
}

/* Ajuste para la cuadrícula de entregas */
.entregas-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
  gap: 15px !important;
}

/* ======= ESTILOS PARA TRANSACCIONES ======= */
.transaction-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 10px rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  overflow: hidden;
}

.transaction-table th {
  background-color: #f5f5f5;
  color: #444;
  font-weight: 600;
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

.transaction-table td {
  padding: 1rem;
  border-bottom: 1px solid #eee;
}

.transaction-table tr:last-child td {
  border-bottom: none;
}

.transaction-table tr:hover {
  background-color: #f9f9f9;
}

.transaction-type {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.type-recarga {
  background-color: rgba(76, 175, 80, 0.1);
  color: #2e7d32;
}

.type-compra {
  background-color: rgba(33, 150, 243, 0.1);
  color: #1565c0;
}

.amount-positive {
  color: #2e7d32;
  font-weight: 600;
}

.amount-negative {
  color: #d32f2f;
  font-weight: 600;
}

/* ======= MODAL PARA CAMBIAR IMAGEN ======= */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 500px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: #888;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: #333;
}

.modal h3 {
  margin: 0 0 1.5rem;
  color: #333;
  font-size: 1.3rem;
}

.image-preview-container {
  margin: 1.5rem 0;
  text-align: center;
}

.image-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: 4px;
  border: 2px dashed #ddd;
  padding: 0.5rem;
}

.image-preview-placeholder {
  width: 100%;
  height: 200px;
  background-color: #f5f5f5;
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #888;
  font-size: 0.9rem;
  border: 2px dashed #ddd;
}

.image-upload-form {
  margin-top: 1.5rem;
}

.file-input-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.file-input-wrapper input[type=file] {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.file-input-button {
  display: inline-block;
  background-color: #f5f5f5;
  color: #444;
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-input-button:hover {
  background-color: #e9e9e9;
}

.file-name {
  margin-left: 0.5rem;
  font-size: 0.9rem;
  color: #666;
}

.modal-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
}

.btn-cancel {
  background-color: #f5f5f5;
  color: #444;
  border: 1px solid #ddd;
}

.btn-cancel:hover {
  background-color: #e9e9e9;
  box-shadow: none;
}

/* ======= ANIMACIONES ======= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ======= MEDIA QUERIES ======= */
@media (max-width: 768px) {
  .perfil-header {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }
  
  .perfil-info {
    text-align: center;
  }
  
  .perfil-tabs {
    overflow-x: auto;
    white-space: nowrap;
  }
  
  .perfil-tab {
    padding: 0.75rem 1rem;
  }
  
  .entregas-grid {
    grid-template-columns: 1fr;
  }
  
  .transaction-table {
    display: block;
    overflow-x: auto;
  }
  
  .editar-perfil-form,
  .cambiar-password-form {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .perfil-avatar {
    width: 100px;
    height: 100px;
  }
  
  .perfil-info h1 {
    font-size: 1.5rem;
  }
  
  .btn {
    width: 100%;
    text-align: center;
  }
  
  .modal-content {
    padding: 1.5rem;
  }
}

/* Ajuste para las imágenes de productos en Mis Entregas */
.perfil-section#entregas img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 1rem;
}

/* Si quieres un tamaño específico máximo */
.perfil-section#entregas .entrega-card img {
  max-width: 300px;
  display: block;
  margin: 0 auto;
}

/* Contenedor para centrar y limitar el tamaño de la imagen */
.entrega-imagen-container {
  max-width: 400px;
  margin: 0 auto 1.5rem;
  text-align: center;
}

/* Solución específica para el problema de navegación y avatar */

/* 1. Asegurar que el overlay del avatar no bloquee los clics */
.perfil-avatar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none !important; /* Clave: Asegura que nunca capture eventos de puntero */
  z-index: 1; /* Nivel de apilamiento apropiado */
}

/* 2. Reforzar el contenedor del avatar */
.avatar-container, #perfil-avatar-container {
  position: relative;
  width: 120px;
  height: 120px;
  cursor: pointer;
  z-index: 10;
}

/* 3. Asegurar que las pestañas sean clickeables y tengan prioridad en la navegación */
.perfil-tabs {
  display: flex;
  border-bottom: 1px solid #e9ecef;
  background-color: #fff;
  position: relative;
  z-index: 20 !important; /* Mayor prioridad que el avatar */
}

.perfil-tab {
  padding: 1rem 1.5rem;
  color: #555;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer !important; /* Forzar cursor de puntero */
  position: relative;
  z-index: 20 !important; /* Asegurar que estén por encima */
}

/* 4. Ajustar los niveles de apilamiento de los contenedores principales */
.perfil-container {
  position: relative;
  z-index: 1; /* Base para el contexto de apilamiento */
}

.perfil-header {
  position: relative;
  z-index: 10; /* Más alto que el contenedor pero menor que las pestañas */
}

.perfil-content {
  position: relative;
  z-index: 5; /* Menor que el header */
}

/* 5. Modal ajustado para no interferir */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000; /* Muy alto para estar por encima de todo */
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

/* Otros estilos permanecen iguales */