/* Chat Section Styles */
.chat-section {
    padding: 150px 0 150px;
    background: var(--tp-common-black);
    position: relative;
    overflow: hidden;
}

.chat-buttons {
    display: flex;
    width: 40%;
    height: 50px;
    padding: 70px 10px 15px 9px;
    justify-content: space-between;
    margin: auto;
    align-items: center;
    flex-shrink: 0;
}

.button {
    padding: 10px 20px;
    border-radius: 33px;
    border: 1px solid #252525;
    background: #FAFAFA;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.button-color {
    background-color: #36C18F;
    color: #fff;
}

.chat-section > .chat-container {
    position: relative;
    z-index: 2;
}

.chat-container {
    width: 100%;
    max-width: 1000px;
    height: 600px;
    background: linear-gradient(230deg, #FFC906 0%, #EF5095 25%, #8E58A4 50%, #36C18F 100%);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    position: relative;
    padding: 5px;
}

.chat-container::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    z-index: 0;
    overflow: hidden;
}

.chat-container > * {
    position: relative;
    z-index: 1;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: -100px;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    overflow-y: auto;
}

.modal-container {
    background: #0E0F11;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 20px 30px 30px;
    margin: 20px;
    /* Hide scrollbar but allow scrolling */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.modal-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.modal-close-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    z-index: 10;
}

.modal-close-btn img {
    width: 24px;
    height: 24px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.modal-close-btn:hover img {
    opacity: 1;
}

.modal-header {
    text-align: center;
    padding-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 34px; /* Same height as close button */
}

.modal-logo {
    max-width: 180px;
    height: auto;
    opacity: 0.2;
}

.modal-title {
    color: #ffffff;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.3;
}

.modal-divider {
    width: 80%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 auto 25px;
}

.modal-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 30px;
}

.modal-text p {
    margin-bottom: 15px;
    color: #B8BCC8;
}

.modal-understand-btn {
    background: #36C18F;
    color: #ffffff;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: block;
    margin: 0 auto;
    transition: background 0.3s ease;
}

.modal-understand-btn:hover {
    background: #2ea876;
    transform: translateY(-2px);
}

/* Modal Subtitle Styles */
.modal-subtitle {
    color: #B8BCC8;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 20px;
    text-align: center;
}

/* Highlight Text Styles */
.highlight-text {
    color: #E5E7EB;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        padding: 30px 20px 20px;
        margin: 20px;
    }
    
    .modal-title {
        font-size: 20px;
    }
    
    .modal-text {
        font-size: 14px;
    }
    
    .modal-logo {
        max-width: 150px;
    }
}

/* Chat Header */
.chat-header {
    background:#FFC906;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px 15px 0 0;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-logo {
    display: flex;
    align-items: center;
}

.chat-logo-img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

.chat-title {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.chat-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin: 4px 0 0 0;
    line-height: 1.2;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8fafc;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Message Bubbles */
.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
    margin: 8px 0;
    transition: all 0.2s ease;
    word-wrap: break-word;
    line-height: 1.5;
    width: fit-content;
}

.message-bubble:hover {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.message-bubble.user {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message-bubble.assistant {
    display: flex;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Estilos para mensajes multi-parte */
.message-bubble.assistant.multi-part {
    margin-bottom: 8px; /* Menos espacio entre partes */
}

.message-bubble.assistant.multi-part:not(:last-of-type) {
    margin-bottom: 4px; /* Aún menos espacio entre partes consecutivas */
}

.message-bubble.system {
    background: #f3f4f6;
    color: #374151;
    border-radius: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin: 0 auto;
    text-align: center;
    font-size: 14px;
}

/* Audio Message Styles */
.audio-message {
    display: flex;
    align-items: center;
    gap: 12px;
}

.audio-play-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-bubble.user .audio-play-button {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.message-bubble.user .audio-play-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.message-bubble.assistant .audio-play-button {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.message-bubble.assistant .audio-play-button:hover {
    background: rgba(59, 130, 246, 0.2);
}

.audio-play-button svg {
    width: 20px;
    height: 20px;
}

.audio-text {
    flex: 1;
    font-size: 14px;
}

/* Loading Indicator */
.chat-loading {
    padding: 0 24px 16px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-text {
    font-size: 14px;
    color: #64748b;
    margin-left: 8px;
}

/* Chat Input Container */
.chat-input-container {
    padding: 20px 24px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 15px 15px;
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input {
    flex: 1;
    min-height: 48px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
    background: #f8fafc;
    resize: none;
    overflow-y: auto;
    line-height: 1.5;
    font-family: inherit;
    word-wrap: break-word;
    white-space: pre-wrap;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.chat-input::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}

.chat-input:focus {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-input::placeholder {
    color: #9ca3af;
}

/* Buttons */
.send-button,
.audio-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.send-button,
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.send-button:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

.audio-button {
    background: #f3f4f6;
    color: #6b7280;
    border: 2px solid #e5e7eb;
}

.audio-button:hover {
    background: #e5e7eb;
    color: #374151;
}

.audio-button.recording {
    background: #ef4444;
    color: #ffffff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.send-icon,
.mic-icon {
    width: 20px;
    height: 20px;
}

/* Markdown Content */
.message-content {
    line-height: 1.6;
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message-bubble.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-bubble.user .message-content pre {
    background: rgba(255, 255, 255, 0.1);
}

/* Responsive Design */
@media (max-width: 991px) {
    .chat-container {
        width: 80%;
    }
}

@media (max-width: 768px) {
    .chat-section {
        padding: 140px 30px;
        min-height: calc(100vh - 40px);
    }
    
    .chat-container {
        width: 100%;
        margin: 0 10px;
        border-radius: 20px;
    }
    
    .chat-container::before {
        border-radius: 15px; /* Mantener consistencia con el interior */
    }
    
    .chat-header {
        padding: 16px 20px;
        border-radius: 3px 3px 0 0;
    }
    
    .chat-title {
        font-size: 16px;
    }
    
    .chat-subtitle {
        font-size: 13px;
    }
    
    .chat-messages {
        padding: 16px;
        gap: 12px;
    }
    
    .message-bubble {
        max-width: 85%;
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .chat-input-container {
        padding: 16px 20px;
    }
    
    .chat-input {
        min-height: 44px;
        max-height: 100px;
        font-size: 16px;
    }
    
    .send-button,
    .audio-button {
        width: 44px;
        height: 44px;
    }
    
    .chat-buttons {
        width: 70%;
        padding: 60px 10px 15px 10px;
    }
    
    .button {
        padding: 11px 16px;
        font-size: 15px;
        white-space: nowrap;
    }
}

@media (max-width: 500px) {
    .chat-input-container {
        padding: 16px 12px; /* Reducir padding lateral para dar más espacio */
    }
    
    .chat-input {
        padding: 10px 14px; /* Reducir padding interno para más espacio de texto */
    }
    
    .chat-input-wrapper {
        gap: 8px;
    }
    
    /* Ocultar botón de audio cuando se está escribiendo */
    .chat-input-wrapper.typing .audio-button {
        display: none;
    }
    
    /* Reducir gap cuando se oculta el botón de audio */
    .chat-input-wrapper.typing {
        gap: 6px;
    }
    
    /* Ajuste sutil cuando el teclado está visible */
    .keyboard-visible .chat-input-container {
        position: sticky;
        bottom: 0;
        z-index: 100;
        margin-bottom: -20px;
    }
}

/* Audio Recording Interface */
.audio-recording-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    min-height: 48px;
}

.cancel-recording-button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cancel-recording-button:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.cancel-recording-button svg {
    width: 18px;
    height: 18px;
}

.recording-status {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recording-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.recording-text {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.recording-timer {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
    font-family: monospace;
}

#recording-time {
    font-weight: 600;
    color: #ef4444;
}

.recording-limit {
    color: #9ca3af;
}

.recording-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.play-recorded-button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.play-recorded-button:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.play-recorded-button svg {
    width: 16px;
    height: 16px;
    margin-left: 2px;
}

.send-audio-button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #10b981;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-audio-button:hover {
    background: #059669;
    transform: scale(1.05);
}

.send-audio-button svg {
    width: 20px;
    height: 20px;
}

.pause-recording-button {
    width: 40px;
    height: 40px;
    background: #ff4757;
    border: none;
    border-radius: 50%;
    color: white !important;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    box-sizing: border-box;
}

.pause-recording-button:hover {
    background: #ff3742;
    transform: scale(1.05);
}

.play-recorded-button {
    width: 32px;
    height: 32px;
    background: #2ed573;
    border: none;
    border-radius: 50%;
    color: white !important;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    box-sizing: border-box;
}

.play-recorded-button:hover {
    background: #26d467;
    transform: scale(1.05);
}

.play-recorded-button.playing {
    background: #ff6b6b;
}

.play-recorded-button.playing:hover {
    background: #ff5757;
}

/* Ensure SVG icons are properly centered */
.pause-recording-button svg,
.play-recorded-button svg {
    display: block;
    margin: auto;
    pointer-events: none;
}

/* Responsive adjustments for audio recording */
@media (max-width: 500px) {
    .audio-recording-wrapper {
        gap: 8px;
        padding: 10px 12px;
    }
    
    .cancel-recording-button {
        width: 32px;
        height: 32px;
    }
    
    .cancel-recording-button svg {
        width: 16px;
        height: 16px;
    }
    
    .recording-text {
        font-size: 13px;
    }
    
    .recording-timer {
        font-size: 11px;
    }
    
    .play-recorded-button {
        width: 32px;
        height: 32px;
    }
    
    .play-recorded-button svg {
        width: 14px;
        height: 14px;
    }
    
    .send-audio-button {
        width: 36px;
        height: 36px;
    }
    
    .send-audio-button svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .chat-container {
        margin: 0px;
        border-radius: 8px;
    }
    
    .chat-container::before {
        border-radius: 3px; /* 8px - 5px padding */
    }

    .chat-buttons {
        width: 90%;
        padding: 50px 10px 15px 10px;
        gap: 10px;
    }
    
    .button {
        flex: 1;
        padding: 12px 8px;
        font-size: 14px;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        min-width: 0;
    }
    
    .chat-header-content {
        gap: 12px;
    }
    
    .chat-logo-img {
        width: 32px;
        height: 32px;
    }
    
    .message-bubble {
        max-width: 90%;
        padding: 8px 12px;
    }
    
    .chat-input-container {
        padding: 16px 8px; /* Aún menos padding en pantallas muy pequeñas */
    }
    
    .chat-input {
        padding: 8px 12px; /* Padding mínimo para pantallas muy pequeñas */
    }
}

/* Connection Error Styles */
.connection-error-message {
    background: rgba(255, 255, 255, 0.95);
    color: #374151;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 8px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    animation: slideInFromTop 0.3s ease-out;
    max-width: fit-content;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.connection-error-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-error-icon {
    font-size: 16px;
    opacity: 0.9;
}

.retry-button {
    background: #3b82f6;
    color: white;
    border: 1px solid #2563eb;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: normal;
}

.retry-button:hover {
    background: #2563eb;
    border-color: #1d4ed8;
    transform: translateY(-1px);
}

.retry-button:active {
    transform: translateY(0);
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments for connection error */
@media (max-width: 768px) {
    .connection-error-message {
        margin: 8px 12px;
        padding: 12px 16px;
    }
    
    .connection-error-content {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .retry-button {
        align-self: center;
        padding: 6px 12px;
    }
}