/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Contenedor principal del chat */
.chat-container {
    width: 100%;
    max-width: 400px;
    height: 100vh;
    max-height: 800px;
    background: white;
    border-radius: 0;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

/* Header del chat */
.chat-header {
    background: white;
    color: #1F2937;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.agent-avatar {
    width: 32px;
    height: 32px;
    background: #E5E7EB;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #6B7280;
    overflow: hidden;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.agent-details h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
    color: #1F2937;
}

.status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    background: #10B981;
    color: white;
    border: none;
}

.status.online {
    background: #10B981;
    color: white;
}

.btn-reset {
    background: #F3F4F6;
    border: none;
    color: #6B7280;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-reset:hover {
    background: #E5E7EB;
    color: #374151;
}

/* Área de mensajes */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #F5F5F5;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
}

.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;
}

/* Mensajes */
.message {
    display: flex;
    gap: 6px;
    max-width: 80%;
    animation: slideIn 0.3s ease-out;
    align-items: flex-end;
}

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

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
}

.agent-message {
    align-self: flex-start;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    overflow: hidden;
}

.user-message .message-avatar {
    background: #c7251a;
    color: white;
}

.agent-message .message-avatar {
    background: #E5E7EB;
    color: #6B7280;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.user-message .message-content {
    align-items: flex-end;
}

.agent-message .message-content {
    align-items: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.4;
}

.user-message .message-bubble {
    background: #c7251a;
    color: white;
    border-bottom-right-radius: 5px;
}

.agent-message .message-bubble {
    background: #E5E7EB;
    color: #1F2937;
    border: none;
    border-bottom-left-radius: 5px;
    box-shadow: none;
}

.message-time {
    font-size: 12px;
    color: #9ca3af;
    padding: 0 5px;
}

/* Área de entrada */
.chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #E5E7EB;
}

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

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #989898;
    border-radius: 12px;
    opacity: 1;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    background: #F3F4F6;
}

#messageInput:focus {
    background: white;
    box-shadow: 0 0 0 2px rgba(227, 6, 19, 0.1);
}

.btn-send {
    width: 40px;
    height: 40px;
    background: #DA291C;
    border: none;
    border-radius: 40%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.send-icon {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
    transition: all 0.3s ease;
}

.btn-send:hover {
    background: #C41E3A;
    transform: scale(1.05);
}

.btn-send:hover .send-icon {
    transform: scale(1.1);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    text-align: center;
    margin-top: 10px;
}

.input-footer small {
    color: #9ca3af;
    font-size: 12px;
}

/* Loading indicator - estilo WhatsApp */
.typing-indicator {
    display: none;
}

.typing-indicator.show {
    display: flex;
}

.typing-indicator .message {
    margin-bottom: 16px;
}

.typing-indicator .message-bubble {
    background: #F3F4F6;
    padding: 12px 16px;
    border-radius: 18px;
    border-top-left-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #9CA3AF;
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite both;
}

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

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

.typing-indicator-text {
    font-size: 11px;
    color: #9CA3AF;
    margin-left: 8px;
    font-style: italic;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .chat-container {
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .agent-details h3 {
        font-size: 16px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .chat-input-container {
        padding: 12px;
    }
}

/* Animaciones adicionales */
.message-bubble p {
    margin: 0;
    font-size: 14px;
}

/* Estilos para tarjetas de productos */
.products-container {
    margin: 12px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.products-header {
    margin-bottom: 12px;
}

.products-title {
    font-size: 16px;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 6px 0;
}

.products-subtitle {
    font-size: 13px;
    color: #6B7280;
    margin: 0;
    margin-bottom: 12px;
}

.products-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.product-card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #E5E7EB;
    display: flex;
    flex-direction: row;
    gap: 12px;
    width: 100%;
    min-width: 0;
    transition: all 0.3s ease;
    align-items: flex-start;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.product-image-container {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 10px;
    overflow: hidden;
    background: #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-image:hover {
    transform: scale(1.05);
}

.product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
}

.product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    box-sizing: border-box;
    width: 100%;
}

.product-title {
    font-size: 14px;
    font-weight: 600;
    color: #1F2937;
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-description {
    font-size: 12px;
    color: #6B7280;
    margin: 0;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    text-align: left;
    white-space: normal;
}

.product-price-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.product-price-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
}

.product-price {
    font-size: 16px;
    font-weight: 700;
    color: #E30613;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.product-original-price {
    font-size: 12px;
    color: #9ca3af;
    text-decoration: line-through;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.product-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.btn-ver-mas {
    background: #B52217;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
    box-sizing: border-box;
    max-width: 120px;
}

.btn-ver-mas:hover {
    background: #C41E3A;
    transform: translateY(-1px);
}

.product-details-btn {
    background: #DA291C;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
    min-width: 120px;
    max-width: 200px;
    flex-shrink: 0;
}

.product-details-btn:hover {
    background: #C41E3A;
    transform: translateY(-1px);
}

/* Media queries para diferentes tamaños de pantalla */

/* Pantallas de escritorio grandes */
@media (min-width: 1200px) {
    .product-card {
        max-width: 100%;
        padding: 14px;
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }
    
    .product-image-container {
        width: 100%;
        height: 160px;
        margin-bottom: 12px;
    }
    
    .product-content {
        width: 100%;
        align-items: stretch;
    }
    
    .product-info {
        align-items: stretch;
        text-align: left;
    }
    
    .product-title {
        font-size: 14px;
        text-align: left;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .product-description {
        font-size: 12px;
        text-align: left;
        line-height: 1.4;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
    }
    
    .product-price-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        margin-top: 8px;
    }
    
    .product-price {
        font-size: 14px;
    }
    
    .product-actions {
        justify-content: flex-end;
        flex-shrink: 0;
    }
    
    .btn-ver-mas {
        padding: 6px 12px;
        font-size: 11px;
        white-space: nowrap;
    }
}

/* Pantallas de escritorio medianas */
@media (min-width: 769px) and (max-width: 1199px) {
    .product-card {
        max-width: 100%;
        padding: 14px;
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }
    
    .product-image-container {
        width: 100%;
        height: 150px;
        margin-bottom: 12px;
    }
    
    .product-content {
        width: 100%;
        align-items: stretch;
    }
    
    .product-info {
        align-items: stretch;
        text-align: left;
    }
    
    .product-title {
        font-size: 14px;
        text-align: left;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .product-description {
        font-size: 12px;
        text-align: left;
        line-height: 1.4;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
    }
    
    .product-price-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        margin-top: 8px;
    }
    
    .product-price {
        font-size: 14px;
    }
    
    .product-actions {
        justify-content: flex-end;
        flex-shrink: 0;
    }
    
    .btn-ver-mas {
        padding: 6px 12px;
        font-size: 11px;
        white-space: nowrap;
    }
}

/* Pantallas de tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .product-card {
        flex-direction: column;
        padding: 14px;
        align-items: stretch;
        text-align: left;
    }
    
    .product-image-container {
        width: 100%;
        height: 140px;
        margin-bottom: 12px;
    }
    
    .product-content {
        width: 100%;
        align-items: stretch;
    }
    
    .product-info {
        align-items: stretch;
        text-align: left;
    }
    
    .product-title {
        font-size: 14px;
        text-align: left;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .product-description {
        font-size: 12px;
        text-align: left;
        line-height: 1.4;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
    }
    
    .product-price-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        margin-top: 8px;
    }
    
    .product-price {
        font-size: 14px;
    }
    
    .product-actions {
        justify-content: flex-end;
        flex-shrink: 0;
    }
    
    .btn-ver-mas {
        padding: 6px 12px;
        font-size: 11px;
        white-space: nowrap;
    }
}

/* Responsive para pantallas pequeñas */
@media (max-width: 480px) {
    .product-card {
        flex-direction: column;
        padding: 12px;
        align-items: stretch;
        text-align: left;
    }
    
    .product-image-container {
        width: 100%;
        height: 140px;
        margin-bottom: 12px;
    }
    
    .product-content {
        width: 100%;
        align-items: stretch;
    }
    
    .product-info {
        align-items: stretch;
        text-align: left;
    }
    
    .product-title {
        font-size: 14px;
        text-align: left;
    }
    
    .product-description {
        font-size: 11px;
        line-height: 1.4;
        text-align: left;
    }
    
    .product-price-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }
    
    .product-price {
        font-size: 14px;
    }
    
    .product-actions {
        justify-content: flex-end;
    }
    
    .product-details-btn,
    .btn-ver-mas {
        padding: 6px 12px;
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .products-list {
        gap: 10px;
    }
    
    .product-card {
        padding: 10px;
    }
    
    .product-title {
        font-size: 13px;
    }
    
    .product-description {
        font-size: 11px;
        line-height: 1.4;
    }
    
    .product-price {
        font-size: 13px;
    }
    
    .product-price-footer {
        gap: 6px;
    }
    
    .btn-ver-mas {
        padding: 5px 10px;
        font-size: 10px;
    }
}

/* Forzar recarga del CSS - Actualizado 11:35 */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #9ca3af;
    font-style: italic;
}

/* Estados de hover y focus mejorados */
.btn-reset:focus,
.btn-send:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

/* Mejoras de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.error-message {
    color: #dc2626;
    font-weight: 500;
    padding: 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin: 0;
}

/* Estilos para el botón Comenzar */
.btn-comenzar {
    position: relative;
    margin-top: 20px;
    width: 100%;
    max-width: 253px;
    height: 40px;
    background: var(--da291c-rojo-600-botón) 0% 0% no-repeat padding-box;
    background: #DA291C 0% 0% no-repeat padding-box;
    border-radius: 100px;
    opacity: 1;
    border: none;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    font-size: 16px;
}

.btn-comenzar:disabled {
    background: #b9b9b9;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-comenzar:hover:not(:disabled) {
    background: #C41E3A;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(218, 41, 28, 0.3);
}

.btn-comenzar:active:not(:disabled) {
    transform: translateY(0);
}

/* Responsive para pantalla de inicio */
@media (max-width: 480px) {
    .btn-comenzar {
        width: 90%;
        max-width: 280px;
    }
}

@media (max-height: 700px) {
    .btn-comenzar {
        margin-top: 16px;
        height: 38px;
        font-size: 14px;
    }
}

@media (max-height: 600px) {
    .btn-comenzar {
        margin-top: 12px;
        height: 36px;
        font-size: 14px;
    }
}
