:root {
    --bg-color: #121212;
    --text-color: #ffffff;
    --card-bg: #1f1f1f;
    --input-bg: #2c2c2c;
    --border-color: #333333;
}
[data-theme="light"] {
    --bg-color: #f0f2f5;
    --text-color: #1c1e21;
    --card-bg: #ffffff;
    --input-bg: #e4e6eb;
    --border-color: #cccccc;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color); color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

.header-top { background-color: var(--card-bg); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid var(--border-color); display: flex; flex-direction: column; }
.header-main { display: flex; justify-content: space-between; align-items: center; padding: 15px; }
#theme-toggle { background: none; border: none; font-size: 24px; cursor: pointer; }

/* MENÚ ADAPTADO PARA 6 BOTONES */
.top-nav { 
    display: flex; 
    justify-content: flex-start; /* Alineamos al principio */
    background-color: var(--card-bg); 
    border-top: 1px solid var(--border-color); 
    padding: 5px 10px; 
    overflow-x: auto; /* Permite scroll horizontal en móviles pequeños */
    gap: 15px;
    -webkit-overflow-scrolling: touch; /* Scroll suave en iPhone */
}
/* Ocultar la barra de scroll visualmente */
.top-nav::-webkit-scrollbar { display: none; }

.nav-btn { 
    flex: 0 0 auto; /* Evita que los botones se aplasten */
    background: none; border: none; color: #888; 
    font-size: 13px; padding: 10px 5px; cursor: pointer; text-align: center; 
}
.nav-btn.active { color: #e50914; font-weight: bold; }

.view { display: none; } .view.active { display: block; }

.search-bar { display: flex; padding: 15px; gap: 10px; }
.search-bar input, .auth-box input { flex: 1; padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--input-bg); color: var(--text-color); font-size: 16px; outline: none; }
.search-bar button { padding: 12px 20px; border-radius: 8px; border: none; background: #e50914; color: white; font-weight: bold; font-size: 16px; cursor: pointer; }

.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 15px; padding: 15px; }

.card { background: var(--card-bg); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; text-align: center; border: 1px solid var(--border-color); box-shadow: 0 2px 5px rgba(0,0,0,0.1); position: relative; }
.card img { width: 100%; height: auto; aspect-ratio: 2/3; object-fit: cover; cursor: pointer; }
.card h3 { font-size: 14px; padding: 10px; flex: 1; cursor: pointer; }
.card button { background: #e50914; color: white; border: none; padding: 10px; width: 100%; font-weight: bold; cursor: pointer; }

.auth-box { padding: 30px; display: flex; flex-direction: column; gap: 15px; margin-top: 50px; }
.auth-box button { padding: 15px; border-radius: 8px; border: none; background: #e50914; color: white; font-weight: bold; cursor: pointer; }
.auth-box .btn-secondary { background: #444; }

.btn-group { display: flex; width: 100%; gap: 5px; padding: 5px; }
.btn-group button { font-size: 12px; padding: 8px; border-radius: 4px; cursor: pointer; }
.btn-visto { background: #28a745 !important; }
.btn-borrar { background: #dc3545 !important; }
.status-badge { position: absolute; top: 5px; right: 5px; background: rgba(40,167,69,0.9); color:white; padding: 5px 10px; border-radius: 5px; font-size: 12px; font-weight: bold; z-index: 10; }
.media-badge { position: absolute; top: 5px; left: 5px; background: rgba(0, 0, 0, 0.8); color: white; padding: 4px 8px; border-radius: 5px; font-size: 12px; font-weight: bold; z-index: 10; border: 1px solid rgba(255,255,255,0.2); backdrop-filter: blur(2px); }

/* SISTEMA DE ESTRELLAS */
.rating-container { display: flex; justify-content: center; gap: 1px; padding: 5px 0; margin-top: auto; }
.star { color: #555555; font-size: 14px; cursor: pointer; transition: transform 0.1s, color 0.2s; }
.star.active { color: #f5c518; }
.star:active { transform: scale(1.3); }

/* PESTAÑAS DEL PERFIL */
.profile-header { padding: 20px; text-align: center; background: var(--card-bg); border-bottom: 1px solid var(--border-color); }
#profile-username { margin-bottom: 15px; font-size: 22px; color: #e50914; }
.profile-tabs { display: flex; justify-content: center; gap: 10px; }
.tab-btn { padding: 10px 15px; border-radius: 20px; border: 1px solid var(--border-color); background: var(--input-bg); color: var(--text-color); cursor: pointer; font-weight: bold; font-size: 13px;}
.tab-btn.active { background: #e50914; color: white; border-color: #e50914; }

/* Detalles y Responsive */
.btn-volver { margin: 15px; padding: 10px 15px; background: var(--card-bg); color: var(--text-color); border: 1px solid var(--border-color); border-radius: 8px; font-weight: bold; cursor: pointer; }

.details-header { 
    display: flex; 
    gap: 15px; 
    margin-bottom: 20px; 
}

.details-header img { 
    width: 120px; 
    border-radius: 8px; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); 
    align-self: flex-start; /* Evita que la imagen se estire verticalmente */
    object-fit: cover; 
    aspect-ratio: 2/3; 
    flex-shrink: 0; /* Evita que el móvil aplaste la imagen si falta espacio */
}

.details-info { 
    flex: 1; 
    min-width: 0; /* ¡LA CLAVE MÁGICA! Evita que el texto empuje la pantalla hacia los lados */
}

.details-info h2 { 
    margin-bottom: 10px; 
    font-size: 20px; 
    word-wrap: break-word; /* Si un título es excesivamente largo, lo corta en lugar de salirse */
}

.tag { 
    display: inline-block; 
    background: #e50914; 
    color: white; 
    padding: 4px 8px; 
    border-radius: 12px; 
    font-size: 12px; 
    font-weight: bold; 
    margin-bottom: 5px; 
}

.overview { 
    line-height: 1.6; 
    opacity: 0.9; 
    word-wrap: break-word; 
}

/* Hacemos que los botones de acción se adapten si no caben en una fila */
.details-info > div[style*="display:flex"] {
    flex-wrap: wrap !important;
}

/* ESTILOS PARA USUARIOS Y AMIGOS */
.user-card {
    background: var(--card-bg); border: 1px solid var(--border-color);
    padding: 15px; border-radius: 8px; margin-bottom: 10px;
    display: flex; justify-content: space-between; align-items: center;
}
.user-card-info { display: flex; align-items: center; gap: 10px; font-weight: bold; font-size: 16px; }
.user-card-actions { display: flex; gap: 5px; }
.btn-small { padding: 8px 12px; border-radius: 5px; font-weight: bold; border: none; cursor: pointer; color: white; }
.btn-add { background: #e50914; }
.btn-accept { background: #28a745; }
.btn-reject { background: #dc3545; }