/* Chatbot Widget Styles - Mobile-Friendly with Light/Dark Mode Support */

.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Smooth transitions for theme changes */
.chatbot-window,
.chatbot-messages,
.message-content,
.chatbot-input,
.chatbot-header,
.suggestion-btn,
.learn-more-btn,
.follow-up-btn {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.5);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Chatbot Window */
.chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
}

.chatbot-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 16px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-header p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* Messages */
.chatbot-message {
    display: flex;
    animation: messageSlide 0.3s ease;
}

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

.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
}

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

.user-message .message-content {
    background: #28a745;
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content strong {
    font-weight: 600;
    color: #28a745;
}

/* Chatbot Answer Sections */
.chatbot-answer-section {
    margin-bottom: 12px;
}

.chatbot-answer-section:last-child {
    margin-bottom: 0;
}

.chatbot-answer-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #28a745;
}

.chatbot-answer-section p {
    margin: 0;
    white-space: pre-wrap;
}

/* Suggested Questions */
.suggested-questions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.suggestion-btn {
    background: #f0f9ff;
    border: 1px solid #28a745;
    color: #28a745;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.suggestion-btn:hover {
    background: #28a745;
    color: white;
}

/* Learn More Button */
.learn-more-btn {
    background: #28a745;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.learn-more-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.learn-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Follow-up Topics */
.follow-up-topics {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.follow-up-topics p {
    margin: 0 0 10px 0;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.follow-up-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.follow-up-btn {
    background: #f8f9fa;
    border: 1px solid #28a745;
    color: #28a745;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    white-space: nowrap;
}

.follow-up-btn:hover {
    background: #28a745;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Input Area */
.chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 16px 16px;
}

#chatbot-form {
    display: flex;
    gap: 8px;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: #28a745;
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #28a745;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.chatbot-send-btn:active {
    transform: scale(0.95);
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
    align-items: center;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: typing 1.4s infinite;
}

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

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

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

/* Mobile Responsive - Compact UI for Mobile Browsers */
@media (max-width: 768px) {
    .chatbot-toggle {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px;
    }

    .chatbot-window {
        width: 100%;
        height: auto;
        max-height: 50vh; /* Half screen max */
        min-height: 300px; /* Minimum usable height */
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    }
    
    /* Compact Header */
    .chatbot-header {
        padding: 12px 16px;
        min-height: 50px;
    }
    
    .chatbot-header-content {
        gap: 8px;
    }
    
    .chatbot-header-content svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }
    
    .chatbot-header h3 {
        font-size: 15px;
        margin: 0;
        line-height: 1.2;
    }
    
    .chatbot-header p {
        font-size: 11px;
        margin: 2px 0 0 0;
        line-height: 1.2;
    }
    
    .chatbot-close {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }
    
    .chatbot-close svg {
        width: 18px;
        height: 18px;
    }

    /* Compact Messages Area */
    .chatbot-messages {
        max-height: calc(50vh - 180px);
        min-height: 150px;
        padding: 12px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    .chatbot-message {
        margin-bottom: 10px;
    }
    
    .message-content {
        font-size: 13px;
        padding: 10px 12px;
        max-width: 85%;
        line-height: 1.5;
        word-wrap: break-word;
    }
    
    .message-content p {
        margin: 0 0 8px 0;
    }
    
    .message-content p:last-child {
        margin-bottom: 0;
    }
    
    /* Compact Input Area */
    .chatbot-input-area {
        padding: 12px 16px;
        background: inherit;
    }
    
    .chatbot-input-area form {
        display: flex;
        gap: 8px;
    }
    
    .chatbot-input {
        font-size: 14px;
        padding: 10px 14px;
        border-radius: 24px;
        flex: 1;
        min-height: 44px; /* Touch-friendly */
    }
    
    .chatbot-send-btn {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        border-radius: 50%;
    }
    
    .chatbot-send-btn svg {
        width: 18px;
        height: 18px;
    }
    
    /* Compact Suggested Questions */
    .suggested-questions {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-top: 10px;
    }
    
    .suggestion-btn {
        font-size: 12px;
        padding: 8px 12px;
        text-align: left;
        min-height: 36px;
        border-radius: 8px;
    }
    
    /* Compact Learn More button */
    .learn-more-btn {
        font-size: 11px;
        padding: 6px 12px;
        margin-top: 8px;
        min-height: 32px;
        border-radius: 6px;
    }
    
    /* Compact follow-up buttons */
    .follow-up-topics {
        margin-top: 12px;
        padding-top: 10px;
    }
    
    .follow-up-topics p {
        font-size: 11px;
        margin-bottom: 8px;
        font-weight: 600;
    }
    
    .follow-up-btn {
        font-size: 11px;
        padding: 6px 10px;
        margin: 4px 4px 4px 0;
        min-height: 32px;
        border-radius: 16px;
    }
    
    /* Typing Indicator */
    .chatbot-typing {
        padding: 8px 12px;
    }
}

/* Test Page Adjustments - Compact for test interface */
@media (max-width: 768px) {
    .mobile-test-body .chatbot-toggle,
    .mobile-review-body .chatbot-toggle {
        bottom: 80px; /* Above navigation buttons */
        right: 20px;
        width: 52px;
        height: 52px;
        z-index: 999;
    }

    /* Even more compact on test pages */
    .mobile-test-body .chatbot-window,
    .mobile-review-body .chatbot-window {
        max-height: 45vh; /* Slightly less than half screen */
        min-height: 280px;
    }

    .mobile-test-body .chatbot-messages,
    .mobile-review-body .chatbot-messages {
        max-height: calc(45vh - 170px);
        min-height: 120px;
    }
    
    /* Smaller header on test pages */
    .mobile-test-body .chatbot-header,
    .mobile-review-body .chatbot-header {
        padding: 10px 14px;
        min-height: 46px;
    }
    
    .mobile-test-body .chatbot-header h3,
    .mobile-review-body .chatbot-header h3 {
        font-size: 14px;
    }
    
    .mobile-test-body .chatbot-header p,
    .mobile-review-body .chatbot-header p {
        font-size: 10px;
    }
}

/* Light Mode (Explicit) - Ensures proper light mode rendering */
@media (prefers-color-scheme: light), (prefers-color-scheme: no-preference) {
    .chatbot-window {
        background: #ffffff;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }
    
    .chatbot-header {
        background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
        border-bottom: none;
    }
    
    .chatbot-header h3,
    .chatbot-header p {
        color: #ffffff;
    }
    
    .chatbot-close {
        background: rgba(255, 255, 255, 0.2);
        color: #ffffff;
    }
    
    .chatbot-close:hover {
        background: rgba(255, 255, 255, 0.3);
    }
    
    .chatbot-messages {
        background: #f8f9fa;
    }
    
    .bot-message .message-content {
        background: #f1f3f5;
        color: #2c3e50;
        border: 1px solid #e9ecef;
    }
    
    .user-message .message-content {
        background: #28a745;
        color: #ffffff;
        border: 1px solid #28a745;
    }
    
    .chatbot-input-area {
        background: #ffffff;
        border-top: 1px solid #e9ecef;
    }
    
    .chatbot-input {
        background: #ffffff;
        color: #2c3e50;
        border: 1px solid #ced4da;
    }
    
    .chatbot-input::placeholder {
        color: #6c757d;
    }
    
    .chatbot-input:focus {
        border-color: #28a745;
        background: #ffffff;
    }
    
    .chatbot-send-btn {
        background: #28a745;
        color: #ffffff;
    }
    
    .chatbot-send-btn:hover {
        background: #218838;
    }
    
    .suggestion-btn {
        background: #ffffff;
        border: 1px solid #28a745;
        color: #28a745;
    }
    
    .suggestion-btn:hover {
        background: #28a745;
        color: #ffffff;
    }
    
    .learn-more-btn {
        background: #ffffff;
        color: #007bff;
        border: 1px solid #007bff;
    }
    
    .learn-more-btn:hover {
        background: #007bff;
        color: #ffffff;
    }
    
    .follow-up-btn {
        background: #ffffff;
        color: #fd7e14;
        border: 1px solid #fd7e14;
    }
    
    .follow-up-btn:hover {
        background: #fd7e14;
        color: #ffffff;
    }
    
    .follow-up-topics {
        border-top: 1px solid #e9ecef;
    }
    
    .follow-up-topics p {
        color: #6c757d;
    }
    
    .chatbot-typing span {
        background: #28a745;
    }
    
    .chatbot-toggle {
        background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    }
    
    .chatbot-toggle:hover {
        background: linear-gradient(135deg, #218838 0%, #1ea87a 100%);
        box-shadow: 0 6px 16px rgba(40, 167, 69, 0.5);
    }
    
    .chatbot-badge {
        background: #dc3545;
        color: #ffffff;
    }
}

/* Extra small screens - Ultra compact */
@media (max-width: 480px) {
    .chatbot-window {
        max-height: 45vh;
        min-height: 280px;
    }
    
    .chatbot-messages {
        max-height: calc(45vh - 160px);
        min-height: 130px;
    }
    
    .chatbot-toggle {
        width: 52px;
        height: 52px;
        bottom: 16px;
        right: 16px;
    }
    
    .chatbot-header {
        padding: 10px 12px;
        min-height: 46px;
    }
    
    .chatbot-header h3 {
        font-size: 14px;
    }
    
    .chatbot-header p {
        font-size: 10px;
    }
    
    .message-content {
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .chatbot-input {
        font-size: 13px;
        padding: 9px 12px;
    }
    
    /* Test pages on small screens */
    .mobile-test-body .chatbot-toggle,
    .mobile-review-body .chatbot-toggle {
        width: 48px;
        height: 48px;
        bottom: 75px;
        right: 16px;
    }
    
    .mobile-test-body .chatbot-window,
    .mobile-review-body .chatbot-window {
        max-height: 40vh;
        min-height: 260px;
    }
    
    .mobile-test-body .chatbot-messages,
    .mobile-review-body .chatbot-messages {
        max-height: calc(40vh - 150px);
        min-height: 110px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* Chatbot Window */
    .chatbot-window {
        background: #1e1e1e;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    }
    
    /* Header */
    .chatbot-header {
        background: linear-gradient(135deg, #1a5928 0%, #145a1f 100%);
        border-bottom: 1px solid #2a4a2a;
    }
    
    .chatbot-header h3,
    .chatbot-header p {
        color: #ffffff;
    }
    
    .chatbot-close {
        background: rgba(255, 255, 255, 0.1);
        color: #ffffff;
    }
    
    .chatbot-close:hover {
        background: rgba(255, 255, 255, 0.2);
    }

    /* Messages Area */
    .chatbot-messages {
        background: #252525;
    }
    
    /* Bot Messages */
    .bot-message .message-content {
        background: #2d2d2d;
        color: #e8e8e8;
        border: 1px solid #3a3a3a;
    }
    
    /* User Messages */
    .user-message .message-content {
        background: #1a5928;
        color: #ffffff;
        border: 1px solid #1a5928;
    }

    /* Input Area */
    .chatbot-input-area {
        background: #1e1e1e;
        border-top: 1px solid #3a3a3a;
    }

    .chatbot-input {
        background: #2d2d2d;
        color: #e8e8e8;
        border: 1px solid #3a3a3a;
    }
    
    .chatbot-input::placeholder {
        color: #888;
    }
    
    .chatbot-input:focus {
        border-color: #28a745;
        background: #333;
    }
    
    /* Send Button */
    .chatbot-send-btn {
        background: #28a745;
        color: #ffffff;
    }
    
    .chatbot-send-btn:hover {
        background: #218838;
    }

    /* Suggestion Buttons */
    .suggestion-btn {
        background: #2d2d2d;
        border: 1px solid #28a745;
        color: #28a745;
    }
    
    .suggestion-btn:hover {
        background: #28a745;
        color: #ffffff;
    }
    
    /* Learn More Button */
    .learn-more-btn {
        background: #2d2d2d;
        color: #4a9eff;
        border: 1px solid #4a9eff;
    }
    
    .learn-more-btn:hover {
        background: #4a9eff;
        color: #ffffff;
    }
    
    /* Follow-up Buttons */
    .follow-up-btn {
        background: #2d2d2d;
        color: #ffa500;
        border: 1px solid #ffa500;
    }
    
    .follow-up-btn:hover {
        background: #ffa500;
        color: #1e1e1e;
    }
    
    /* Follow-up Topics Section */
    .follow-up-topics {
        border-top: 1px solid #3a3a3a;
    }
    
    .follow-up-topics p {
        color: #999;
    }
    
    /* Typing Indicator */
    .chatbot-typing span {
        background: #888;
    }
    
    /* Toggle Button - Keep bright for visibility */
    .chatbot-toggle {
        background: #28a745;
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    }
    
    .chatbot-toggle:hover {
        background: #218838;
        box-shadow: 0 6px 16px rgba(40, 167, 69, 0.5);
    }
    
    /* Badge */
    .chatbot-badge {
        background: #dc3545;
        color: #ffffff;
    }
    
    /* Scrollbar */
    .chatbot-messages::-webkit-scrollbar-track {
        background: #1e1e1e;
    }
    
    .chatbot-messages::-webkit-scrollbar-thumb {
        background: #3a3a3a;
    }
    
    .chatbot-messages::-webkit-scrollbar-thumb:hover {
        background: #4a4a4a;
    }
}
