/*
 * ===================================================================
 * Hoja de Estilos Principal para el Clon de Twitter (X)
 * ===================================================================
 * Autor: Carlos Namias
 * Descripción: Este archivo contiene todos los estilos para la interfaz
 * de la aplicación. La estructura está dividida en secciones para 
 * facilitar el mantenimiento y la comprensión del código.
 * ===================================================================
 */

/* ===================================================================
   1. ESTILOS GLOBALES Y RESETEO
   =================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #000000;
    color: #E7E9EA;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent; /* Elimina el color de resaltado al tocar en móviles */
}

/* ===================================================================
   2. PANTALLA DE SPLASH (CARGA)
   =================================================================== */

#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgb(0, 0, 0);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.splash-hidden {
    opacity: 0;
    visibility: hidden;
}

#splash-screen .logo {
    width: 155px;
    animation: fadeIn 1.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===================================================================
   3. ENCABEZADO FIJO (HEADER)
   =================================================================== */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 53px;
    background-color: #000000ee; /* El `ee` final indica opacidad */
    backdrop-filter: blur(12px); /* Efecto "vidrio esmerilado" */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.profile-pic {
    width: 33px;
    height: 33px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
}

.x-logo {
    font-size: 30px;
    font-weight: bold;
}

.settings-icon {
    font-size: 24px;
    cursor: pointer;
}

/* ===================================================================
   4. PESTAÑAS DE NAVEGACIÓN (TABS)
   =================================================================== */

.tabs {
    position: fixed;
    top: 53px; /* Justo debajo del header */
    left: 0;
    right: 0;
    height: 53px;
    background-color: #000000;
    backdrop-filter: blur(12px);
    display: flex;
    border-bottom: 1px solid #313a41;
    z-index: 999;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.tab {
    flex: 1; /* Comparte el espacio disponible por igual */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 500;
    color: #727d89; /* Color para pestañas inactivas */
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
}

.tab:hover {
    background-color: #1c273200;
}

.tab.active {
    color: #E7E9EA; /* Color más brillante para la pestaña activa */
    font-weight: 700;
}

/* Indicador visual (línea azul) para la pestaña activa */
.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: #1D9BF0;
    border-radius: 2px 2px 0 0;
}

/* ===================================================================
   5. FEED PRINCIPAL Y TWEETS
   =================================================================== */

.feed {
    margin-top: 106px; /* Espacio para header (53px) + tabs (53px) */
    padding-bottom: 70px; /* Espacio para la navegación inferior */
}

.tweet {
    border-bottom: 1px solid #38444D;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tweet:hover {
    background-color: #1c273200;
}

.tweet-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
}

.tweet-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    overflow: hidden;
}

.tweet-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Asegura que la imagen cubra el espacio sin distorsionarse */
}

.tweet-info {
    flex: 1;
}

.tweet-user {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.tweet-name {
    font-weight: 700;
}

.verified {
    color: #1D9BF0; /* Color azul de cuentas verificadas */
    font-size: 18px;
}

.tweet-username,
.tweet-time {
    color: #71767B;
}

.tweet-menu {
    color: #71767B;
    cursor: pointer;
}

.tweet-content {
    line-height: 1.4;
    margin-bottom: 12px;
}

.tweet-image {
    width: 100%;
    border-radius: 16px;
    margin-bottom: 12px;
    border: 1px solid #38444D;
}

/* ===================================================================
   6. BOTONES DE ACCIÓN DEL TWEET
   =================================================================== */

.tweet-actions {
    display: flex;
    justify-content: space-between;
    max-width: 425px;
    margin-left: 52px; /* 40px del avatar + 12px de margen */
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #71767b;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    transition: color 0.2s;
}

.action-btn i {
    font-size: 18px;
}

.action-btn:hover {
    color: #1d9cf000;
}

.action-btn.liked {
    color: #F91880; /* Color rosa para "Me gusta" */
}

/* ===================================================================
   7. NAVEGACIÓN INFERIOR (FOOTER)
   =================================================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 53px;
    background-color: #000000;
    border-top: 1px solid #38444D;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    transition: transform 0.3s ease-out; /* Añadido para la animación */
}

/* Clase para ocultar el footer al hacer scroll hacia abajo */
.bottom-nav.is-hidden {
    transform: translateY(100%);
}

.nav-item {
    color: #e3e2e2;
    cursor: pointer;
    font-size: 26px;
    position: relative; /* Necesario para posicionar la insignia de notificación */
}

.notification-badge {
    position: absolute;
    top: 1px;
    right: -5px;
    background-color: #1D9BF0;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 50px;
}

/* ===================================================================
   8. BOTÓN FLOTANTE (COMPOSE)
   =================================================================== */

.floating-container {
    position: fixed;
    bottom: 70px;
    right: 16px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.floating-container.hidden {
    opacity: 0;
    transform: scale(0); /* Encoge el contenedor hasta desaparecer */
    pointer-events: none;
}

.compose-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #1D9BF0;
    color: white;
    border: none;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(192, 26, 26, 0);
    transition: background-color 0.2s, transform 0.3s ease-out;
    z-index: 2; /* Sobre los botones de acción */
    position: relative; /* Contenedor para los íconos internos */
}

.compose-btn:hover {
    background-color: #1A8CD8;
}

/* --- Animación de íconos del botón de componer --- */
.compose-btn i {
    position: absolute;
    top: 50%;
    left: 50%;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

/* Estado inicial: solo se ve el '+' */
.compose-btn .bi-plus-lg {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.compose-btn .bi-feather {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
}

/* Estado 'open': el '+' se anima y aparece la pluma */
.floating-container.open .compose-btn .bi-plus-lg {
    transform: translate(calc(-50% + 10px), calc(-50% - 10px)) scale(0.5);
    opacity: 0.7;
}

.floating-container.open .compose-btn .bi-feather {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* --- Botones de acción secundarios (fotos, espacios, etc.) --- */
.action-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
}

.action-buttons .action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #ffffff;
    color: #1A8CD8;
    border: none;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0);
    position: relative; /* Para el tooltip */
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    pointer-events: none;
}

.action-buttons .action-btn:hover {
    background-color: #1A8CD8;
}

/* Animación de aparición de botones de acción */
.floating-container.open .action-buttons .action-btn {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Animación escalonada */
.floating-container.open .action-buttons .action-btn:nth-child(1) { transition-delay: 0.2s; }
.floating-container.open .action-buttons .action-btn:nth-child(2) { transition-delay: 0.1s; }
.floating-container.open .action-buttons .action-btn:nth-child(3) { transition-delay: 0s; }

/* --- Tooltips de los botones --- */
.action-btn .tooltip-text,
.compose-btn .tooltip-text {
    visibility: hidden;
    width: max-content;
    background-color: #27334000;
    color: #E7E9EA;
    text-align: center;
    border-radius: 4px;
    padding: 4px 10px;
    position: absolute;
    z-index: 1;
    right: 60px; /* Posición a la izquierda del botón */
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    font-size: 16px;
    pointer-events: none;
}

.compose-btn .tooltip-text { right: 68px; }

/* Muestra los tooltips cuando el menú está abierto */
.floating-container.open .action-btn .tooltip-text,
.floating-container.open .compose-btn .tooltip-text {
    opacity: 1;
    visibility: visible;
}

/* Retraso en la aparición de los tooltips */
.floating-container.open .action-btn:nth-child(1) .tooltip-text { transition-delay: 0.2s; }
.floating-container.open .action-btn:nth-child(2) .tooltip-text { transition-delay: 0.1s; }
.floating-container.open .action-btn:nth-child(3) .tooltip-text { transition-delay: 0s; }
.floating-container.open .compose-btn .tooltip-text { transition-delay: 0.2s; }

/* ===================================================================
   9. OVERLAY (FONDO OSCURO)
   =================================================================== */

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(14, 20, 26, 0.774); /* Color de overlay de X/Twitter */
    z-index: 1000; /* Debajo del floating-container (1001) y sidebar (2000) */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-out;
}

#overlay.active {
    opacity: 1;
    pointer-events: auto; /* Permite hacer clic para cerrar menús */
}

/* ===================================================================
   10. ESTILOS ADICIONALES Y CLASES DE UTILIDAD
   =================================================================== */

/* Estilo para diferenciar los tweets que son anuncios */
.tweet.ad {
    background-color: #1A2732;
}

/* Clase para ocultar elementos en el scroll */
.is-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

/* ===================================================================
   11. BOTÓN "POSTED" (NUEVOS TWEETS)
   =================================================================== */

.demo-container {
    position: fixed;
    top: 50px; /* Posicionado debajo de las pestañas */
    left: 50%;
    transform: translate(-50%, -20px); /* Inicia un poco arriba */
    text-align: center;
    z-index: 1002; /* Sobre el feed y otros elementos */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.demo-container.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0); /* Vuelve a su posición original */
}

.posted-badge {
    background: linear-gradient(135deg, #1d9bf0 0%, #0c7abf 100%);
    border-radius: 50px;
    padding: 8px 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(29, 156, 240, 0);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.posted-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(29, 155, 240, 0.4);
    background: linear-gradient(135deg, #2ba3f7 0%, #1d9bf0 100%);
}

.posted-badge:active {
    transform: translateY(0);
}

.arrow-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.arrow-icon svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.avatars-group {
    display: flex;
    align-items: center;
    margin-left: -4px;
}

.avatar {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 1px solid #ffffff;
    margin-left: -8px;
    object-fit: cover;
    background: #fff;
}

.avatar:first-child {
    margin-left: 0;
}

.posted-text {
    color: white;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Efecto de brillo animado */
.posted-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.posted-badge:hover::before {
    left: 100%;
}

/* ===================================================================
   12. BARRA LATERAL DERECHA (PARA ESCRITORIO)
   =================================================================== */

#right-sidebar {
    display: none; /* Oculto por defecto en móviles */
    padding: 12px 30px 0 30px;
    width: 350px;
}

#right-sidebar .sidebar-content {
    position: sticky;
    top: 12px;
}

#right-sidebar .search-container {
    position: relative;
    margin-bottom: 16px;
}

#right-sidebar .search-container i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #71767B;
    font-size: 18px;
}

#right-sidebar .search-container input {
    width: 100%;
    background-color: #202327;
    border: 1px solid #202327;
    border-radius: 9999px;
    padding: 12px 12px 12px 48px;
    color: #E7E9EA;
    font-size: 15px;
}

#right-sidebar .search-container input:focus {
    outline: none;
    border-color: #1D9BF0;
    background-color: #15202B;
}

#right-sidebar .trends-container {
    background-color: #16181C;
    border-radius: 16px;
    padding: 12px 16px;
}

#right-sidebar .trends-container h3 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 12px;
}

#right-sidebar .trend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    cursor: pointer;
}

#right-sidebar .trend-item:hover {
    background-color: #1C1F23;
}

#right-sidebar .trend-info {
    display: flex;
    flex-direction: column;
}

#right-sidebar .trend-info span {
    font-size: 13px;
    color: #71767B;
}

#right-sidebar .trend-info strong {
    font-size: 15px;
    font-weight: 700;
    color: #E7E9EA;
}

#right-sidebar .trend-item i {
    color: #71767B;
}

#right-sidebar .show-more {
    color: #1D9BF0;
    text-decoration: none;
    font-size: 15px;
    padding-top: 12px;
    display: block;
}

/* ===================================================================
   13. MEDIA QUERY (DISEÑO PARA ESCRITORIO)
   =================================================================== */

@media screen and (min-width: 988px) {
    /* --- Layout Principal --- */
    #desktop-layout-container {
        display: flex;
        justify-content: center;
        width: 100%;
        max-width: 1280px;
        margin: 0 auto;
    }

    #main-column {
        width: 600px;
        border-left: 1px solid #2f3336;
        border-right: 1px solid #2f3336;
    }

    /* --- Barra lateral derecha --- */
    #right-sidebar {
        display: block;
    }

    /* --- Ajustes a elementos fijos --- */
    .header, .tabs {
        position: sticky; /* Se pegan al hacer scroll dentro de su columna */
        top: 0;
        z-index: 10;
        width: 100%;
    }
    
    .tabs {
        top: 53px; /* Se pega debajo del header */
    }

    .feed {
        margin-top: 0; /* El layout pegajoso maneja el espacio */
    }

    /* Ocultar elementos solo para móviles */
    .bottom-nav,
    .floating-container {
        display: none;
    }

    /* Ajuste de z-index para menús */
    .sidebar { z-index: 2001; }
    #overlay.active { z-index: 2000; }
}

/* ===================================================================
   14. MODO CLARO (SOBREESCRITURAS)
   =================================================================== */

body.light-mode {
    background-color: #FFFFFF;
    color: #0F1419;
}

.light-mode .header,
.light-mode .tabs,
.light-mode .bottom-nav,
.light-mode .sidebar {
    background-color: #FFFFFFee;
    border-color: #EFF3F4;
    color: #0F1419;
}

.light-mode .tab { color: #536471; }
.light-mode .tab.active { color: #0F1419; }
.light-mode .tweet { border-color: #EFF3F4; }
.light-mode .tweet:hover { background-color: #F7F7F7; }

.light-mode .tweet-username,
.light-mode .tweet-time,
.light-mode .action-btn {
    color: #536471;
}

.light-mode .menu-item { color: #0F1111; }
.light-mode .menu-item:hover { background-color: #EFEFEF; }
.light-mode .profile-header { border-bottom-color: #EFF3F4; }

.light-mode .profile-name,
.light-mode .stat-number {
    color: #0F1419;
}

.light-mode .profile-username,
.light-mode .stat-label {
    color: #536471;
}

.light-mode .separator { background-color: #EFF3F4; }

.light-mode #right-sidebar .search-container input {
    background-color: #EFF3F4;
    border-color: #EFF3F4;
    color: #0F1419;
}

.light-mode #right-sidebar .search-container input:focus {
    background-color: #FFFFFF;
}

.light-mode #right-sidebar .trends-container { background-color: #F7F9F9; }
.light-mode #right-sidebar .trend-info strong { color: #0F1419; }

.light-mode #right-sidebar .trend-info span,
.light-mode #right-sidebar .trend-item i {
    color: #536471;
}

.light-mode .x-logo,
.light-mode .settings-icon,
.light-mode .nav-item {
    color: #0F1419;
}

.light-mode .purple-badge { border-color: #FFFFFF; }
.light-mode .tweet-image { border-color: #CFD9DE; }
.light-mode #main-column { border-color: #EFF3F4; }
.light-mode .menu-icon { color: #0F1419; }
.light-mode .action-btn.liked { color: #F91880; }