/* --- GLOBAL & RESET --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #121212;
    color: white;
}

.full-view {
    height: 100%;
    width: 100%;
    display: flex;
}

/* --- LOGIN STYLES --- */
#login-screen {
    justify-content: center;
    align-items: center;
}

.login-box {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 12px;
    width: 350px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 15px 0;
}

.avatar-option {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    object-fit: cover;
    transition: 0.2s;
}

.avatar-option.selected {
    border-color: #5865F2;
    transform: scale(1.1);
}

#username-input, #password-input, #room-input {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    border-radius: 6px;
    border: none;
    background: #2c2c2c;
    color: white;
    outline: none;
}

#btn-connect {
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    background: #5865F2;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

#btn-connect:hover {
    background: #4752c4;
}

/* --- MAIN LAYOUT --- */
#chat-app {
    display: none;
}

.grid-container {
    display: grid;
    grid-template-columns: 200px 1fr;
    width: 100%;
    height: 100%;
    transition: grid-template-columns 0.3s ease;
}

.grid-container.sidebar-hidden {
    grid-template-columns: 0px 1fr;
}

/* Sidebar */
.sidebar {
    background: #1e1e1e;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

#users-list {
    list-style: none;
    padding: 10px;
    overflow-y: auto;
    flex-grow: 1;
}

/* --- NUEVA SECCIÓN: BOTONES INFERIORES SIDEBAR --- */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #333;
    background: #1a1a1a;
}

.footer-buttons {
    display: flex;
    gap: 8px; /* Espacio entre los dos botones */
}

.footer-buttons .logout-btn, 
.footer-buttons .tool-btn {
    flex: 1; /* Ambos botones ocupan el mismo ancho */
    padding: 8px 2px;
    font-size: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

/* Estilo específico para botón de sala (azul suave/grisáceo) */
.tool-btn.secondary {
    background: #4f545c;
    color: white;
}

.tool-btn.secondary:hover {
    background: #686d73;
}

/* --- MAIN CONTENT AREA --- */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.chat-header {
    padding: 11px 15px;
    background: #1e1e1e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.editor-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.editor-toolbar .tool-btn {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Editor Area */
.editor-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #282a36; /* Fondo Dracula */
}

.CodeMirror {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    height: 100% !important;
    width: 100% !important;
    font-family: 'Consolas', monospace;
    font-size: 15px;
}

/* Chat Panel */
#chat-collapsible {
    height: 40%;
    background: #121212;
    display: flex;
    flex-direction: column;
    transition: height 0.3s ease, opacity 0.2s;
    border-top: 2px solid #333;
}

#chat-collapsible.chat-hidden {
    height: 0;
    opacity: 0;
    overflow: hidden;
    border: none;
}

#messages-log {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.input-zone {
    padding: 15px;
    background: #1e1e1e;
    border-top: 1px solid #333;
}

.input-row {
    display: flex;
    gap: 10px;
}

#msg-input {
    flex: 1;
    padding: 8px 15px;
    border-radius: 20px;
    background: #232329;
    color: white;
    border: none;
    outline: none;
}

#btn-send {
    background: #5865F2;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0 20px;
    cursor: pointer;
}

/* UI ELEMENTS */
#lang-indicator {
    background: #3776ab;
    color: #000000;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid #ffde57;
}

.toggle-btn {
    background: transparent;
    border: 1px solid #444;
    color: #5865F2;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Ocultar botón de mostrar sidebar cuando el sidebar está visible */
.show-sidebar-btn {
    display: none;
}

.sidebar-hidden .show-sidebar-btn {
    display: inline-block;
}

.tool-btn {
    background: #333;
    color: #ddd;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: #44494f;
    color: white;
}

.logout-btn {
    background-color: #ed4245; /* Rojo Discord */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.logout-btn:hover {
    background-color: #c03537;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
}

.avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

/* Bubbles */
.message-row {
    display: flex;
    margin-bottom: 10px;
}

.own-message {
    justify-content: flex-end;
}

.bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    background: #2f3136;
    font-size: 0.9em;
}

.own-message .bubble {
    background: #5865F2;
}

.auth-switch {
    margin-top: 15px;
    font-size: 0.85em;
    color: #b9bbbe;
}

#link-switch {
    color: #5865F2;
    text-decoration: none;
    font-weight: bold;
}

#emoji-bar {
    margin-bottom: 8px;
    display: flex;
    gap: 5px;
}

.emoji-btn {
    background: #2c2c2c;
    border: none;
    color: white;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
}

/* --- LOBBY SCREEN STYLES --- */
#lobby-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #1a1a1a 0%, #121212 100%);
}

.lobby-box {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 12px;
    width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
    border: 1px solid #333;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}

/* Contenedor de las Cards */
#rooms-container {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr; /* Dos columnas de salas */
    gap: 15px;
    padding-right: 10px;
}

/* Estilo de las Cards de Sala */
.room-card {
    background: #2c2c2c;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.room-card:hover {
    background: #36393f;
    border-color: #5865F2;
    transform: translateY(-2px);
}

.room-card h4 {
    color: #5865F2;
    font-size: 1.1em;
}

.room-card p {
    font-size: 0.85em;
    color: #b9bbbe;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.room-card small {
    font-size: 0.75em;
    color: #72767d;
}

.lobby-footer {
    margin-top: 20px;
    text-align: center;
}

.link-btn {
    background: none;
    border: none;
    color: #ed4245;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9em;
}

/* --- MODAL STYLES --- */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content {
    background: #1e1e1e;
    padding: 25px;
    border-radius: 12px;
    width: 400px;
    border: 1px solid #444;
    box-shadow: 0 0 30px rgba(0,0,0,1);
}

.modal-content h3 {
    margin-bottom: 15px;
    color: white;
}

.modal-content input, 
.modal-content textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 6px;
    border: none;
    background: #2c2c2c;
    color: white;
    font-family: inherit;
    outline: none;
}

.modal-content textarea {
    height: 100px;
    resize: none;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Colores de botones específicos */
.tool-btn.success {
    background: #248046;
    color: white;
}
.tool-btn.success:hover {
    background: #1a6334;
}

.tool-btn.secondary {
    background: #4f545c;
}

/* Texto de carga */
.loading-text {
    grid-column: span 2;
    text-align: center;
    color: #72767d;
    padding: 40px;
}

/* Scrollbar personalizada para el lobby */
#rooms-container::-webkit-scrollbar {
    width: 6px;
}
#rooms-container::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

/* --- PROJETOS & FORM EXTENSIONS --- */

/* Etiquetas dentro de modales */
.modal-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85em;
    color: #b9bbbe;
    text-align: left;
}

/* Estilos para selectores (dropdowns) */
#select-project-choice, 
#select-import-project {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 6px;
    border: none;
    background: #2c2c2c;
    color: white;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    border: 1px solid #333;
}

#select-project-choice:focus, 
#select-import-project:focus {
    border-color: #5865F2;
}

/* Texto de información pequeña */
.small-info {
    font-size: 0.75em;
    color: #72767d;
    margin-bottom: 15px;
    text-align: left;
    font-style: italic;
}

/* Input para nombre de nuevo proyecto (condicional) */
#new-project-name-input {
    display: block; /* El JS controlará si se oculta o no */
    border: 1px dashed #5865F2 !important;
    background: #1a1a1a !important;
}

/* Agrupación de botones en el header del Lobby */
.header-btns {
    display: flex;
    gap: 10px;
}

/* Botón de éxito (Verde) */
.tool-btn.success {
    background: #248046;
    color: white;
}

.tool-btn.success:hover {
    background: #1a6334;
}

/* Animación simple para aparición de modales */
@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content {
    animation: modalFadeIn 0.3s ease-out;
}

/* --- PROJECTS MENU STYLES --- */
#projects-menu-modal .modal-content {
    max-width: 900px !important;
    max-height: 80vh !important;
    width: 900px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#projects-menu-modal .modal-content h3 {
    padding: 20px 25px;
    border-bottom: 1px solid #333;
    margin-bottom: 0;
    background: #16171b;
}

#projects-menu-modal .modal-content > div {
    display: flex;
    gap: 20px;
    padding: 20px;
    flex: 1;
    overflow: hidden;
}

/* Projects List Panel */
#projects-list {
    border-right: 1px solid #555;
    padding-right: 20px !important;
}

#projects-list h4 {
    color: #5865F2;
    margin-bottom: 15px;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#projects-list button {
    width: 100%;
    text-align: left;
    padding: 12px !important;
    border: 1px solid #555 !important;
    background: #2c2c2c !important;
    color: white !important;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    font-size: 13px;
}

#projects-list button:hover {
    background: #36393f !important;
    border-color: #5865F2 !important;
}

#projects-list button strong {
    display: block;
    color: #5865F2;
    margin-bottom: 4px;
}

#projects-list button small {
    color: #888;
    font-size: 0.8em;
}

/* Versions Panel */
#versions-section h4 {
    color: #5865F2;
    margin-bottom: 15px;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#versions-list {
    margin-bottom: 20px !important;
    padding-bottom: 15px;
    border-bottom: 1px solid #555;
}

#versions-list > div {
    padding: 12px !important;
    border: 1px solid #555 !important;
    background: #2c2c2c !important;
    margin-bottom: 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

#versions-list > div:hover {
    background: #36393f !important;
    border-color: #5865F2 !important;
}

#versions-list > div.active {
    background: #36393f !important;
    border-color: #5865F2 !important;
}

#versions-list > div > div:first-child strong {
    color: #5865F2;
    display: block;
    margin-bottom: 4px;
}

#versions-list > div > div:first-child small {
    color: #888;
    font-size: 0.8em;
}

#versions-list button {
    padding: 6px 12px !important;
    font-size: 0.85em !important;
}

#versions-list .tool-btn.success {
    background: #248046 !important;
}

#versions-list .tool-btn.success:hover {
    background: #1a6334 !important;
}

#versions-list .tool-btn.secondary {
    background: #4f545c !important;
}

#versions-list .tool-btn.secondary:hover {
    background: #686d73 !important;
}

/* Preview Area */
#version-preview {
    width: 100% !important;
    height: 150px !important;
    padding: 10px !important;
    border: 1px solid #555 !important;
    border-radius: 4px !important;
    background: #1e1e1e !important;
    color: #e0e0e0 !important;
    font-family: 'Consolas', monospace !important;
    resize: none !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
}

#version-preview::-webkit-scrollbar {
    width: 8px;
}

#version-preview::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

#no-selection {
    color: #888;
    text-align: center;
    padding-top: 50px;
}

/* Modal Buttons */
#projects-menu-modal .modal-buttons {
    padding: 20px;
    border-top: 1px solid #333;
    background: #16171b;
    justify-content: flex-end;
}

#projects-menu-modal .modal-buttons button {
    padding: 10px 20px !important;
}

/* Scrollbars for projects and versions list */
#projects-list {
    overflow-y: auto !important;
    scrollbar-width: thin;
    scrollbar-color: #555 #2c2c2c;
}

#projects-list::-webkit-scrollbar {
    width: 6px;
}

#projects-list::-webkit-scrollbar-track {
    background: #2c2c2c;
}

#projects-list::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

#versions-list {
    scrollbar-width: thin;
    scrollbar-color: #555 #2c2c2c;
}

.versions-section {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #555 #2c2c2c;
}

/* --- REMOTE CURSORS & SELECTION STYLES --- */

.CodeMirror-cursor {
    border-left: 2px solid #5865F2;
}

.remote-cursor-label {
    position: relative;
    display: inline-block;
    margin-right: 2px;
    pointer-events: none;
    z-index: 100;
}

/* Selection marker styling handled inline with dynamic color */