/* ======================== ESTILOS DEL WIDGET DE CHAT ======================== */

/* Contenedor principal del widget de chat */
.chat-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 997;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Botón flotante del chat */
.chat-floating-button {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: var(--Gray-00);
    border: 1px solid var(--Gray-55);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 997;
    padding: 5px 10px;
}

.chat-floating-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: var(--Primary-50);
}

.chat-floating-button:active {
    transform: scale(0.95);
}

.chat-floating-button svg {
    width: 30px;
    height: 30px;
    stroke: var(--Primary-50);
    stroke-width: 2;
    fill: none;
}

/* Widget del chat */
.chat-widget {
    position: absolute;
    bottom: 50px;
    right: 0;
    background-color: var(--Gray-00);
    border-radius: 24px;
    border: 1px solid var(--Gray-55);
    width: 398px;
    height: 650px;
    min-width: 398px;
    min-height: 625px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header del chat */
.chat-widget-header {
    background: var(--Gray-00);
    color: var(--Primary-100);
    padding: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    font-weight: bold;
    font-size: 18px;
    border-bottom: 1px solid var(--Gray-55);
}

.chat-widget-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    flex: 1;
}

.chat-widget-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: var(--Primary-100);
}

.chat-widget-subtitle {
    font-size: 14px;
    font-weight: 600;
    color: var(--Gray-75);
    margin: 0;
}

.chat-widget-hours {
    font-size: 12px;
    font-weight: normal;
    color: var(--Gray-70);
    margin: 0;
    text-align: justify;
}

.chat-widget-controls {
    display: flex;
    gap: 8px;
}

.chat-widget-btn {
    background: rgba(8, 99, 120, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--Primary-100);
    font-size: 16px;
    transition: all 0.3s ease;
}

.chat-widget-btn:hover {
    background: rgba(8, 99, 120, 0.2);
    transform: scale(1.1);
}

.chat-widget-btn:active {
    transform: scale(0.95);
}

.chat-widget-btn i {
    pointer-events: none;
}

/* Pestañas */
.chat-tabs {
    display: flex;
    background: var(--Gray-20);
    border-bottom: 1px solid var(--Gray-55);
    padding: 8px;
    gap: 8px;
}

.chat-tab {
    flex: 1;
    padding: 10px 16px;
    background: var(--Gray-20);
    border: 1px solid var(--Gray-40);
    border-radius: 8px;
    color: var(--Gray-70);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.chat-tab.active {
    background: var(--Success-25);
    color: var(--Primary-100);
    border-color: var(--Primary-100);
    font-weight: 600;
}

.chat-tab:hover {
    background: var(--Gray-30);
    border-color: var(--Gray-60);
}

.chat-tab.active:hover {
    background: #E8F5E8;
    border-color: var(--Primary-100);
}

/* Body del chat */
.chat-widget-body {
    height: calc(100% - 180px);
    padding: 16px;
    position: relative;
}

.chat-content {
    display: none;
    height: 100%;
}

.chat-content.active {
    display: block;
}

/* Contenedor del iframe */
.chat-container {
    background: var(--Gray-00);
    border: 1px solid var(--Gray-40);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 16px;
    height: calc(100% - 140px);
    overflow: hidden;
}

.chat-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    display: block;
    position: relative;
    /* Mejorar compatibilidad móvil */
    -webkit-overflow-scrolling: touch;
    overflow: auto;
    /* Asegurar que el iframe sea interactivo */
    pointer-events: auto;
    /* Mejorar rendimiento */
    will-change: auto;
    /* Eliminar cualquier restricción de selección */
    -webkit-user-select: auto;
    user-select: auto;
    /* Asegurar que los eventos táctiles funcionen */
    touch-action: auto;
}

/* Contenido de contactos */
.contacts-content {
    padding: 16px;
    height: 100%;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--Gray-30);
    cursor: pointer;
    transition: all 0.3s ease;
}

.contact-item:last-child {
    border-bottom: none;
}

.contact-item:hover {
    background: var(--Gray-20);
    border-radius: 8px;
    padding-left: 8px;
    padding-right: 8px;
}

.contact-item svg {
    width: 20px;
    height: 20px;
    stroke: var(--Primary-100);
    stroke-width: 2;
    fill: none;
}

.contact-item span {
    color: var(--Gray-90);
    font-weight: 500;
}

/* Footer del chat */
.chat-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--Gray-20);
    padding: 12px 16px;
    border-top: 1px solid var(--Gray-55);
    font-size: 11px;
    color: var(--Gray-70);
    text-align: justify;
    line-height: 1.4;
    z-index: 10;
    min-height: 80px;
    display: block;
}

.chat-footer a {
    color: var(--Primary-100);
    text-decoration: none;
    font-weight: 600;
}

.chat-footer a:hover {
    text-decoration: underline;
}

.chat-footer strong {
    font-weight: bold;
    color: var(--Gray-90);
    display: inline;
}

.chat-footer .terms-link {
    color: var(--Primary-100);
    font-weight: 600;
    text-decoration: none;
    display: inline;
}

.chat-footer .terms-link:hover {
    text-decoration: underline;
}

/* ======================== VISTAS DEL CHAT ======================== */

/* Vista principal del chat */
.chat-main-view {
    display: block;
    height: 100%;
}

.chat-full-view {
    display: none !important;
    height: 100%;
}

/* Cuando la vista principal está activa, ocultar la vista de términos */
.chat-main-view.active {
    display: block !important;
}

.chat-main-view.active ~ .chat-full-view {
    display: none !important;
}

/* Cuando la vista de términos está activa, ocultar la vista principal */
.chat-full-view.active {
    display: block !important;
}

.chat-full-view.active ~ .chat-main-view,
.chat-full-view.active ~ .chat-main-view.active {
    display: none !important;
}

/* Asegurar que las vistas se muestren correctamente */
#chatMainView.active {
    display: block !important;
}

#termsContent.active {
    display: block !important;
}

/* Regla específica para ocultar la vista principal cuando términos está activo */
#termsContent.active ~ #chatMainView,
#termsContent.active ~ #chatMainView.active {
    display: none !important;
}

/* ======================== TÉRMINOS Y CONDICIONES ======================== */

/* Contenido de términos y condiciones */
.terms-content {
    height: calc(100% - 80px); /* Restar altura del header */
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.terms-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--Gray-30);
}

.terms-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: var(--Primary-100);
}

.terms-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
    margin-bottom: 20px;
}

.terms-body p {
    margin-bottom: 16px;
    line-height: 1.6;
    color: var(--Gray-80);
    text-align: justify;
    font-size: 14px;
}

.terms-footer {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--Gray-30);
}

.back-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--Gray-00);
    color: var(--Primary-100);
    border: 1px solid var(--Primary-100);
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 90%;
    max-width: 300px;
    margin: 0 auto;
}

.back-button:hover {
    background: var(--Primary-100);
    color: var(--Gray-00);
    transform: translateY(-1px);
}

.back-button:active {
    transform: translateY(0);
}

.back-button svg {
    width: 16px;
    height: 16px;
}

/* ======================== RESPONSIVE ======================== */

/* Responsive para dispositivos móviles (768px y menos) */
@media (max-width: 768px) {
    .chat-widget-container {
        bottom: 20px;
        right: 20px;
    }

    .chat-widget {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        min-width: 320px;
        min-height: 500px;
        bottom: 50px;
        border-radius: 20px;
    }
    
    .chat-floating-button {
        width: 40px;
        height: 40px;
    }
    
    .chat-floating-button svg {
        width: 24px;
        height: 24px;
    }

    .chat-tabs {
        border-radius: 0;
        padding: 6px;
        gap: 6px;
    }

    .chat-tab {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 6px;
    }

    .contacts-content {
        padding: 12px;
    }

    .contact-item {
        padding: 10px 0;
        font-size: 14px;
    }

    .chat-footer {
        padding: 10px 12px;
        font-size: 10px;
    }

    /* Estilos para términos y condiciones en móviles */
    .terms-content {
        padding: 12px;
        height: calc(100% - 70px); /* Ajustar para header más pequeño en móvil */
    }

    .terms-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }

    .terms-header h3 {
        font-size: 16px;
    }

    .terms-body {
        padding: 0 4px;
        margin-bottom: 16px;
    }

    .terms-body p {
        font-size: 13px;
        margin-bottom: 12px;
    }

    .terms-footer {
        padding-top: 12px;
    }

    .back-button {
        padding: 10px 16px;
        font-size: 13px;
        width: 95%;
        max-width: 280px;
    }

    .back-button svg {
        width: 14px;
        height: 14px;
    }

    /* Estilos específicos para el iframe en móviles */
    .chat-iframe {
        pointer-events: auto !important;
        touch-action: auto !important;
        -webkit-user-select: auto !important;
        user-select: auto !important;
        overflow: visible !important;
        -webkit-overflow-scrolling: touch !important;
        /* Asegurar que el iframe sea completamente interactivo */
        position: relative !important;
        z-index: 1 !important;
    }

    .chat-container {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 16px;
        height: calc(100% - 140px);
    }
}

/* Responsive para móviles pequeños (480px y menos) */
@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 15px;
        right: 15px;
    }

    .chat-widget {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        min-width: 280px;
        min-height: 400px;
        bottom: 50px;
        border-radius: 16px;
    }
    
    .chat-floating-button {
        width: 36px;
        height: 36px;
    }
    
    .chat-floating-button svg {
        width: 20px;
        height: 20px;
    }

    .chat-tab {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 6px;
    }

    .chat-container {
        padding: 10px;
        margin-bottom: 10px;
        border-radius: 14px;
        height: calc(100% - 140px);
    }

    .contacts-content {
        padding: 10px;
    }

    .contact-item {
        padding: 8px 0;
        font-size: 13px;
    }

    .chat-footer {
        padding: 8px 10px;
        font-size: 9px;
    }

    /* Estilos para términos y condiciones en móviles pequeños */
    .terms-content {
        padding: 10px;
        height: calc(100% - 65px);
    }

    .terms-header {
        margin-bottom: 12px;
        padding-bottom: 8px;
    }

    .terms-header h3 {
        font-size: 15px;
    }

    .terms-body {
        padding: 0 2px;
        margin-bottom: 12px;
    }

    .terms-body p {
        font-size: 12px;
        margin-bottom: 10px;
    }

    .terms-footer {
        padding-top: 8px;
    }

    .back-button {
        padding: 8px 12px;
        font-size: 12px;
        width: 95%;
        max-width: 260px;
    }

    .back-button svg {
        width: 12px;
        height: 12px;
    }
}

/* Responsive para móviles muy pequeños (360px y menos) */
@media (max-width: 360px) {
    .chat-widget-container {
        bottom: 10px;
        right: 10px;
    }

    .chat-widget {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        min-width: 260px;
        min-height: 350px;
        bottom: 45px;
        border-radius: 12px;
    }
    
    .chat-floating-button {
        width: 32px;
        height: 32px;
    }
    
    .chat-floating-button svg {
        width: 18px;
        height: 18px;
    }

    .chat-tab {
        padding: 6px 8px;
        font-size: 12px;
    }

    .contacts-content {
        padding: 8px;
    }

    .contact-item {
        padding: 6px 0;
        font-size: 12px;
    }

    .chat-footer {
        padding: 6px 8px;
        font-size: 8px;
    }

    /* Estilos para términos y condiciones en móviles muy pequeños */
    .terms-content {
        padding: 8px;
        height: calc(100% - 60px);
    }

    .terms-header {
        margin-bottom: 10px;
        padding-bottom: 6px;
    }

    .terms-header h3 {
        font-size: 14px;
    }

    .terms-body {
        padding: 0;
        margin-bottom: 10px;
    }

    .terms-body p {
        font-size: 11px;
        margin-bottom: 8px;
    }

    .terms-footer {
        padding-top: 6px;
    }

    .back-button {
        padding: 6px 10px;
        font-size: 11px;
        width: 95%;
        max-width: 240px;
    }

    .back-button svg {
        width: 10px;
        height: 10px;
    }
}

/* Manejo de orientación landscape en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-widget {
        height: calc(100vh - 80px);
        min-height: 300px;
    }

    .chat-widget-header {
        padding: 8px 12px;
        font-size: 14px;
    }

    .chat-widget-btn {
        width: 28px;
        height: 28px;
    }

    .chat-tab {
        padding: 5px 8px;
        font-size: 11px;
        border-radius: 5px;
    }

    .chat-container {
        padding: 6px;
        margin-bottom: 6px;
        border-radius: 12px;
        height: calc(100% - 140px);
    }

    .contacts-content {
        padding: 6px;
    }

    .contact-item {
        padding: 4px 0;
        font-size: 11px;
    }

    .chat-footer {
        padding: 5px 8px;
        font-size: 8px;
    }

    /* Estilos para términos y condiciones en landscape */
    .terms-content {
        padding: 6px;
        height: calc(100% - 55px);
    }

    .terms-header {
        margin-bottom: 8px;
        padding-bottom: 4px;
    }

    .terms-header h3 {
        font-size: 13px;
    }

    .terms-body {
        padding: 0;
        margin-bottom: 8px;
    }

    .terms-body p {
        font-size: 10px;
        margin-bottom: 6px;
    }

    .terms-footer {
        padding-top: 4px;
    }

    .back-button {
        padding: 4px 8px;
        font-size: 10px;
        width: 95%;
        max-width: 220px;
    }

    .back-button svg {
        width: 8px;
        height: 8px;
    }
} 