/* --- Estilos generales del contenedor --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #eef2f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding-top: 40px;
}
.contenedor {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}
h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #34495e;
    font-size: 2em;
    font-weight: 600;
}
h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.5em;
    font-weight: 500;
}
hr {
    border: 0;
    height: 1px;
    background-color: #ddd;
    margin: 2rem 0;
}

/* --- Estilos para formularios e inputs (generales) --- */
input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: #ff8c42;
}
button {
    padding: 0.8rem 1.5rem;
    background-color: #ff8c42;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
button:hover {
    background-color: #e07b3b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.error {
    color: #e74c3c;
    font-weight: bold;
    text-align: center;
    margin-bottom: 1rem;
    background-color: #fcebeb;
    padding: 10px;
    border-radius: 6px;
}
a {
    color: #ff8c42;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
.notificacion {
    background-color: #d1e7dd;
    color: #0f5132;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #badbcc;
    border-radius: 6px;
}

/* --- Estilos del Header del Lobby/Sala --- */
.header-lobby {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}
.header-lobby span strong {
    color: #2c3e50;
}
.header-lobby a {
    color: #2c3e50;
    font-weight: 500;
    transition: color 0.3s;
}
.header-lobby a:hover {
    color: #ff8c42;
}
/* Estilo para los nuevos botones de enlace */
.btn-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #ff8c42;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    text-decoration: none;
    margin-left: 10px;
}
.btn-link:hover {
    background-color: #e07b3b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    text-decoration: none;
}
.header-lobby .btn-link {
    margin-left: 5px;
}
/* --- Estilos de la lista de Salas en el Lobby --- */
.lista-salas {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 15px;
}
.sala-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sala-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}
.sala-link {
    flex-grow: 1;
    text-decoration: none;
    color: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sala-link div {
    display: flex;
    flex-direction: column;
}
.sala-link strong {
    font-size: 1.2em;
    color: #2c3e50;
}
.sala-link p {
    margin: 5px 0;
    font-size: 0.9em;
    color: #7f8c8d;
}
.sala-link small {
    font-size: 0.8em;
    color: #95a5a6;
}
.contador-participantes {
    font-weight: bold;
    background-color: #ff8c42;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    margin-left: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.btn-eliminar {
    margin-left: 1rem;
    color: #e74c3c;
    text-decoration: none;
    font-weight: bold;
    flex-shrink: 0;
    font-size: 0.9em;
    padding: 8px 12px;
    background-color: #fcebeb;
    border-radius: 6px;
    transition: background-color 0.2s, transform 0.1s;
}
.btn-eliminar:hover {
    background-color: #f7d4d4;
    transform: translateY(-2px);
}
.sin-salas-mensaje {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 2rem;
    border: 1px dashed #ccc;
    border-radius: 8px;
    grid-column: 1 / -1;
}

/* === ESTILOS PARA LA SALA DE CHAT === */
body.sala-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background-color: #fff;
}
.sala-header {
    background: #fff5ee;
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
    border-bottom: none;
}
.sala-header h2 {
    margin: 0;
    font-size: 1.5rem;
}
.sala-main {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}
.panel-lateral {
    flex-basis: 220px;
    flex-shrink: 0;
    background-color: #f8f9fa;
    padding: 1rem;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}
.panel-lateral h3 {
    margin-top: 0;
    font-size: 1.1em;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    color: #333;
}
#lista-participantes ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}
#lista-participantes li {
    padding: 5px 0;
    color: #444;
}
#lista-participantes .admin {
    color: #e74c3c;
    font-weight: bold;
}
#lista-participantes .admin::before {
    content: '@ ';
}
.controles-fuente {
    display: flex;
    align-items: center;
    gap: 5px;
}
.controles-fuente span {
    margin-right: 10px;
    font-size: 0.9em;
    color: #666;
}
.controles-fuente button {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 1.1rem;
    border-radius: 3px;
    background-color: #6c757d;
}
.controles-fuente button:hover {
    background-color: #5a6268;
}
.sala-page .chat-box {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    background-color: #fff;
    margin-bottom: 0;
    border: 1px solid #ddd;
    border-radius: 5px;
}
.mensaje {
    margin-bottom: 0.8rem;
    line-height: 1.4;
    word-wrap: break-word;
}
.mensaje strong {
    color: #ff8c42;
}
.sala-footer {
    background: #f1f1f1;
    padding: 1rem 1.5rem;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    position: relative;
}
.mensaje-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-grow: 1;
}
.mensaje-form input {
    flex-grow: 1;
    margin-bottom: 0;
}
.mensaje-form button {
    flex-shrink: 0;
    width: auto;
}
.emoji-picker {
    display: none;
    position: absolute;
    bottom: 65px;
    left: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 250px;
    z-index: 100;
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    padding: 10px;
}
.emoji-grid span {
    cursor: pointer;
    text-align: center;
    font-size: 1.5em;
    transition: transform 0.1s;
}
.emoji-grid span:hover {
    transform: scale(1.2);
}

/* ============================================= */
/* --- ESTILOS PARA DISPOSITIVOS MÓVILES --- */
/* ============================================= */
@media (max-width: 768px) {

    body {
        padding-top: 10px; /* Reducimos el margen superior */
    }

    .contenedor {
        width: 100%;
        padding: 1rem;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
        box-sizing: border-box; /* Asegura que el padding no cause desbordamiento */
    }

    h2 {
        font-size: 1.5em;
    }

    /* --- Ajustes para el Lobby --- */
    .header-lobby {
        flex-direction: column;
        gap: 10px;
    }
    .sala-item {
        padding: 1rem;
    }
    .sala-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .contador-participantes {
        align-self: flex-end; /* Mueve el contador a la derecha */
    }


    /* --- La magia para la Sala de Chat --- */
    .sala-main {
        flex-direction: column; /* Apila el chat y los participantes verticalmente */
    }

    .chat-box {
        flex-grow: 1;
        height: 60vh; /* Ocupa la mayor parte de la pantalla */
    }

    .panel-lateral {
        flex-basis: auto; /* El alto se ajusta al contenido */
        height: 25vh; /* Un alto fijo para la lista de participantes */
        border-left: none;
        border-top: 2px solid #ddd;
        overflow-y: auto;
    }
    
    .sala-header {
        flex-wrap: wrap; /* Permite que los elementos se envuelvan */
        gap: 10px;
    }
    .sala-header h2 {
        font-size: 1.2rem;
        width: 100%; /* Ocupa todo el ancho */
        text-align: center;
    }
    .sala-header > div { /* El contenedor de los botones */
        margin: 0 auto; /* Centra los botones */
    }

    .controles-fuente span {
        display: none; /* Ocultamos el texto "Tamaño de texto" */
    }
}