/**
 * Custom Chatbot - Public Styles
 */

/* Main Container */
.custom-chatbot-container {
    display: flex;
    width: 100%;
    height: 600px; /* Default height, can be overridden via shortcode */
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    color: #ececf1;
    background-color: #343541;
}

/* Sidebar */
.custom-chatbot-sidebar {
    display: flex;
    flex-direction: column;
    width: 260px;
    background-color: #202123;
    border-right: 1px solid #4d4d4f;
}

.custom-chatbot-sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #4d4d4f;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-chatbot-sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #ececf1;
}

.custom-chatbot-new-chat {
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.custom-chatbot-new-chat:hover {
    background-color: #0d8c6e;
}

.custom-chatbot-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.custom-chatbot-history-list {
    list-style-type: none;
    margin: 0;
    padding: 0;
}

.custom-chatbot-history-item {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 5px;
    margin: 2px 8px;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s;
}

.custom-chatbot-history-item:hover {
    background-color: #2a2b32;
}

.custom-chatbot-history-item.active {
    background-color: #343541;
}

.custom-chatbot-history-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-chatbot-history-date {
    font-size: 11px;
    color: #8e8ea0;
    margin-top: 4px;
}

/* Main Chat Area */
.custom-chatbot-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: #343541;
    min-height: 0; /* Important for flex layout */
    height: 100%; /* Ensure full height */
    overflow: hidden; /* Prevent overflow */
}

/* Email Form */
.custom-chatbot-email-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 20px;
}

.custom-chatbot-email-form {
    width: 100%;
    max-width: 400px;
    background-color: #444654;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.custom-chatbot-email-form h2 {
    margin-top: 0;
    font-size: 20px;
    color: #ececf1;
}

.custom-chatbot-email-input-group {
    display: flex;
    margin-top: 20px;
}

.custom-chatbot-email-input-group input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #5e5e5e;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
    color: #ececf1;
    background-color: #40414f;
}

.custom-chatbot-email-input-group button {
    background-color: #10a37f;
    color: white;
    border: none;
    padding: 0 15px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background-color 0.3s;
}

.custom-chatbot-email-input-group button:hover {
    background-color: #0d8c6e;
}

.custom-chatbot-email-input-group button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.custom-chatbot-email-input-group button:disabled:hover {
    background-color: #6c757d;
}

/* Email Error Message */
.custom-chatbot-email-error {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #ff4444;
    color: white;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
    animation: fadeIn 0.3s ease-in-out;
}

.custom-chatbot-email-error .error-message {
    display: block;
}

.custom-chatbot-email-input-group input.error {
    border-color: #ff4444;
    box-shadow: 0 0 0 2px rgba(255, 68, 68, 0.2);
}

/* Chat Messages Area */
.custom-chatbot-messages-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* Important for flex layout */
    height: 100%; /* Ensure full height */
}

.custom-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    scroll-behavior: smooth;
    min-height: 0; /* Important for flex layout */
    height: 100%; /* Ensure full height */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.custom-chatbot-message {
    max-width: 90%;
    margin-bottom: 24px;
    line-height: 1.5;
    font-size: 15px;
    animation: fadeIn 0.3s ease-in-out;
}

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

.custom-chatbot-message.user {
    margin-left: auto;
    background-color: #444654;
    border-radius: 10px 10px 0 10px;
    padding: 12px 16px;
}

.custom-chatbot-message.assistant {
    margin-right: auto;
    background-color: #444654;
    border-radius: 10px 10px 10px 0;
    padding: 12px 16px;
}

/* Message content formatting */
.custom-chatbot-message-content {
    line-height: 1.6;
    word-wrap: break-word;
}

.custom-chatbot-message-content p {
    margin: 0 0 12px 0;
}

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

.custom-chatbot-message-content strong {
    font-weight: 600;
    color: #ececf1;
}

.custom-chatbot-message-content em {
    font-style: italic;
    color: #d1d5db;
}

.custom-chatbot-message-content code {
    background-color: #2d2d2d;
    color: #f8f8f2;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    border: 1px solid #4d4d4f;
}

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

.custom-chatbot-message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.custom-chatbot-message-content ul li {
    list-style-type: disc;
}

.custom-chatbot-message-content ol li {
    list-style-type: decimal;
}

/* Additional message styling */
.custom-chatbot-message.assistant {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.custom-chatbot-message.user {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Better spacing for formatted content */
.custom-chatbot-message-content br + br {
    margin-top: 8px;
}

/* Highlight important information */
.custom-chatbot-message-content strong {
    background: linear-gradient(45deg, #10a37f, #0d8c6e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Message Input Area */
.custom-chatbot-input-container {
    display: flex !important;
    align-items: center;
    padding: 16px;
    border-top: 1px solid #4d4d4f;
    background-color: #40414f;
}

#custom-chatbot-message {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #5e5e5e;
    border-radius: 6px;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    color: #ececf1;
    background-color: #40414f;
    font-family: inherit;
    overflow-y: auto;
    max-height: 200px;
    transition: border-color 0.3s;
}

#custom-chatbot-message:focus {
    outline: none;
    border-color: #10a37f;
}

#custom-chatbot-send {
    background-color: transparent;
    border: none;
    padding: 6px;
    margin-left: 8px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

#custom-chatbot-send:hover {
    background-color: #565869;
}

#custom-chatbot-send svg {
    fill: #10a37f;
    width: 20px;
    height: 20px;
}

#custom-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Typing Indicator */
.custom-chatbot-typing {
    padding: 15px;
    display: flex;
    align-items: center;
}

.typing-dot {
    background-color: #ececf1;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin: 0 2px;
    animation: typingAnimation 1.5s infinite ease-in-out;
}

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

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

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Responsive Styles */
@media (max-width: 768px) {
    .custom-chatbot-container {
        flex-direction: column;
        height: 100vh; /* Full viewport height */
        max-height: 100vh;
        overflow: hidden; /* Prevent container scrolling */
    }
    
    .custom-chatbot-sidebar {
        width: 100%;
        height: 60px;
        border-right: none;
        border-bottom: 1px solid #4d4d4f;
        flex-direction: row;
        align-items: center;
        cursor: pointer;
        position: relative;
        flex-shrink: 0; /* Prevent shrinking */
    }
    
    .custom-chatbot-sidebar-header {
        width: 100%;
        border-bottom: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 15px;
        position: relative;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    .custom-chatbot-sidebar-header:active {
        background-color: #2a2b32;
    }
    
    .custom-chatbot-sidebar-header::after {
        content: '▼';
        font-size: 12px;
        color: #8e8ea0;
        transition: transform 0.3s ease;
    }
    
    .custom-chatbot-sidebar-header.active::after {
        transform: rotate(180deg);
    }
    
    .custom-chatbot-sidebar-content {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        width: 100%;
        background-color: #202123;
        z-index: 10;
        max-height: 300px;
        overflow-y: auto;
        border-bottom: 1px solid #4d4d4f;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        animation: slideDown 0.3s ease-out;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .custom-chatbot-sidebar-content.active {
        display: block;
    }
    
    .custom-chatbot-history-list {
        padding: 8px 0;
    }
    
    .custom-chatbot-history-item {
        margin: 2px 8px;
        padding: 12px 15px;
        border-radius: 6px;
        transition: background-color 0.2s;
    }
    
    .custom-chatbot-history-item:hover {
        background-color: #2a2b32;
    }
    
    .custom-chatbot-history-item.active {
        background-color: #343541;
    }
    
    .custom-chatbot-message {
        max-width: 95%;
    }
    
    /* Hide desktop new chat button on mobile */
    .custom-chatbot-new-chat {
        display: none;
    }
    
    /* Show mobile new chat button on mobile */
    .custom-chatbot-mobile-new-chat {
        display: block !important;
        padding: 8px 15px;
        border-bottom: 1px solid #4d4d4f;
    }
    
    /* Ensure mobile button is visible when sidebar content is active */
    .custom-chatbot-sidebar-content.active .custom-chatbot-mobile-new-chat {
        display: block !important;
    }
    
    /* Main chat area - make it scrollable */
    .custom-chatbot-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Prevent main area scrolling */
        min-height: 0; /* Allow flex shrinking */
    }
    
    /* Messages container - make it scrollable */
    .custom-chatbot-messages-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
        
    }
    
    .custom-chatbot-messages {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 15px;
        padding-bottom: 80px; /* Space for fixed input container */
        -webkit-overflow-scrolling: touch;
    }
    
    /* Input container - fixed at bottom */
    .custom-chatbot-input-container {
        display: flex;
        align-items: center;
        padding: 10px 15px;
        border-top: 1px solid #4d4d4f;
        background-color: #40414f;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        min-height: 60px;
        box-sizing: border-box;
    }
    
    /* Input box - reduce height and ensure it fits */
    #custom-chatbot-message {
        flex: 1;
        padding: 8px 12px;
        border: 1px solid #5e5e5e;
        border-radius: 6px;
        resize: none;
        font-size: 16px; /* Prevents iPhone zoom */
        line-height: 1.4;
        color: #ececf1;
        background-color: #40414f;
        font-family: inherit;
        overflow-y: auto;
        max-height: 80px; /* Reduced max height */
        min-height: 36px; /* Minimum height */
        box-sizing: border-box;
        margin-right: 8px; /* Space between input and button */
    }
    
    /* Send button - ensure it fits */
    #custom-chatbot-send {
        background-color: transparent;
        border: none;
        padding: 8px;
        cursor: pointer;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background-color 0.3s;
        flex-shrink: 0; /* Prevent shrinking */
        min-width: 40px; /* Minimum width */
        height: 36px; /* Match input height */
    }
    
    #custom-chatbot-send:hover {
        background-color: #565869;
    }
    
    #custom-chatbot-send svg {
        fill: #10a37f;
        width: 18px;
        height: 18px;
    }
    
    /* Email form adjustments for mobile */
    .custom-chatbot-email-container {
        padding: 20px 15px;
    }
    
    .custom-chatbot-email-form {
        padding: 20px;
    }
    
    .custom-chatbot-email-input-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .custom-chatbot-email-input-group input {
        border-radius: 4px;
        margin-bottom: 0;
    }
    
    .custom-chatbot-email-input-group button {
        border-radius: 4px;
        margin-left: 0;
    }
} 

/* PDF context badge */
.custom-chatbot-pdf-status {
    margin: 10px 0;
}

.custom-chatbot-pdf-badge {
    display: inline-flex;
    align-items: center;
    background-color: #f0f7ff;
    border: 1px solid #cce5ff;
    color: #0066cc;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 12px;
}

.custom-chatbot-pdf-badge svg {
    margin-right: 6px;
}

/* Context message styling */
.custom-chatbot-message.context {
    background-color: #f8f9fa;
    border-left: 3px solid #6c757d;
    font-style: italic;
    color: #6c757d;
}

/* Raw content styling */
.custom-chatbot-message-content .raw-content {
    white-space: pre-wrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    line-height: 1.6;
}

/* Math symbols styling */
.custom-chatbot-message-content .raw-content sup,
.custom-chatbot-message-content .raw-content sub {
    font-size: 0.75em;
    line-height: 0;
}

/* Special characters like square root, plus-minus */
.custom-chatbot-message-content .raw-content .math-symbol {
    font-weight: normal;
    font-style: normal;
}

/* Ensure math expressions are readable on dark background */
.MathJax {
    color: #ececf1 !important;
}

/* Math display styling */
.MathJax_Display {
    overflow-x: auto;
    margin: 15px 0 !important;
}

/* Loading animation for PDF */
.pdf-loading {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 13px;
}

.pdf-loading div {
    position: absolute;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #0066cc;
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.pdf-loading div:nth-child(1) {
    left: 8px;
    animation: pdf-loading1 0.6s infinite;
}

.pdf-loading div:nth-child(2) {
    left: 8px;
    animation: pdf-loading2 0.6s infinite;
}

.pdf-loading div:nth-child(3) {
    left: 32px;
    animation: pdf-loading2 0.6s infinite;
}

.pdf-loading div:nth-child(4) {
    left: 56px;
    animation: pdf-loading3 0.6s infinite;
}

@keyframes pdf-loading1 {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pdf-loading3 {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(0);
    }
}

@keyframes pdf-loading2 {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(24px, 0);
    }
} 

/* PDF loading indicator */
.custom-chatbot-pdf-loading {
    margin: 15px 0;
    text-align: center;
}

.custom-chatbot-pdf-loading p {
    margin: 10px 0 0 0;
    color: #8e8ea0;
    font-size: 14px;
}

.custom-chatbot-pdf-loading .pdf-loading {
    margin: 0 auto;
} 

/* Mobile new chat button - hidden by default on desktop */
.custom-chatbot-mobile-new-chat {
    display: none;
}

.custom-chatbot-new-chat-mobile {
    width: 100%;
    background-color: #10a37f;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.custom-chatbot-new-chat-mobile:hover {
    background-color: #0d8c6e;
}

/* Force mobile button visibility on mobile when sidebar is active */
@media (max-width: 768px) {
    .custom-chatbot-sidebar-content.active .custom-chatbot-mobile-new-chat {
        display: block !important;
    }
    
    .custom-chatbot-sidebar-content.active .custom-chatbot-new-chat-mobile {
        display: block !important;
    }
} 

/* Mobile body scrolling prevention */
body.custom-chatbot-mobile-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Ensure proper mobile layout */
@media (max-width: 768px) {
    .custom-chatbot-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
    }
} 