:root {
  --primary: #ff4c68;
  --primary-light: #ff8a71;
  --cyan: #00f3ff;
  --bg: #050505;
  --card: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --gray: #a0a0a0;
  --glass-border: rgba(255, 255, 255, 0.15);
}

/* --- RESET Y BASE --- */
* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

body {
  background: #000;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--text);
  overflow-x: hidden;
  height: 100vh;
}

.app-shell {
  width: 100%;
  max-width: 450px;
  height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  border-left: 1px solid #111;
  border-right: 1px solid #111;
  padding-bottom: 70px;
  box-sizing: border-box;
}

/* --- AUTH SECTION --- */
#auth-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 20px;
}

.logo-text {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(45deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 30px;
  letter-spacing: -1px;
}

.auth-card {
  background: var(--card);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  padding: 30px;
  border-radius: 24px;
  width: 100%;
  border: 1px solid var(--glass-border);
}

/* --- INPUTS Y BOTONES GLOBALES --- */
input, textarea {
  width: 100%;
  padding: 16px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  color: white;
  outline: none;
}

input:focus, textarea:focus {
  border-color: var(--primary);
}

button {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(45deg, var(--primary), var(--primary-light));
  color: white;
  margin-top: 10px;
}

/* --- FEED SECTION --- */
.snap-feed {
  height: calc(100vh - 70px);
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  background: #000;
  scrollbar-width: none;
}
.snap-feed::-webkit-scrollbar { display: none; }

.video-snap-item {
  height: calc(100vh - 70px);
  width: 100%;
  scroll-snap-align: start;
  position: relative;
  background: #000;
  overflow: hidden;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* CAPA DE INFORMACIÓN (OVERLAY) */
.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; 
  padding-bottom: 20px; 
  background: linear-gradient(transparent 50%, rgba(0,0,0,0.8) 100%);
  z-index: 10;
  pointer-events: none; 
}

.video-bottom-info {
  padding: 20px;
  pointer-events: auto; 
}

.creator-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}

.mini-avatar-feed {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  object-fit: cover;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
  background-color: #333; 
}

.username-label {
  color: white;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.video-title-display {
  font-size: 1rem;
  color: white;
  margin-bottom: 6px;
  font-weight: 600;
}

.video-desc-display {
  font-size: 0.9rem;
  color: #eee;
  max-height: 1.4em;
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
}

.video-desc-display.expanded {
  max-height: 200px;
  background: rgba(0,0,0,0.4);
  padding: 8px;
  border-radius: 8px;
}

/* BOTONES LATERALES */
.side-actions {
  position: absolute;
  right: 15px;
  bottom: 120px; 
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 20;
  pointer-events: auto;
}

.action-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.action-btn span {
  font-size: 0.8rem;
  margin-top: 5px;
  font-weight: 600;
}

/* BARRA DE PROGRESO CIAN */
.video-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  cursor: pointer;
  z-index: 30;
}

.video-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

/* --- NAVBAR --- */
#navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70px;
  background: rgba(0,0,0,0.95);
  display: flex !important;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #1a1a1a;
  z-index: 9000;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}

.nav-btn { background: none; color: var(--gray); border: none; font-size: 1.5rem; cursor: pointer; padding: 10px; width: auto; }
.nav-btn.active { color: white; }

.center-plus {
  background: white !important;
  color: black !important;
  border-radius: 12px;
  width: 50px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- GRID DE PERFIL --- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
}

.grid-item {
  position: relative;
  aspect-ratio: 9 / 16;
  background: #111;
  overflow: hidden;
  cursor: pointer;
}

.grid-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.action-btn i.fa-user-plus { font-size: 1.5rem; margin-bottom: 2px; }
.action-btn.following i { color: var(--cyan); }

/* ==========================================
   FASE 2: MENÚ DE 3 PUNTITOS (DROPDOWN)
========================================== */
.menu-container {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.three-dots-btn {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    margin: 0;
    padding: 0;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 40px;
    right: 0;
    background: #111;
    border: 1px solid #333;
    border-radius: 10px;
    overflow: hidden;
    flex-direction: column;
    min-width: 140px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.8);
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-menu button {
    background: transparent;
    color: #eee;
    border: none;
    padding: 12px 15px;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
    border-bottom: 1px solid #222;
    margin: 0;
    border-radius: 0;
}

.dropdown-menu button:last-child {
    border-bottom: none;
}

.dropdown-menu button:hover {
    background: #2a2a2a;
}

.dropdown-menu button.danger-text {
    color: #ff4c68;
}

/* --- PERFIL AJENO --- */
#other-profile-section { padding-top: 20px; animation: fadeIn 0.3s ease-in-out; }
#other-profile-section .profile-header { text-align: center; padding: 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); margin-bottom: 10px; }
#other-profile-section .main-pfp { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid #00f3ff; box-shadow: 0 0 15px rgba(0, 243, 255, 0.3); margin-bottom: 10px; }
#other-profile-section h2 { font-size: 1.5rem; color: #fff; margin-bottom: 5px; }
#other-profile-section .bio-text { color: #ccc; font-size: 0.9rem; max-width: 300px; margin: 0 auto 15px auto; line-height: 1.4; }

.follow-btn-main {
  background: #00f3ff; color: #000; border: none; padding: 10px 40px; border-radius: 25px;
  font-weight: bold; cursor: pointer; transition: all 0.3s ease; margin-top: 10px; font-size: 1rem; width: auto;
}
.follow-btn-main:hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(0, 243, 255, 0.5); }
.follow-btn-main.following { background: rgba(255, 255, 255, 0.1); color: #fff; border: 1px solid rgba(255, 255, 255, 0.3); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================================
   MODALES AISLADOS (NO ROMPERÁN TU DISEÑO)
========================================================================= */

.modal-overlay {
  position: fixed; /* OBLIGATORIO PARA QUE FLOTE SOBRE TODO */
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999; /* ALTO para asegurar que tape feed y perfiles */
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.modal-content.bottom-sheet {
  width: 100%;
  max-width: 450px;
  height: 70vh;
  background: #121212;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Capas de vista */
.comment-view-wrapper {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  background: #121212;
}

.replies-hidden { display: none !important; }
.replies-visible { display: flex !important; z-index: 10; }

/* Cabeceras Modal (protegidas del CSS global) */
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 20px; border-bottom: 1px solid #2a2a2a; flex-shrink: 0;
}

.modal-header h3 { flex: 1; text-align: center; font-size: 1rem; color: #fff; margin: 0; font-weight: 600; }

/* Protección para que los botones de cerrar no hereden el tamaño gigante */
.modal-header button, .close-modal-btn, .back-btn {
  width: 40px !important; height: 40px !important; padding: 0 !important; margin: 0 !important;
  background: none !important; border: none !important; color: white !important;
  font-size: 1.2rem !important; cursor: pointer; display: flex; justify-content: center; align-items: center;
}

/* Cuerpo Modal */
.modal-body { flex: 1; overflow-y: auto; padding: 10px; }

/* Diseño Comentarios */
.comment-item { display: flex; gap: 12px; padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.comment-avatar { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; cursor: pointer; }
.comment-user-name { font-weight: 700; font-size: 0.85rem; color: var(--gray); display: block; }
.comment-text { font-size: 0.9rem; color: #eee; margin: 4px 0; }
.reply-btn-text { font-size: 0.8rem; font-weight: 600; color: var(--gray); cursor: pointer; display: inline-block; margin-top: 5px;}

.comment-actions { display: flex; align-items: center; gap: 20px; }
.comment-react-tools { display: flex; gap: 12px; margin-left: auto; }

/* Protección botones de like */
.react-btn { 
  background: none !important; border: none !important; color: var(--gray) !important; 
  width: auto !important; padding: 0 !important; margin: 0 !important; font-size: 0.9rem !important;
}

/* Área de Escribir (Abajo) */
.comment-input-area {
  padding: 15px; border-top: 1px solid #2a2a2a;
  display: flex; gap: 10px; background: #121212; align-items: center; flex-shrink: 0;
}

/* Protección de inputs para que no choquen con el global */
.comment-input-area input {
  flex: 1; margin-bottom: 0 !important; padding: 12px 18px !important;
  background: #222 !important; border: none !important; border-radius: 25px !important; color: white;
}

.comment-input-area button {
  width: 45px !important; height: 45px !important; border-radius: 50% !important;
  margin-top: 0 !important; padding: 0 !important; background: var(--cyan) !important;
  color: black !important; display: flex; justify-content: center; align-items: center;
}

/* Listas de Usuarios (SmartFriends) */
#user-list-modal .modal-content { height: 60vh; border-radius: 20px 20px 0 0; }
.user-item { display: flex; align-items: center; gap: 15px; padding: 12px; border-bottom: 1px solid #222; cursor:pointer;}
.user-item-avatar { width: 45px; height: 45px; border-radius: 50%; object-fit: cover;}
.user-item-info { display: flex; flex-direction: column; flex: 1; }
.user-item-name { color: white; font-weight: 600; font-size: 0.95rem; }
.user-item-stats { color: var(--gray); font-size: 0.8rem; }

/* ==========================================
   FASE 3: SMARTBLOG & POSTS
========================================== */
.smartblog-btn {
    background: linear-gradient(45deg, #00f3ff, #00ff87) !important; /* Degradado Verde/Cian */
    color: #000 !important;
    width: auto;
    padding: 5px 15px;
    font-size: 0.85rem;
    border-radius: 14px;
    font-weight: 800;
    margin-left: 10px;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.smartblog-btn:hover {
    transform: scale(1.05);
}

/* Diseño de la Tarjeta del Post */
.post-card {
    background: #111;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid #222;
    position: relative;
}

.post-cover {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-bottom: 1px solid #222;
}

.post-body {
    padding: 15px;
}

.post-title {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: #fff;
}

.post-text {
    font-size: 0.95rem;
    color: #ccc;
    line-height: 1.5;
    margin-bottom: 15px;
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #222;
    padding-top: 12px;
    color: var(--gray);
    font-size: 0.85rem;
}

.post-actions {
    display: flex;
    gap: 15px;
}

.post-actions i {
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.post-actions i:hover { color: var(--cyan); }

/* Filtros */
.post-filters {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    border-bottom: 1px solid #222;
    padding-bottom: 10px;
}

.post-filters span {
    color: var(--gray);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.post-filters span.filter-active {
    color: #00ff87;
    border-bottom: 2px solid #00ff87;
    padding-bottom: 11px;
}

/* Badge de vistas en la cuadrícula de perfil */
.grid-item { position: relative; }
.view-badge {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

/* Botón de Suscripción en Blog */
.sub-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}
.sub-btn.subscribed {
    background: #333;
    color: var(--gray);
}

/* ==========================================
   🧠 FASE 1 IA: ANIMACIONES DE EVALUACIÓN
========================================== */

/* Latido del cerebro mientras la IA analiza */
@keyframes ai-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; text-shadow: 0 0 25px var(--cyan); }
    100% { transform: scale(1); opacity: 0.8; }
}

.fa-pulse {
    animation: ai-pulse 1.5s infinite ease-in-out;
}
