/* AI Flooring Chatbot Styles */

:root {
    /* Light mode (default) */
    --aifc-bg-primary: #ffffff;
    --aifc-bg-secondary: #f9fafb;
    --aifc-bg-tertiary: #f0f0f0;
    --aifc-text-primary: #1a1a1a;
    --aifc-text-secondary: #6b7280;
    --aifc-border: #e5e7eb;
    --aifc-bot-message-bg: #f0f0f0;
    --aifc-user-message-bg: var(--aifc-primary-color, #4F46E5);
}

/* Dark mode overrides - applied via JavaScript when enabled */
#aifc-chat-widget.aifc-dark-mode {
    --aifc-primary-color: var(--aifc-dark-primary-color);
    --aifc-bg-primary: var(--aifc-dark-bg-primary);
    --aifc-bg-secondary: var(--aifc-dark-bg-secondary);
    --aifc-bg-tertiary: var(--aifc-dark-bg-tertiary);
    --aifc-text-primary: var(--aifc-dark-text-primary);
    --aifc-text-secondary: var(--aifc-dark-text-secondary);
    --aifc-border: var(--aifc-dark-border);
    --aifc-bot-message-bg: var(--aifc-dark-bot-message-bg);
    --aifc-user-message-bg: var(--aifc-dark-user-message-bg);
}

#aifc-chat-widget {
    position: fixed;
    bottom: 20px;
    z-index: 2147483647;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#aifc-chat-widget.aifc-position-right {
    right: 20px;
}

#aifc-chat-widget.aifc-position-left {
    left: 20px;
}

/* Chat Button */
.aifc-chat-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--aifc-primary-color, #4F46E5);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16), 0 0 1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

.aifc-chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
}

.aifc-chat-button svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.aifc-chat-button.aifc-chat-open svg {
    transform: rotate(180deg);
}

/* Chat Window */
.aifc-chat-window {
    position: absolute;
    bottom: 80px;
    width: 400px;
    height: 700px;
    max-height: calc(100vh - 120px);
    background: var(--aifc-bg-primary);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

#aifc-chat-widget.aifc-position-right .aifc-chat-window {
    right: 0;
}

#aifc-chat-widget.aifc-position-left .aifc-chat-window {
    left: 0;
}

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

/* Header */
.aifc-chat-header {
    background: var(--aifc-primary-color, #4F46E5);
    color: var(--aifc-header-text-color, #FFFFFF);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 52px;
}

.aifc-chat-header-content h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.3;
    color: inherit;
}

.aifc-chat-header-content p {
    margin: 2px 0 0 0;
    font-size: 11px;
    opacity: 0.8;
    font-weight: 400;
    color: inherit;
}

.aifc-back-button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--aifc-header-text-color, #FFFFFF);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 12px;
}

.aifc-back-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.aifc-back-button svg {
    color: inherit;
}

.aifc-close-button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--aifc-header-text-color, #FFFFFF);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 12px;
}

.aifc-close-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.aifc-close-button svg {
    color: inherit;
}

/* Home Screen */
.aifc-home-screen {
    flex: 1;
    overflow-y: auto;
    background: var(--aifc-bg-primary);
    display: flex;
    flex-direction: column;
}

.aifc-home-hero {
    padding: 40px 24px 32px;
    text-align: center;
    background: var(--aifc-bg-primary);
}

.aifc-home-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 16px;
    background: var(--aifc-primary-color, #4F46E5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.aifc-home-icon svg {
    color: white;
    width: 32px;
    height: 32px;
}

.aifc-home-title {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--aifc-text-primary);
    line-height: 1.3;
}

.aifc-home-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--aifc-text-secondary);
    font-weight: 400;
}

.aifc-home-actions {
    flex: 1;
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aifc-home-ask-button {
    width: 100%;
    padding: 16px 20px;
    background: var(--aifc-bg-primary);
    border: 1px solid var(--aifc-border);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    text-align: left;
}

.aifc-home-ask-button:hover {
    border-color: var(--aifc-primary-color, #4F46E5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.aifc-home-ask-content span {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--aifc-text-primary);
    margin-bottom: 2px;
}

.aifc-home-ask-content p {
    margin: 0;
    font-size: 13px;
    color: var(--aifc-text-secondary);
}

.aifc-home-ask-button svg {
    color: #9ca3af;
    flex-shrink: 0;
}

.aifc-suggested-questions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aifc-suggested-question {
    width: 100%;
    padding: 14px 16px;
    background: var(--aifc-bg-secondary);
    border: 1px solid var(--aifc-border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--aifc-text-primary);
    text-align: left;
    transition: all 0.2s ease;
    font-weight: 500;
}

.aifc-suggested-question:hover {
    background: var(--aifc-bg-tertiary);
    border-color: var(--aifc-primary-color, #4F46E5);
    color: var(--aifc-text-primary);
}

/* Messages */
.aifc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--aifc-bg-primary);
}

.aifc-message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-out;
}

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

.aifc-message-bot {
    justify-content: flex-start;
}

.aifc-message-user {
    justify-content: flex-end;
}

.aifc-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--aifc-primary-color, #4F46E5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 12px;
}

.aifc-message-user .aifc-message-avatar {
    background: #6b7280;
    margin-right: 0;
    margin-left: 12px;
    order: 2;
}

.aifc-message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
}

.aifc-message-bot .aifc-message-content {
    background: var(--aifc-bot-message-bg);
    color: var(--aifc-text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--aifc-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.aifc-message-user .aifc-message-content {
    background: var(--aifc-user-message-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.aifc-form-container {
    max-width: 85% !important;
    background: var(--aifc-bg-primary) !important;
    border: 1px solid var(--aifc-border);
    padding: 16px !important;
}

/* Suggestion Buttons */
.aifc-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    margin-left: 44px;
    max-width: 75%;
}

.aifc-suggestion-button {
    padding: 10px 14px;
    background: var(--aifc-bg-primary);
    border: 1px solid var(--aifc-border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--aifc-text-primary);
    text-align: left;
    transition: all 0.2s ease;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.aifc-suggestion-button:hover {
    background: var(--aifc-bg-secondary);
    border-color: var(--aifc-primary-color, #4F46E5);
    color: var(--aifc-text-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Typing Indicator */
.aifc-typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--aifc-bot-message-bg);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 75%;
}

.aifc-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.aifc-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.aifc-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Input Container */
.aifc-chat-input-container {
    padding: 16px 20px;
    background: var(--aifc-bg-primary);
    border-top: 1px solid var(--aifc-border);
    display: flex;
    align-items: flex-end;
    position: relative;
}

.aifc-chat-input {
    flex: 1;
    border: 1px solid var(--aifc-border);
    border-radius: 20px;
    padding: 10px 16px;
    padding-right: 50px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: all 0.2s ease;
    line-height: 1.4;
    background: var(--aifc-bg-primary);
    color: var(--aifc-text-primary);
}

.aifc-chat-input:focus {
    outline: none;
    border-color: #c0c0c0;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.aifc-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--aifc-primary-color, #4F46E5);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    position: absolute;
    right: 22px;
    bottom: 18px;
}

.aifc-send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.aifc-send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.aifc-send-button svg {
    width: 18px;
    height: 18px;
}

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

.aifc-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.aifc-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Reset positioning for mobile */
    #aifc-chat-widget {
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
    }

    /* Chat button respects position setting on mobile */
    .aifc-chat-button {
        position: fixed;
        bottom: 20px;
        z-index: 2147483647;
    }

    #aifc-chat-widget.aifc-position-right .aifc-chat-button {
        right: 20px;
        left: auto;
    }

    #aifc-chat-widget.aifc-position-left .aifc-chat-button {
        left: 20px;
        right: auto;
    }

    /* Hide chat button when window is open on mobile */
    .aifc-chat-window[style*="display: flex"] ~ .aifc-chat-button {
        display: none;
    }

    /* Full screen chat window on mobile */
    .aifc-chat-window {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
        animation: slideUpMobile 0.3s ease-out;
        z-index: 2147483647;
    }

    @keyframes slideUpMobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Adjust message content width on mobile */
    .aifc-message-content {
        max-width: 85%;
    }

    /* Smaller avatars on mobile */
    .aifc-message-avatar {
        width: 28px;
        height: 28px;
        margin-right: 8px;
    }

    .aifc-message-user .aifc-message-avatar {
        margin-right: 0;
        margin-left: 8px;
    }

    /* Adjust home screen padding on mobile */
    .aifc-home-hero {
        padding: 32px 20px 24px;
    }

    .aifc-home-icon {
        width: 56px;
        height: 56px;
    }

    .aifc-home-icon svg {
        width: 28px;
        height: 28px;
    }

    .aifc-home-title {
        font-size: 22px;
    }

    .aifc-home-subtitle {
        font-size: 15px;
    }

    /* Prevent zoom on input focus - font-size must be at least 16px */
    .aifc-chat-input {
        font-size: 16px;
    }

    /* Also prevent zoom on contact form inputs */
    #aifc-contact-email,
    #aifc-contact-question {
        font-size: 16px !important;
    }

    /* Adjust suggestions on mobile */
    .aifc-suggestions {
        margin-left: 36px;
        max-width: 85%;
    }

    .aifc-suggestion-button {
        font-size: 14px;
        padding: 12px 14px;
    }
}

/* Hidden state */
.aifc-hidden {
    display: none !important;
}

/* Markdown Formatting Styles */
.aifc-message-content strong {
    font-weight: 600;
}

.aifc-message-content em {
    font-style: italic;
}

.aifc-message-content ul,
.aifc-message-content ol {
    margin: 8px 0 8px 0;
    padding-left: 20px;
}

.aifc-message-content ul {
    list-style-type: disc;
}

.aifc-message-content ol {
    list-style-type: decimal;
}

.aifc-message-content li {
    margin: 3px 0;
    line-height: 1.5;
}

.aifc-message-content a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--aifc-primary-color, #4F46E5);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    word-break: normal;
    white-space: nowrap;
    margin: 2px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.aifc-message-content a:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    filter: brightness(1.1);
}

/* Add arrow icon after link using pseudo-element */
.aifc-message-content a::after {
    content: "→";
    margin-left: 2px;
    font-size: 14px;
    transition: transform 0.2s ease;
}

.aifc-message-content a:hover::after {
    transform: translateX(2px);
}

/* For user messages, links should have a different style */
.aifc-message-user .aifc-message-content a {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
}

.aifc-message-user .aifc-message-content a:hover {
    background: rgba(255, 255, 255, 0.3);
}
