/* ===== PERFIL DE USUARIO ===== */

.profile-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg, #f5f5f5);
  z-index: 1500;
  display: none;
}

.profile-overlay.show {
  display: block;
}

.profile-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header del perfil */
.profile-header {
  background: linear-gradient(135deg, #0b3b8f 0%, #1e5bb8 100%);
  color: #fff;
  padding: 0 16px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(50px + env(safe-area-inset-top));
  z-index: 100;
  transition: transform 0.3s ease;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.profile-header-content {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding-top: 1.1rem;
}

.profile-header.oculto {
  transform: translateY(-100%);
}

.profile-header-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-back {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.profile-back:hover {
  background: rgba(255,255,255,0.25);
}

.profile-header-title {
  font-size: 15px;
  font-weight: 600;
  margin-left: 4px;
  margin-right: auto;
}

.profile-menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 17px;
  cursor: pointer;
}

/* Info del perfil */
.profile-info {
  background: #fff;
  padding: 0 0 20px 0;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
}

/* Banner / foto de portada */
.profile-banner-wrap {
  position: relative;
  width: 100%;
  height: 200px;
}

.profile-banner {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, #0b3b8f 0%, #1e5bb8 100%);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.profile-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-banner-edit {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  border: none;
  border-radius: 20px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10;
  pointer-events: auto;
  -webkit-tap-highlight-color: rgba(255,255,255,0.2);
}

/* Avatar circular superpuesto */
.profile-avatar-wrap {
  position: relative;
  margin-top: -96px;
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.profile-avatar {
  width: 192px !important;
  height: 192px !important;
  border-radius: 50% !important;
  border: 4px solid #fff !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18) !important;
  background: linear-gradient(135deg, #0b3b8f 0%, #1e5bb8 100%) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 64px;
  font-weight: 600;
  overflow: hidden;
  position: relative;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-edit {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 26px;
  height: 26px;
  background: var(--azul);
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
}

.profile-name {
  display: block !important;
  font-size: 20px;
  font-weight: 700;
  color: #111;
  margin: 0 0 2px;
}

.profile-username {
  display: block !important;
  font-size: 14px;
  color: #888;
  margin: 0 0 6px;
}

.profile-bio {
  font-size: 17px;
  color: #374151;
  max-width: 300px;
  margin: 0 auto 16px;
  line-height: 1.3;
}

/* Stats */
.profile-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 16px;
}

.profile-stat {
  text-align: center;
}

.profile-stat-value {
  font-size: 17px;
  font-weight: 700;
  color: #111;
}

.profile-stat-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
}

/* Botón de amistad */
.profile-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.profile-friend-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.profile-friend-btn.add {
  background: var(--primary-color, #2563eb);
  color: #fff;
}

.profile-friend-btn.add:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.profile-friend-btn.friends {
  background: #d1fae5;
  color: #065f46;
}

.profile-friend-btn.pending {
  background: #fef3c7;
  color: #92400e;
}

.profile-friend-btn.pending:hover {
  background: #fde68a;
}

.profile-friend-btn.respond {
  background: #dbeafe;
  color: #1e40af;
}

.profile-friend-btn svg {
  width: 20px;
  height: 20px;
}

/* Tabs */
.profile-tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.profile-tab {
  flex: 1;
  padding: 14px;
  border: none;
  background: none;
  font-size: 17px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.profile-tab.active {
  color: var(--primary-color, #2563eb);
}

.profile-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--primary-color, #2563eb);
  border-radius: 3px 3px 0 0;
}

/* Wrapper scrolleable */
.profile-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0; /* Importante para flex scroll */
  padding-top: calc(50px + env(safe-area-inset-top)); /* Espacio para el header fixed */
}

/* Contenido del perfil (muro) */
.profile-content {
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.profile-posts {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-empty {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}

.profile-empty-icon {
  font-size: 43px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Responder solicitud desde perfil */
.profile-respond-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.profile-respond-btn {
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.profile-respond-btn.accept {
  background: #10b981;
  color: #fff;
}

.profile-respond-btn.accept:hover {
  background: #059669;
}

.profile-respond-btn.reject {
  background: #e5e7eb;
  color: #374151;
}

.profile-respond-btn.reject:hover {
  background: #d1d5db;
}

/* Responsive */
@media (min-width: 600px) {
  .profile-overlay {
    padding: 20px;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
  }
  
  .profile-container {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg, #f5f5f5);
  }
}
