/**
 * Chat Widget Styles
 * Brightboy Child Theme - Copilot Studio Integration
 */

/* Chat Widget Base Font */
#chat-widget-button,
#chat-widget-popup,
#chat-widget-container,
#chat-widget-popup *,
#chat-widget-container * {
    font-family: "ibm-plex-sans", Sans-serif;
}

/* Chat Icon Button */
#chat-widget-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: #BD1D23;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(189, 29, 35, 0.3);
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: 2px;
    cursor: pointer;
    z-index: 999998;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
}

#chat-widget-button:hover {
    background-color: #A01721;
    box-shadow: 0 6px 20px rgba(189, 29, 35, 0.4);
    outline-color: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
}

#chat-widget-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* Chat Popup */
#chat-widget-popup {
    position: fixed;
    bottom: 20px;
    right: 110px;
    width: 315px;
    height: 80px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 999997;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: visible;
    border: 1px solid #e0e0e0;
}

#chat-widget-popup.hide {
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
}

#chat-popup-content {
    display: flex;
    align-items: center;
    padding: 16px;
    height: 100%;
    position: relative;
}

#chat-popup-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
    flex-shrink: 0;
}

#chat-popup-text {
    flex: 1;
    min-width: 0;
}

#chat-popup-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    margin-bottom: 2px;
}

#chat-popup-message {
    font-size: 14px;
    color: #666;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
}

#chat-popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-popup-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #666;
}

#chat-popup-close svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* Triangle pointer */
#chat-widget-popup::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -10px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid white;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}

#chat-widget-popup::before {
    content: '';
    position: absolute;
    top: 50%;
    right: -11px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 11px solid #e0e0e0;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
}

/* Chat Window Container */
#chat-widget-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

#chat-widget-container.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
#chat-widget-header {
    background: linear-gradient(to right, #bd1d23, #570d10);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

#chat-widget-title {
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

#chat-widget-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-widget-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#chat-widget-close svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Chat Content */
#chat-widget-content {
    height: calc(100% - 64px);
    position: relative;
}

#chat-widget-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Loading State */
#chat-widget-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #666;
}

#chat-widget-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #BD1D23;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #chat-widget-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
    
    #chat-widget-button svg {
        width: 24px;
        height: 24px;
    }
    
    #chat-widget-popup {
        bottom: 10px;
        right: 86px;
        width: calc(100vw - 126px);
        max-width: 280px;
    }
    
    #chat-widget-popup::after {
        right: -8px;
        border-left: 8px solid white;
        border-top: 8px solid transparent;
        border-bottom: 8px solid transparent;
    }
    
    #chat-widget-popup::before {
        right: -9px;
        border-left: 9px solid #e0e0e0;
        border-top: 9px solid transparent;
        border-bottom: 9px solid transparent;
    }
    
    #chat-widget-container {
        bottom: 90px;
        right: 20px;
        left: 20px;
        width: auto;
        height: 70vh;
        max-height: 500px;
    }
}

@media (max-width: 480px) {
    #chat-widget-popup {
        width: calc(100vw - 106px);
        max-width: 260px;
    }
    
    #chat-widget-popup::after {
        right: -6px;
        border-left: 6px solid white;
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
    }
    
    #chat-widget-popup::before {
        right: -7px;
        border-left: 7px solid #e0e0e0;
        border-top: 7px solid transparent;
        border-bottom: 7px solid transparent;
    }
    
    #chat-widget-container {
        bottom: 90px;
        right: 20px;
        left: 20px;
        width: auto;
        height: 75vh;
        max-height: 570px;
        border-radius: 8px;
    }
    
    #chat-widget-header {
        padding: 12px 16px;
    }
    
    #chat-widget-title {
        font-size: 15px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    #chat-widget-button,
    #chat-widget-container,
    #chat-widget-close {
        transition: none;
    }
    
    #chat-widget-loading .spinner {
        animation: none;
    }
}

/* Focus states for keyboard navigation */
#chat-widget-button:focus {
    outline-color: rgba(255, 255, 255, 1);
    outline-width: 3px;
}

#chat-widget-close:focus {
    outline: 2px solid #ffffff;
    outline-offset: 1px;
}

/* Hide on specific page */
body.page-id-10206 #chat-widget-button,
body.page-id-10206 #chat-widget-popup,
body.page-id-10206 #chat-widget-container {
    display: none !important;
}