/* --- Estilos Base --- */
body { background-color: #1a1a1a; color: #f0f0f0; font-family: sans-serif; margin: 0; padding: 20px; }
.container { max-width: 900px; margin: 0 auto; }
h1, h2 { color: #00aaff; }
.main-title { font-size: 28px; text-align: center; margin-bottom: 30px; }
button { background-color: #00aaff; color: #fff; border: none; padding: 10px 15px; border-radius: 4px; cursor: pointer; font-size: 16px; margin-top: 10px; }
button:hover { background-color: #0088cc; }
.hidden { display: none !important; }

/* --- Autenticación --- */
.main-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #444; padding-bottom: 10px; margin-bottom: 20px; }
.main-header h1 { margin: 0; font-size: 24px; }
#welcomeUser { margin-right: 15px; }
#logoutBtn { background-color: #555; margin-top: 0; }
#logoutBtn:hover { background-color: #c44; }
#authContainer { max-width: 400px; }
#authContainer form { margin-top: 20px; padding: 20px; background-color: #2a2a2a; border-radius: 8px; }
#authContainer input { width: 100%; padding: 12px; margin-bottom: 15px; background-color: #333; color: #f0f0f0; border: 1px solid #555; border-radius: 4px; box-sizing: border-box; }
#authContainer p { text-align: center; margin-top: 15px; }
#authContainer a { color: #00aaff; cursor: pointer; text-decoration: none; }
#authContainer a:hover { text-decoration: underline; }
.error-message { color: #ff4d4d; background-color: rgba(255, 77, 77, 0.1); border: 1px solid #ff4d4d; padding: 10px; border-radius: 4px; margin-bottom: 15px; text-align: center; }

/* --- Loading Overlay --- */
#loading {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); display: flex;
    justify-content: center; align-items: center; z-index: 2000;
}


#chapterText {
    width: 90%;
}
#singleProjectView {
    max-width: 900px;
    margin: 0 auto;
}

#resultsContainer {
    margin-top: 30px;
    padding: 20px;
    background-color: #2a2a2a;
    border-radius: 4px;
}

.character-item {
    padding: 10px;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
}

.character-item:last-child {
    border-bottom: none;
}

.character-item input {
    margin-right: 15px;
    width: 18px;
    height: 18px;
}

.character-item .name {
    font-weight: bold;
    flex-grow: 1;
}

.character-item .status {
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.status.new {
    background-color: #2a623d;
}

.status.existing {
    background-color: #3b5b8d;
}

.hidden {
    display: none !important; /* Usamos !important para asegurar que se aplique */
}

#chatSelectionContainer {
    margin-top: 40px;
}

#chatCharacterList {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.character-chat-button {
    background-color: #333;
    color: #f0f0f0;
    border: 1px solid #555;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s, color 0.2s;
}

.character-chat-button:hover {
    background-color: #00aaff;
    color: #fff;
    border-color: #00aaff;
}



#chatWindow {
    max-width: 800px;
    margin: 20px auto;
    border: 1px solid #444;
    border-radius: 8px;
    display: flex;
     /* display: none; */
    flex-direction: column;
    height: 70vh; /* Ocupa el 70% de la altura de la ventana */
    background-color: #2a2a2a;
}

#chatWindow.hidden {
    display: none !important;
}
#chatHeader {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: #333;
    border-bottom: 1px solid #444;
}

#backButton {
    background: none;
    border: none;
    color: #00aaff;
    font-size: 24px;
    cursor: pointer;
    margin: 0;
    padding: 0 15px 0 0;
}

#chatCharacterName {
    margin: 0;
    font-size: 18px;
}

#messageList {
    flex-grow: 1;
    overflow-y: auto; /* Permite scroll */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 70%;
    line-height: 1.4;
}

.message.user {
    background-color: #007acc;
    color: #fff;
    align-self: flex-end; /* A la derecha */
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background-color: #444;
    color: #f0f0f0;
    align-self: flex-start; /* A la izquierda */
    border-bottom-left-radius: 4px;
}

#chatFooter {
    display: flex;
    padding: 10px;
    border-top: 1px solid #444;
}

#messageInput {
    flex-grow: 1;
    border: 1px solid #555;
    background-color: #333;
    color: #fff;
    padding: 10px;
    border-radius: 20px;
    margin-right: 10px;
}

#sendMessageButton {
    margin-top: 0;
    border-radius: 50%; /* Botón redondo */
    width: 45px;
    height: 45px;
    padding: 0;
    font-size: 20px; /* Puedes usar un icono SVG aquí en el futuro */
}

.message.assistant.typing span {
    display: inline-block;
    animation: bounce 1.4s infinite;
    opacity: 0;
}

.message.assistant.typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.message.assistant.typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}


/* --- ESTILOS DE LISTA DE PROYECTOS --- */
#projectListView {
    max-width: 900px;
}

#projectList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.project-card {
    background-color: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #444;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 170, 255, 0.2);
}

.project-card-image {
    width: 100%;
    height: 150px;
    background-color: #333;
    background-size: cover;
    background-position: center;
}

.project-card-content {
    padding: 15px;
}

.project-card-content h3 {
    margin: 0 0 10px 0;
    color: #00aaff;
}

.project-card-content p {
    margin: 0;
    font-size: 14px;
    color: #ccc;
    line-height: 1.4;
}

#createProjectForm {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #444;
}

#createProjectForm input, #createProjectForm textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #2a2a2a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 4px;
    box-sizing: border-box;
}

.project-header {
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: 900px;
    margin: 0 auto 20px auto;
}

.project-header button {
    margin-top: 0;
    font-size: 24px;
    background: none;
    border: none;
    color: #00aaff;
    cursor: pointer;
}

/* --- ESTILOS DEL MODAL DE EDICIÓN --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    border: 1px solid #555;
}

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

.modal-header h2 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #aaa;
    cursor: pointer;
}

#editProfileForm label {
    display: block;
    margin-bottom: 5px;
    color: #ccc;
}

#editProfileForm input,
#editProfileForm textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    background-color: #333;
    color: #f0f0f0;
    border: 1px solid #555;
    border-radius: 4px;
    box-sizing: border-box;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid #444;
}

.modal-footer button {
    margin-top: 0;
}

.modal-footer #cancelEditBtn {
    background-color: #555;
}
.modal-footer #cancelEditBtn:hover {
    background-color: #666;
}

/* Ajuste para añadir botón de editar */
.character-chat-button-container {
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: #333;
    border: 1px solid #555;
    border-radius: 20px;
    padding: 0;
    padding-left: 20px; /* Espacio para el nombre */
}

.character-chat-button-container .character-name {
    flex-grow: 1;
    cursor: pointer;
    padding: 10px 0;
}

.edit-char-btn {
    background: #444;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    border-radius: 0 20px 20px 0;
    padding: 10px 15px;
    height: 100%;
}
.edit-char-btn:hover {
    background: #00aaff;
}