/* AI Chatbot Frontend Styles */

#ai-chatbot-widget { 
    position: fixed; 
    z-index: 9999; 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

#ai-chatbot-widget.bottom-right { 
    bottom: 20px; 
    right: 20px; 
}

#ai-chatbot-widget.bottom-left { 
    bottom: 20px; 
    left: 20px; 
}

#chatbot-button-container { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

#ai-chatbot-widget.bottom-left #chatbot-button-container { 
    flex-direction: row-reverse; 
}

#chatbot-hint {
    background: white;
    padding: 10px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    transition: all 0.3s ease;
    opacity: 0.9;
}

#chatbot-hint:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-color, #0084ff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

#chatbot-button:hover { 
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

#chatbot-contact-form {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    padding: 30px;
    animation: slideUp 0.3s ease;
    box-sizing: border-box;
}

#ai-chatbot-widget.bottom-left #chatbot-contact-form { 
    left: 0; 
    right: auto; 
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#contact-form-content h3 { 
    margin-top: 0; 
    margin-bottom: 10px;
    color: var(--chatbot-color, #0084ff); 
    font-size: 22px;
    font-weight: 600;
}

#contact-form-content p {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.5;
}

/* FORM INPUT FIELDS - RESTORED TO ORIGINAL LAYOUT */
#contact-info-form {
    display: block;
    width: 100%;
    margin-bottom: 15px;
}

#contact-info-form input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 15px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

#contact-info-form input:focus {
    outline: none;
    border-color: var(--chatbot-color, #0084ff);
    box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.1);
}

#contact-info-form button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    background: var(--chatbot-color, #0084ff);
}

#contact-info-form button:hover { 
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

#contact-info-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#contact-error {
    padding: 10px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    font-size: 14px;
}

#chatbot-window {
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    position: absolute;
    bottom: 75px;
    right: 0;
    animation: slideUp 0.3s ease;
    overflow: hidden;
    box-sizing: border-box;
}

#ai-chatbot-widget.bottom-left #chatbot-window { 
    left: 0; 
    right: auto; 
}

#chatbot-header {
    padding: 18px 20px;
    color: white;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    flex-shrink: 0;
    background: var(--chatbot-color, #0084ff);
}

#chatbot-logo-container {
    position: absolute;
    left: 20px;
    background: white;
    border-radius: 50%;
    padding: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-logo { 
    max-width: 100%; 
    border-radius: 50%; 
    object-fit: cover;
}

#chatbot-header span { 
    flex: 1; 
    text-align: center; 
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

#chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

#chatbot-close:hover {
    background: rgba(255,255,255,0.2);
}

#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#chatbot-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
}

#escalate-button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--chatbot-color, #0084ff);
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#escalate-button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

#escalate-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#chatbot-footer {
    padding: 12px 16px;
    text-align: center;
    font-size: 12px;
    color: #888;
    background: #fafafa;
    border-top: 1px solid #e5e7eb;
}

#chatbot-footer a {
    color: var(--chatbot-color, #0084ff);
    text-decoration: none;
    font-weight: 500;
}

#chatbot-footer a:hover {
    text-decoration: underline;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
}

#chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    outline: none;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

#chatbot-input:focus {
    border-color: var(--chatbot-color, #0084ff);
    box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.1);
}

#chatbot-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    background: var(--chatbot-color, #0084ff);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#chatbot-send:hover {
    opacity: 0.9;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

#chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-message { 
    max-width: 85%; 
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user { 
    align-self: flex-end; 
    text-align: right;
}

.chat-message.bot { 
    align-self: flex-start; 
    text-align: left;
}

.chat-message .bubble {
    display: inline-block;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chat-message.user .bubble {
    background: var(--chatbot-color, #0084ff);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot .bubble {
    background: white;
    color: #333;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-message.bot .bubble strong {
    font-weight: 600;
    color: #1a1a1a;
}

.chat-message.bot .bubble a {
    color: var(--chatbot-color, #0084ff);
    text-decoration: none;
    font-weight: 500;
}

.chat-message.bot .bubble a:hover {
    text-decoration: underline;
}

.typing-indicator { 
    display: flex; 
    gap: 6px; 
    padding: 12px 0; 
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
    display: inline-block;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { 
        opacity: 0.3; 
        transform: translateY(0);
    }
    30% { 
        opacity: 1; 
        transform: translateY(-6px);
    }
}

/* Scrollbar styling */
#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Math Challenge Styles - UPDATED FOR SINGLE LINE */
.challenge-container {
    margin: -7px 0;
    padding: 0px 15px 15px 15px; /* Reduced top padding to 0px */
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    animation: fadeIn 0.3s ease;
    box-sizing: border-box;
    width: 100%;
}

.challenge-question {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
}

.challenge-instruction {
    font-size: 13px;
    color: #666;
    margin-bottom: 15px;
    text-align: center;
}

.challenge-options {
    display: flex !important;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
}

.challenge-option {
    flex: 1;
    min-width: 0; /* Allow flex items to shrink below content size */
    padding: 12px 6px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
}

.challenge-option:hover {
    border-color: var(--chatbot-color, #0084ff);
    background: rgba(0, 132, 255, 0.05);
    transform: translateY(-2px);
}

.challenge-option.selected {
    background: var(--chatbot-color, #0084ff);
    color: white;
    border-color: var(--chatbot-color, #0084ff);
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.challenge-error {
    color: #dc2626;
    font-size: 13px;
    text-align: center;
    padding: 8px;
    background: #fee;
    border-radius: 6px;
    border: 1px solid #fcc;
    display: none;
}

.challenge-success {
    color: #059669;
    font-size: 13px;
    text-align: center;
    padding: 8px;
    background: #d1fae5;
    border-radius: 6px;
    border: 1px solid #a7f3d0;
    display: none;
}

/* Mobile responsiveness - UPDATED FOR BETTER CHALLENGE LAYOUT */
@media (max-width: 768px) {
    #ai-chatbot-widget {
        bottom: 15px;
    }
    
    #ai-chatbot-widget.bottom-right {
        right: 15px;
        left: auto;
    }
    
    #ai-chatbot-widget.bottom-left {
        left: 15px;
        right: auto;
    }
    
    #chatbot-window,
    #chatbot-contact-form {
        width: calc(100vw - 40px);
        max-width: 380px;
        bottom: 70px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        padding: 20px !important;
    }
    
    #ai-chatbot-widget.bottom-right #chatbot-window,
    #ai-chatbot-widget.bottom-right #chatbot-contact-form {
        right: 20px;
        left: auto;
        transform: none;
    }
    
    #ai-chatbot-widget.bottom-left #chatbot-window,
    #ai-chatbot-widget.bottom-left #chatbot-contact-form {
        left: 20px;
        right: auto;
        transform: none;
    }
    
    #chatbot-hint {
        display: none;
    }
    
    #chatbot-button {
        width: 56px;
        height: 56px;
    }
    
    #chatbot-messages {
        padding: 15px;
    }
    
    .chat-message .bubble {
        max-width: 85%;
        margin-left: 0;
        margin-right: 0;
    }
    
    .chat-message.bot {
        margin-right: 8px;
    }
    
    .chat-message.user {
        margin-left: 8px;
    }
    
    #chatbot-input-area {
        padding: 12px;
    }
    
    #escalate-button {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .chat-input-container {
        gap: 6px;
    }
    
    #chatbot-input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    #chatbot-send {
        width: 42px;
        height: 42px;
    }
    
    /* CHALLENGE SPECIFIC MOBILE STYLES */
    .challenge-container {
        padding: 0px 12px 12px 12px;
        margin: -12px 0;
        width: 100%;
        box-sizing: border-box;
    }
    
    .challenge-options {
        gap: 6px;
        width: 100%;
    }
    
    .challenge-option {
        padding: 10px 4px;
        font-size: 13px;
        min-height: 42px;
        flex: 1;
    }
    
    /* FORM FIELDS - RESTORED TO BLOCK LAYOUT */
    #contact-info-form {
        display: block;
    }
    
    #contact-info-form input {
        width: 100%;
        padding: 12px 14px;
        margin-bottom: 15px;
        font-size: 15px;
    }
    
    #contact-info-form button {
        padding: 14px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    #chatbot-window,
    #chatbot-contact-form {
        width: calc(100vw - 30px);
        height: 500px;
        padding: 15px !important;
    }
    
    #chatbot-messages {
        padding: 12px;
    }
    
    .chat-message .bubble {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .chat-message.bot {
        margin-right: 6px;
    }
    
    .chat-message.user {
        margin-left: 6px;
    }
    
    #chatbot-input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    #chatbot-send {
        width: 40px;
        height: 40px;
    }
    
    #chatbot-button {
        width: 52px;
        height: 52px;
    }
    
    #chatbot-header {
        padding: 14px 16px;
    }
    
    #chatbot-header span {
        font-size: 15px;
    }
    
    /* CHALLENGE FOR SMALL SCREENS */
    .challenge-option {
        padding: 10px 3px;
        font-size: 12px;
        min-height: 40px;
    }
    
    .challenge-question {
        font-size: 15px;
    }
    
    .challenge-instruction {
        font-size: 12px;
    }
}

/* Very small screens - introduce horizontal scroll for challenge options */
@media (max-width: 380px) {
    #chatbot-window,
    #chatbot-contact-form {
        width: calc(100vw - 25px);
        padding: 15px !important;
    }
    
    .challenge-container {
        padding: 0px 10px 10px 10px;
        margin: 10px 0;
    }
    
    .challenge-options {
        display: flex;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    .challenge-options::-webkit-scrollbar {
        height: 4px;
    }
    
    .challenge-options::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 2px;
    }
    
    .challenge-options::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 2px;
    }
    
    .challenge-option {
        flex: 0 0 auto;
        width: 70px;
        padding: 10px 4px;
        font-size: 12px;
        min-height: 38px;
    }
    
    #contact-form-content h3 {
        font-size: 20px;
    }
    
    #contact-form-content p {
        font-size: 14px;
    }
    
    #contact-info-form input {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    #contact-info-form button {
        padding: 12px;
        font-size: 15px;
    }
}

/* Extra small devices */
@media (max-width: 350px) {
    #chatbot-window,
    #chatbot-contact-form {
        width: calc(100vw - 20px);
        padding: 12px !important;
    }
    
    .challenge-option {
        width: 65px;
        padding: 8px 3px;
        font-size: 11px;
        min-height: 36px;
    }
    
    .challenge-question {
        font-size: 14px;
    }
    
    .challenge-instruction {
        font-size: 11px;
        margin-bottom: 10px;
    }
}

/* Ensure consistent spacing between form elements */
#contact-form-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Divider line between sections */
#contact-form-content hr {
    border: none;
    height: 1px;
    background: #e5e7eb;
    margin: 10px 0;
}