:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --bg-main: #0d0d0d;
    --bg-card: #171717;
    --bg-input: #212121;
    --user-msg: #2f2f2f;
    --bot-msg: transparent;
    --text-main: #ececec;
    --text-sub: #b4b4b4;
    --border-color: rgba(255, 255, 255, 0.1);
    --error-red: #f87171;
}


body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}


.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-main);
}

.login-card {
    background-color: #000000;
    padding: 40px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-card p.subtitle {
    color: var(--text-sub);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.login-card input {
    width: 100%;
    box-sizing: border-box;
    background-color: var(--bg-input);
    border: 1px solid #424242;
    color: white;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.login-card input:focus {
    border-color: var(--primary-color);
}

.login-card button {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.2s;
}

.login-card button:hover {
    opacity: 0.9;
}


.header {
    background: var(--bg-main);
    color: var(--text-main);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.btn-logout {
    background: transparent;
    color: var(--text-sub);
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}


#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.msg {
    max-width: 800px;
    width: 100%;
    line-height: 1.6;
    font-size: 1rem;
    word-wrap: break-word;
    border-radius: 20px;
}

.user {
    align-self: flex-end;
    background: var(--user-msg);
    padding: 12px 20px;
    border-radius: 20px;
    max-width: 70%;
    width: fit-content;
}

.bot {
    align-self: flex-start;
    color: var(--text-main);
    background-color: #252525;
}


.fuentes {
    margin-top: 15px;
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.fuente-item {
    margin-top: 10px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.fuente-header {
    background: #171717;
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.8rem;
}

.fuente-content {
    display: none;
    padding: 15px;
    font-size: 0.85rem;
    color: var(--text-sub);
    background: #000;
    border-top: 1px solid var(--border-color);
}


.feedback-container {
    display: flex;
    gap: 12px;
    margin-top: 15px;
}

.btn-feedback {
    background: transparent;
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.btn-feedback svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.btn-feedback:hover {
    color: white;
    border-color: white;
}

.btn-feedback.active-like {
    color: #10b981;
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.btn-feedback.active-dislike {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.latencia-info {
    font-size: 0.7rem;
    color: var(--text-sub);
    display: block;
    margin-top: 10px;
    opacity: 0.6;
}


.input-area {
    padding: 20px;
    background: var(--bg-main);
    display: flex;
    justify-content: center;
}

.input-area select, .input-area input {
    background: transparent;
    color: white;
    border: none;
    outline: none;
    font-size: 1rem;
}


.input-area {
    border-top: none;
}

#categoria, #pregunta, #btn-enviar {

}


.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: none;
    z-index: 9998;
}

.modal-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    z-index: 9999;
    display: none;
    flex-direction: column;
    width: 90%;
    max-width: 500px;
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-body {
    padding: 24px;
}

.modal-feedback textarea {
    width: 100%;
    background: #2f2f2f;
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 12px;
    padding: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    margin-bottom: 20px;
    resize: none;
}

.chip {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-sub);
    margin: 0 8px 8px 0;
    display: inline-block;
}

.chip.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}


.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}


.bot p {
    margin-top: 0;
}

.bot code {
    background: #2f2f2f;
    padding: 2px 5px;
    border-radius: 4px;
}


:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --bg-main: #0d0d0d;
    --bg-input: #212121;
    --user-msg: #2f2f2f;
    --text-main: #ececec;
    --text-sub: #b4b4b4;
    --border-color: rgba(255, 255, 255, 0.1);
}


#chat-box::-webkit-scrollbar {
    width: 8px;
}

#chat-box::-webkit-scrollbar-track {
    background: var(--bg-main);
}

#chat-box::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 10px;
}

#chat-box::-webkit-scrollbar-thumb:hover {
    background: #555;
}


body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header {
    background: var(--bg-main);
    color: var(--text-main);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}


#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}


.msg.user {
    align-self: flex-end;
    background: var(--user-msg);
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 70%;
    width: fit-content;
    margin-left: auto;
    color: var(--text-main);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}


.msg.bot {
    align-self: flex-start;
    width: 100%;
    max-width: 800px;
    padding: 20px;
}


.fuente-item {
    margin-top: 10px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.fuente-header {
    background: #171717;
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
}

.fuente-content {
    display: none;
    padding: 15px;
    font-size: 0.85rem;
    background: #000;
    color: var(--text-sub);
    border-top: 1px solid var(--border-color);
}


.feedback-container {
    display: flex;
    gap: 12px;
    margin-top: 15px;
}

.btn-feedback {
    background: transparent;
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: var(--text-sub);
}

.btn-feedback svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.btn-feedback:hover {
    color: white;
    border-color: white;
}

.btn-feedback.active-like {
    color: #10b981;
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.btn-feedback.active-dislike {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}


.input-area {
    padding: 20px;
    background: var(--bg-main);
    display: flex;
    justify-content: center;
}

.input-capsule {
    max-width: 800px;
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 8px 16px;
}

.input-capsule select {
    background: transparent;
    color: var(--text-sub);
    border: none;
    border-right: 1px solid var(--border-color);
    outline: none;
    padding-right: 10px;
    margin-right: 10px;
}

.input-capsule input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    padding: 10px;
}

.input-capsule button {
    background: white;
    color: black;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-weight: bold;
}


.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}




.input-capsule select {
    background: transparent;
    color: var(--text-sub);
    border: none;
    border-right: 1px solid var(--border-color);
    outline: none;
    padding-right: 10px;
    margin-right: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
}


.input-capsule select option {
    background-color: #171717;
    color: #ececec;
    padding: 12px;
}


.input-capsule select option:hover,
.input-capsule select option:focus,
.input-capsule select option:active {
    background-color: #2f2f2f !important;
}



.loading span {
    animation: pulseText 1.5s ease-in-out infinite;
}

@keyframes pulseText {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}


.input-area {
    padding: 20px;
    background: var(--bg-main);
    display: flex;
    justify-content: center;
    border-top: none;
}


.modal-header {
    background: #171717;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    background: #171717;
}

.modal-feedback textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    resize: vertical;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
    background-color: #2f2f2f;
    transition: border-color 0.2s;
    outline: none;
    margin-bottom: 15px;
}

.modal-feedback textarea:focus {
    border-color: var(--primary-color);
}

.modal-feedback p {
    font-size: 0.8rem;
    font-weight: bold;
    margin: 0 0 8px 0;
    color: var(--text-sub);
}

.msg.bot.loading {
    background-color: transparent; !important;
}