/* ============================================================
   PERFIL.CSS — Modal perfil, avatar, temas, foto/emoji picker
   ============================================================ */

.overlay-perfil {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 270;
  align-items: flex-end; justify-content: center;
}
@media (min-width: 600px) {
  .overlay-perfil { align-items: center; padding: 20px; }
  .modal-perfil { border-radius: 24px !important; max-height: 90vh !important; }
}
.overlay-perfil.active { display: flex; }

.modal-perfil {
  background: var(--blanco);
  border-radius: 24px 24px 0 0;
  width: 100%; max-width: 520px;
  max-height: 90vh; 
  display: flex;
  flex-direction: column;
  position: relative;
  animation: slideUp .32s cubic-bezier(.22,.68,0,1.2);
  overflow: hidden; /* El modal no scrollea, scrollea el cuerpo */
}

.perfil-header {
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-claro) 100%);
  padding: 28px 24px 24px;
  border-radius: 24px 24px 0 0;
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
}

.perfil-avatar-big {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--tierra);
  border: 3px solid rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 900; color: white;
  flex-shrink: 0; cursor: pointer; position: relative;
  transition: transform 0.2s;
  overflow: hidden;
}
.perfil-avatar-big:hover { transform: scale(1.05); }
.perfil-avatar-big img { width: 100%; height: 100%; object-fit: cover; }

.perfil-avatar-edit-badge {
  position: absolute; bottom: 0; right: 0;
  background: var(--tierra); color: white;
  font-size: 14px; width: 22px; height: 22px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
}

.perfil-header-info h3 {
  font-family: 'Fraunces', serif;
  font-size: 20px; font-weight: 900;
  color: white; margin-bottom: 2px;
}
.perfil-header-info small {
  font-size: 12px; color: rgba(255,255,255,0.75);
}

.perfil-close {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,0.2); border: none;
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; font-size: 15px; color: white;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.perfil-close:hover { background: rgba(255,255,255,0.35); }

.perfil-body { 
  padding: 24px 28px 32px 24px; 
  overflow-y: auto;
  flex: 1;
}

/* Custom Scrollbar solo en el cuerpo */
.perfil-body::-webkit-scrollbar {
  width: 6px;
}
.perfil-body::-webkit-scrollbar-track {
  background: transparent;
}
.perfil-body::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}
.perfil-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.2);
}

.perfil-section-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gris); margin-bottom: 12px; margin-top: 20px;
  padding-bottom: 4px; border-bottom: 1px solid var(--crema-oscura);
}
.perfil-section-label:first-child { margin-top: 0; }

/* ── Avatar emoji picker en perfil ── */
.perfil-avatar-opts {
  display: none;
  background: var(--crema);
  border: 2px solid var(--crema-oscura);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
  animation: fadeUp 0.2s ease;
}
.perfil-avatar-opts.open { display: block; }
.perfil-avatar-opts p {
  font-size: 12px; color: var(--gris);
  margin-bottom: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}

.perfil-emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.perfil-emoji-opt {
  font-size: 24px; padding: 6px;
  border-radius: 10px; cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s; text-align: center;
  background: white;
}
.perfil-emoji-opt:hover { border-color: var(--verde-claro); }
.perfil-emoji-opt.sel { border-color: var(--verde); background: #D8F3DC; }

/* ── Categorías favoritas ── */
.perfil-cats-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.perfil-cat-pill {
  border: 2px solid var(--crema-oscura);
  border-radius: 50px;
  padding: 6px 14px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--cafe); background: var(--crema);
  transition: all 0.18s; display: flex;
  align-items: center; gap: 5px;
}
.perfil-cat-pill:hover { border-color: var(--verde-claro); }
.perfil-cat-pill.sel {
  border-color: var(--verde);
  background: var(--verde); color: white;
}

/* ── SELECTOR FOTO / EMOJI (paso 4) ── */
.media-tabs {
  display: flex;
  gap: 0;
  background: var(--crema-oscura);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 12px;
}
.media-tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--gris);
  cursor: pointer;
  transition: all 0.2s;
}
.media-tab.active {
  background: white;
  color: var(--cafe);
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}
.media-panel { display: none; }
.media-panel.active { display: block; animation: fadeUp 0.2s ease; }

.foto-drop-area {
  border: 2px dashed var(--crema-oscura);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--crema);
  position: relative;
}
.foto-drop-area:hover { border-color: var(--verde); background: white; }
.foto-drop-area .fda-icon { font-size: 36px; margin-bottom: 6px; }
.foto-drop-area .fda-text { font-size: 13px; color: var(--gris); line-height: 1.5; }
.foto-drop-area .fda-sub { font-size: 11px; color: #aaa; margin-top: 4px; }

#fotoPreview {
  width: 100%; border-radius: 10px;
  max-height: 180px; object-fit: cover;
  display: none; margin-top: 10px;
}
.foto-preview-wrap {
  position: relative; display: inline-block; width: 100%;
}
.foto-remove-btn {
  position: absolute; top: 14px; right: 8px;
  background: rgba(0,0,0,0.55); color: white;
  border: none; border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 13px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
}
.foto-remove-btn.visible { display: flex; }

.emoji-cat-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.emoji-cat-btn {
  border: 1.5px solid var(--crema-oscura);
  background: var(--crema);
  color: var(--cafe);
  border-radius: 50px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all .18s;
}
.emoji-cat-btn:hover,
.emoji-cat-btn.active {
  background: var(--verde);
  border-color: var(--verde);
  color: white;
}
.emoji-picker {
  max-height: 210px;
  overflow-y: auto;
  padding-right: 4px;
}

/* ── LIGHTBOX FOTO ── */
.lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.92); z-index: 9000;
  align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
.lightbox.active { display: flex; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.lightbox img {
  max-width: 100%; max-height: 90vh;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: zoomIn 0.25s cubic-bezier(.22,.68,0,1.2);
}
@keyframes zoomIn { from { transform: scale(0.85); opacity:0; } to { transform: scale(1); opacity:1; } }

.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.15); border: none;
  color: white; width: 38px; height: 38px;
  border-radius: 50%; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }
.foto-clickable { cursor: zoom-in; }

/* ── Selector de Temas ────────────────────────────────────────── */
.tema-section { margin-top: 20px; }
.tema-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.tema-card {
  border: 2.5px solid transparent;
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  position: relative;
}
.tema-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.tema-card.activo { border-color: var(--verde); box-shadow: 0 0 0 3px rgba(0,0,0,0.08); }
.tema-card.activo::after {
  content: '✓';
  position: absolute; top: 4px; right: 6px;
  font-size: 11px; font-weight: 700;
  color: var(--verde);
}
.tema-paleta {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-bottom: 7px;
}
.tema-color {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.1);
}
.tema-nombre {
  font-size: 11px;
  font-weight: 600;
  color: #444;
  line-height: 1.2;
}

/* ── Términos ── */
.termino-bloque h4 {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--verde);
  margin-bottom: 8px;
}
.termino-bloque p {
  font-size: 13px;
  color: var(--cafe);
  line-height: 1.7;
}
.termino-bloque ul li {
  font-size: 13px;
  color: var(--cafe);
}

/* ── Clases de Utilidad y Seguridad CSP para Perfil ── */
.perfil-description {
  font-size: 12px;
  color: var(--gris);
  margin-bottom: 12px;
}

.perfil-danger-zone {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--crema-oscura);
  text-align: center;
}

/* ── Temas de color (eliminación de inline background) ── */
#tema-default .tema-color:nth-child(1) { background: #1B4332; }
#tema-default .tema-color:nth-child(2) { background: #52B788; }
#tema-default .tema-color:nth-child(3) { background: #F5E6C8; }

#tema-petroleo .tema-color:nth-child(1) { background: #0A4D5C; }
#tema-petroleo .tema-color:nth-child(2) { background: #00B4D8; }
#tema-petroleo .tema-color:nth-child(3) { background: #E8F7FA; }

#tema-pizarra .tema-color:nth-child(1) { background: #1A4A44; }
#tema-pizarra .tema-color:nth-child(2) { background: #2AB5A8; }
#tema-pizarra .tema-color:nth-child(3) { background: #E8FAF8; }

#tema-cobalto .tema-color:nth-child(1) { background: #1A2E7A; }
#tema-cobalto .tema-color:nth-child(2) { background: #4C6EF5; }
#tema-cobalto .tema-color:nth-child(3) { background: #EEF2FF; }

#tema-bosque-oscuro .tema-color:nth-child(1) { background: #0F2419; }
#tema-bosque-oscuro .tema-color:nth-child(2) { background: #97C459; }
#tema-bosque-oscuro .tema-color:nth-child(3) { background: #EAF3DE; }

#tema-casi-negro .tema-color:nth-child(1) { background: #062D38; }
#tema-casi-negro .tema-color:nth-child(2) { background: #00C8E8; }
#tema-casi-negro .tema-color:nth-child(3) { background: #74C69D; }
