/**
 * AI eShop Chat - Frontend Styles
 * Oxford Metadata Blue Theme 💙
 *
 * @package AI_eShop_Chat
 */

/* Chat Wrapper */
.aieo-chat-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    max-width: 95vw;
    margin: 0 auto;
}

/* Chat Container */
.aieo-chat-container {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(3, 22, 60, 0.15);
    overflow: hidden;
    border: 1px solid rgba(3, 22, 60, 0.1);
}

/* Header */
.aieo-chat-header {
    background: #03163C;
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(3, 22, 60, 0.3);
}

.aieo-chat-avatar {
    font-size: 2.5em;
    line-height: 1;
}

.aieo-chat-title {
    flex: 1;
    font-size:14px;
}

.aieo-chat-title strong {
    display: block;
    font-size: 1.3em;
    margin-bottom: 3px;
}

.aieo-chat-status {
    font-size: 0.85em;
    opacity: 0.9;
}

/* Messages Area */
.aieo-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #F9FAFB;
    min-height: 0; /* Important: allows flex to shrink below content size */
}

/* Individual Message */
.aieo-chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

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

.aieo-chat-message-user {
    flex-direction: row-reverse;
}

.aieo-chat-avatar-small {
    width: 36px;
    height: 36px;
    background: #03163C;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    flex-shrink: 0;
}

.aieo-chat-message-user .aieo-chat-avatar-small {
    background: #47ACFE;
}

.aieo-chat-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 70%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    line-height: 1.5;
}

.aieo-chat-message-user .aieo-chat-message-content {
    background: #47ACFE;
    color: white;
}

/* Typing Indicator */
.aieo-chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.aieo-chat-typing-dots span {
    width: 8px;
    height: 8px;
    background: #03163C;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

.aieo-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.7;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* Products Display */
.aieo-chat-products {
    margin: 20px 0;
    display: grid;
    gap: 15px;
}

.aieo-chat-product {
    background: white;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    gap: 15px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(3, 22, 60, 0.1);
    transition: all 0.3s ease;
}

.aieo-chat-product:hover {
    box-shadow: 0 4px 20px rgba(3, 22, 60, 0.2);
    transform: translateY(-2px);
}

.aieo-chat-product-image {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #F3F4F6;
}

.aieo-chat-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aieo-chat-product-details {
    flex: 1;
}

.aieo-chat-product-details h4 {
    margin: 0 0 8px 0;
    font-size: 1.1em;
}

.aieo-chat-product-details h4 a {
    color: #1F2937;
    text-decoration: none;
    transition: color 0.2s;
}

.aieo-chat-product-details h4 a:hover {
    color: #47ACFE;
}

.aieo-chat-product-price {
    font-size: 1.2em;
    font-weight: bold;
    color: #03163C;
    margin-bottom: 8px;
}

.aieo-chat-product-details p {
    color: #6B7280;
    font-size: 0.9em;
    margin: 8px 0;
}

.aieo-chat-product-rating {
    font-size: 0.9em;
    color: #6B7280;
    margin: 8px 0;
}

.aieo-chat-product-stock {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    margin: 8px 0;
}

.aieo-out-of-stock {
    background: #FEE2E2;
    color: #DC2626;
}

.aieo-on-sale {
    background: #DCFCE7;
    color: #16A34A;
    margin-bottom: 12px;
}

.aieo-chat-product-btn {
    display: inline-block;
    background: #03163C;
    color: white !important;
    padding: 8px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(3, 22, 60, 0.3);
}

.aieo-chat-product-btn:hover {
    background: #47ACFE;
    box-shadow: 0 4px 12px rgba(3, 22, 60, 0.5);
    transform: translateY(-1px);
}

/* Input Area */
.aieo-chat-input-area {
    background: white;
    padding: 20px 20px 20px 20px;
    border-top: 1px solid #E5E7EB;
    flex-shrink: 0; /* Important: prevents input area from being hidden */
}

.aieo-chat-terms {
    font-size: 0.75em;
    line-height: 1.4;
    color: #9CA3AF;
    text-align: center;
    margin-bottom: 12px;
    margin-top: 0;
    padding: 0 10px;
}

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

.aieo-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 24px;
    font-size: 1em;
    outline: none;
    transition: all 0.3s ease;
}

.aieo-chat-input:focus {
    border-color: #47ACFE;
    box-shadow: 0 0 0 3px rgba(71, 172, 254, 0.1);
}

.aieo-chat-send-btn {
    width: 48px;
    height: 48px;
    background: #03163C;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(3, 22, 60, 0.3);
}

.aieo-chat-send-btn:hover:not(:disabled) {
    background: #47ACFE;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(3, 22, 60, 0.5);
}

.aieo-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading State */
.aieo-chat-loading {
    text-align: center;
    padding: 40px;
    color: #6B7280;
    font-size: 1.1em;
}

/* Error State */
.aieo-chat-error {
    background: #FEE2E2;
    color: #DC2626;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .aieo-chat-container {
        border-radius: 0;
        height: 100vh !important;
    }

    .aieo-chat-message-content {
        max-width: 85%;
    }

    .aieo-chat-product {
        flex-direction: column;
    }

    .aieo-chat-product-image {
        width: 100%;
        height: 200px;
    }
}

/* Scrollbar Styling */
.aieo-chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

.aieo-chat-messages::-webkit-scrollbar-thumb {
    background: #03163C;
    border-radius: 4px;
}

.aieo-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #47ACFE;
}

/* ========================================
   FLOATING CHAT WIDGET STYLES
   ======================================== */

/* Floating Trigger Button */
.aieo-floating-trigger {
    position: fixed;
    width: 60px;
    height: 60px;
    background: #03163C;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(3, 22, 60, 0.4);
    transition: all 0.3s ease;
    z-index: 999998;
}

.aieo-floating-trigger.bottom-right {
    bottom: 20px;
    right: 20px;
}

.aieo-floating-trigger.bottom-left {
    bottom: 20px;
    left: 20px;
}

.aieo-floating-trigger.bottom-centre {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.aieo-floating-trigger.bottom-centre:hover {
    transform: translateX(-50%) scale(1.1);
}

.aieo-floating-trigger.top-right {
    top: 100px;
    right: 20px;
}

.aieo-floating-trigger.top-left {
    top: 100px;
    left: 20px;
}

.aieo-floating-trigger:hover {
    background: #47ACFE;
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(3, 22, 60, 0.6);
}

.aieo-floating-trigger svg {
    width: 28px;
    height: 28px;
}

/* Welcome Bubble */
.aieo-floating-welcome-bubble {
    position: fixed;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    max-width: 250px;
    z-index: 999997;
    animation: aieo-bubble-appear 0.3s ease-out;
    cursor: pointer;
}

.aieo-floating-welcome-bubble.hidden {
    display: none;
}

/* Desktop positions for welcome bubble */
.aieo-floating-welcome-bubble.bottom-right {
    bottom: 90px;
    right: 20px;
}

.aieo-floating-welcome-bubble.bottom-left {
    bottom: 90px;
    left: 20px;
}

.aieo-floating-welcome-bubble.bottom-centre {
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
}

.aieo-floating-welcome-bubble-content {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.aieo-floating-welcome-bubble-arrow {
    position: absolute;
    bottom: -8px;
    right: 25px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

/* Position arrow for bottom-left */
.aieo-floating-welcome-bubble.bottom-left .aieo-floating-welcome-bubble-arrow {
    right: auto;
    left: 25px;
}

/* Position arrow for bottom-centre */
.aieo-floating-welcome-bubble.bottom-centre .aieo-floating-welcome-bubble-arrow {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

/* Mobile-specific positions */
@media (max-width: 768px) {
    .aieo-floating-welcome-bubble.mobile-bottom-right {
        bottom: 90px;
        right: 20px;
        left: auto;
        transform: none;
    }

    .aieo-floating-welcome-bubble.mobile-bottom-left {
        bottom: 90px;
        left: 20px;
        right: auto;
        transform: none;
    }

    .aieo-floating-welcome-bubble.mobile-bottom-centre {
        bottom: 90px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    /* Mobile arrow positioning */
    .aieo-floating-welcome-bubble.mobile-bottom-right .aieo-floating-welcome-bubble-arrow {
        right: 25px;
        left: auto;
        transform: none;
    }

    .aieo-floating-welcome-bubble.mobile-bottom-left .aieo-floating-welcome-bubble-arrow {
        left: 25px;
        right: auto;
        transform: none;
    }

    .aieo-floating-welcome-bubble.mobile-bottom-centre .aieo-floating-welcome-bubble-arrow {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}

@keyframes aieo-bubble-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Floating Chat Window */
.aieo-floating-chat-window {
    position: fixed;
    width: 400px;
    max-width: calc(100vw - 40px) !important;
    height: 600px;
    max-height: calc(100vh - 100px) !important;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
}

.aieo-floating-chat-window.bottom-right {
    bottom: 40px;
    right: 20px;
}

.aieo-floating-chat-window.bottom-left {
    bottom: 40px;
    left: 20px;
}

.aieo-floating-chat-window.bottom-centre {
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

.aieo-floating-chat-window.top-right {
    top: 80px;
    right: 20px;
}

.aieo-floating-chat-window.top-left {
    top: 80px;
    left: 20px;
}

.aieo-floating-chat-window .aieo-chat-header {
    background: #03163C;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(3, 22, 60, 0.3);
    flex-shrink: 0; /* Important: keeps header always visible */
}

.aieo-floating-chat-window .aieo-chat-header h3 {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
}

.aieo-chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px !important;
    height: 32px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 10px;
}

.aieo-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.aieo-floating-chat-window .aieo-chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Important: allows flex to shrink */
    margin: 0; /* Remove auto margin that centers content */
    max-width: none; /* Remove max-width constraint */
    width: 100%; /* Fill the floating window width */
}

.aieo-floating-chat-window .aieo-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Important: allows flex to shrink */
}

.aieo-floating-chat-window .aieo-chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* Important: allows flex to shrink below content size */
}

.aieo-floating-chat-window .aieo-chat-input-area {
    flex-shrink: 0; /* Important: prevents input area from being hidden */
}

/* Mobile Responsive Floating Widget */
@media (max-width: 768px) {
    .aieo-floating-trigger {
        width: 56px;
        height: 56px;
    }

    .aieo-floating-trigger svg {
        width: 24px;
        height: 24px;
    }

    /* Mobile positioning for trigger button - overrides desktop position */
    .aieo-floating-trigger.mobile-bottom-right {
        bottom: 10px !important;
        right: 15px !important;
        left: auto !important;
        transform: none !important;
    }

    .aieo-floating-trigger.mobile-bottom-left {
        bottom: 10px !important;
        left: 15px !important;
        right: auto !important;
        transform: none !important;
    }

    .aieo-floating-trigger.mobile-bottom-centre {
        bottom: 10px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }

    /* Mobile positioning for chat window - overrides desktop position */
    .aieo-floating-chat-window {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        height: calc(100vh - 80px) !important;
        max-height: calc(100vh - 80px) !important;
        top: auto !important;
        border-radius: 12px;
    }

    .aieo-floating-chat-window.mobile-bottom-right {
        bottom: 10px !important;
        right: 10px !important;
        left: auto !important;
        transform: none !important;
    }

    .aieo-floating-chat-window.mobile-bottom-left {
        bottom: 10px !important;
        left: 10px !important;
        right: auto !important;
        transform: none !important;
    }

    .aieo-floating-chat-window.mobile-bottom-centre {
        bottom: 10px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }
}

/* Persistent Category Menu */
.aieo-chat-category-menu {
    background: #f9f9f9;
    border-bottom: 2px solid #e0e0e0;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Category Selection Bubbles */
.aieo-chat-category-bubbles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.aieo-chat-category-bubble {
    background: #03163C;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(3, 22, 60, 0.2);
    white-space: nowrap;
}

.aieo-chat-category-bubble:hover {
    background: #45B1E8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(69, 177, 232, 0.3);
}

.aieo-chat-category-bubble:active {
    transform: translateY(0);
}

/* Highlighted category bubble (current page category) */
.aieo-chat-category-bubble-highlight {
    background: #45B1E8 !important;
    box-shadow: 0 4px 12px rgba(69, 177, 232, 0.4) !important;
    transform: scale(1.05);
}

.aieo-chat-category-selection .aieo-chat-message-content p {
    margin-bottom: 10px;
}

/* Category link styling */
.aieo-chat-message-content a {
    color: #45B1E8;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.aieo-chat-message-content a:hover {
    color: #03163C;
    text-decoration: underline;
}
