/**
 * OptiBot MD - ChatGPT Style Interface
 *
 * @package OptiBotMD
 */

/* =========================================
   CSS Variables
   ========================================= */
:root {
    --optibot-bg: #ffffff;
    --optibot-text: #1a1a1a;
    --optibot-text-secondary: #6b6b6b;
    --optibot-border: #e5e5e5;
    --optibot-input-bg: #f4f4f4;
    --optibot-input-border: #e5e5e5;
    --optibot-input-focus: #10a37f;
    --optibot-user-bg: #15BECF;
    --optibot-user-text: #ffffff;
    --optibot-assistant-bg: #F7F7F8;
    --optibot-assistant-text: #1a1a1a;
    --optibot-send-bg: #1a1a1a;
    --optibot-send-hover: #333333;
    --optibot-send-disabled: #d1d1d1;
    --optibot-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --optibot-font-size: 16px;
    --optibot-line-height: 1.6;
    --optibot-radius: 24px;
    --optibot-radius-sm: 12px;
    --optibot-max-width: 768px;
}

/* Dark theme variables */
.optibot-theme-dark {
    --optibot-bg: #212121;
    --optibot-text: #ececec;
    --optibot-text-secondary: #9b9b9b;
    --optibot-border: #424242;
    --optibot-input-bg: #2f2f2f;
    --optibot-input-border: #424242;
    --optibot-user-bg: #15BECF;
    --optibot-user-text: #ffffff;
    --optibot-assistant-bg: #2f2f2f;
    --optibot-assistant-text: #ececec;
    --optibot-send-bg: #ffffff;
    --optibot-send-hover: #e5e5e5;
}

/* =========================================
   Container
   ========================================= */
.optibot-container {
    font-family: var(--optibot-font-family);
    font-size: var(--optibot-font-size);
    line-height: var(--optibot-line-height);
    color: var(--optibot-text);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    box-sizing: border-box;
}

.optibot-container *,
.optibot-container *::before,
.optibot-container *::after {
    box-sizing: border-box;
}

/* =========================================
   Messages Area
   ========================================= */
.optibot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.optibot-messages-list {
    width: 100%;
    max-width: var(--optibot-max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* Additional spacing for messages */
.optibot-message {
    margin-bottom: 8px;
}

/* =========================================
   Welcome Section
   ========================================= */
.optibot-welcome-section {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 200px;
    text-align: center;
    padding: 40px 20px;
}

.optibot-welcome-content {
    max-width: 600px;
}

.optibot-welcome-content h2 {
    font-size: 28px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--optibot-text);
}

.optibot-welcome-content p {
    font-size: 16px;
    color: var(--optibot-text-secondary);
    margin: 0;
}

/* Hide welcome when there are messages */
.optibot-container.has-messages .optibot-welcome-section {
    display: none;
}

/* =========================================
   Message Styles - Base
   ========================================= */
.optibot-message {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    width: 100%;
    max-width: var(--optibot-max-width);
    margin: 0 auto;
    animation: optibot-fade-in 0.3s ease;
}

/* =========================================
   User Message - Right Aligned with Callout
   ========================================= */
.optibot-message-user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.optibot-message-user .optibot-message-content {
    background: var(--optibot-user-bg);
    color: var(--optibot-user-text);
    border-radius: 20px 0px 20px 20px; /* Callout bottom-right */
    padding: 12px 18px;
    max-width: 75%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin: 20px 0px;
}

.optibot-message-user .optibot-message-avatar {
    background: #5436da;
    color: white;
    margin-top:15px;
}

/* User message links */
.optibot-message-user .optibot-message-content a {
    color: #ffffff;
    text-decoration: underline;
}

.optibot-message-user .optibot-message-content a:hover {
    opacity: 0.9;
}

/* =========================================
   Assistant Message - Left Aligned with Callout
   ========================================= */
.optibot-message-assistant {
    flex-direction: row;
    justify-content: flex-start;
}

.optibot-message-assistant .optibot-message-content {
    background: #ffffff; /* CHANGED: White background */
    color: var(--optibot-assistant-text);
    border-radius: 0px 20px 20px 20px; /* CHANGED: Rounded corners all sides */
    padding: 14px 18px;
    max-width: 85%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* CHANGED: Slightly stronger shadow */
    border: 1px solid #e5e5e5; /* ADDED: Subtle border */
}


.optibot-message-assistant .optibot-message-avatar {
    background: #10a37f;
    color: white;
    margin-top:-5px;
}

/* Assistant message links */
.optibot-message-assistant .optibot-message-content a {
    color: #10a37f;
    text-decoration: none;
}

.optibot-message-assistant .optibot-message-content a:hover {
    text-decoration: underline;
}

/* =========================================
   Message Avatar
   ========================================= */
.optibot-message-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.optibot-message-avatar svg {
    width: 20px;
    height: 20px;
}

.optibot-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* =========================================
   Message Content
   ========================================= */
.optibot-message-content {
    overflow-wrap: break-word;
    word-wrap: break-word;
    line-height: 1.5;
}

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

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

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

.optibot-message-content li {
    margin-bottom: 6px;
}

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

.optibot-message-content strong {
    font-weight: 600;
}

.optibot-message-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

.optibot-message-assistant .optibot-message-content code {
    background: rgba(0, 0, 0, 0.06);
}

.optibot-message-user .optibot-message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.optibot-message-content pre {
    background: rgba(0, 0, 0, 0.06);
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.optibot-message-content pre code {
    background: transparent;
    padding: 0;
}

.optibot-message-content h3,
.optibot-message-content h4 {
    margin: 16px 0 10px 0;
    font-weight: 600;
}

.optibot-message-content h3:first-child,
.optibot-message-content h4:first-child {
    margin-top: 0;
}

.optibot-message-content hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 16px 0;
}

/* Tables in messages */
.optibot-message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 14px;
}

.optibot-message-content th,
.optibot-message-content td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.optibot-message-content th {
    background: rgba(0, 0, 0, 0.04);
    font-weight: 600;
}

/* =========================================
   Typing Indicator - Left Aligned with Avatar
   ========================================= */
.optibot-typing {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: var(--optibot-max-width);
    margin: 0 auto;
    width: 100%;
    padding: 0 16px;
    animation: optibot-fade-in 0.3s ease;
}

.optibot-typing-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: #10a37f;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* ADDED: Subtle pulse animation */
    animation: optibot-avatar-pulse 2s ease-in-out infinite;
}

@keyframes optibot-avatar-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 163, 127, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(16, 163, 127, 0);
    }
}

.optibot-typing-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.optibot-typing-label {
    font-size: 12px;
    color: var(--optibot-text-secondary);
    font-weight: 500;
}

.optibot-typing-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.optibot-typing-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.optibot-typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    background: var(--optibot-assistant-bg);
    border-radius: 20px 20px 20px 4px; /* Match assistant message callout */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.optibot-typing-dot {
    width: 8px;
    height: 8px;
    background: #9CA3AF;
    border-radius: 50%;
    animation: optibot-typing-bounce 1.4s infinite ease-in-out both;
}

.optibot-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

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

@keyframes optibot-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =========================================
   Input Area (ChatGPT Style)
   ========================================= */
.optibot-input-area {
    padding: 16px 24px 24px;
    position: sticky;
    bottom: 0;
}

.optibot-form {
    max-width: var(--optibot-max-width);
    margin: 0 auto;
}

.optibot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--optibot-bg);
    border: 1px solid var(--optibot-input-border);
    border-radius: var(--optibot-radius);
    padding: 12px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.optibot-input-wrapper:focus-within {
    /*border-color: var(--optibot-input-focus);*/
    /*box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);*/
}

.optibot-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    color: var(--optibot-text);
    resize: none;
    outline: none;
    max-height: 200px;
    min-height: 24px;
}

.optibot-input:focus{ border:0; outline:0; box-shadow:none;}

.optibot-input::placeholder {
    color: var(--optibot-text-secondary);
}

.optibot-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    border-radius: 50%; /* CHANGED: Circle button */
    background: #15BECF;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.optibot-send:hover:not(:disabled) {
    background: #12a8b8;
    transform: scale(1.05);
}

.optibot-send:active:not(:disabled) {
    transform: scale(0.95);
}

.optibot-send:disabled {
    background: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ADDED: Processing state for send button */
.optibot-send.processing {
    background: #cccccc;
    cursor: not-allowed;
    pointer-events: none;
}

.optibot-send.processing svg {
    animation: optibot-spin 1s linear infinite;
}

@keyframes optibot-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.optibot-send svg {
    width: 20px;
    height: 20px;
}


/* Footer Note */
.optibot-footer-note {
    text-align: center;
    font-size: 12px;
    color: var(--optibot-text-secondary);
    margin-top: 12px;
    max-width: var(--optibot-max-width);
    margin-left: auto;
    margin-right: auto;
}

/* =========================================
   Floating Chat Button
   ========================================= */
.optibot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #10a37f;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 9998;
}

.optibot-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.optibot-fab svg {
    width: 24px;
    height: 24px;
}

/* Floating container positioning */
.optibot-position-floating {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    overflow: hidden;
    background: var(--optibot-bg);
}

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

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

.optibot-messages::-webkit-scrollbar-thumb {
    background: var(--optibot-border);
    border-radius: 3px;
}

.optibot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--optibot-text-secondary);
}

/* =========================================
   Safety Disclaimer Styling
   ========================================= */
.optibot-disclaimer {
    margin-top: 12px;
    padding: 10px 14px;
    background: #fff8e6;
    border-left: 3px solid #f59e0b;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: #92400e;
}

.optibot-theme-dark .optibot-disclaimer {
    background: #422006;
    color: #fcd34d;
}

/* =========================================
   Responsive Design
   ========================================= */
@media (max-width: 768px) {
    .optibot-messages {
        padding: 16px;
    }

    .optibot-input-area {
        padding: 12px 16px 20px;
    }

    .optibot-message {
        gap: 10px;
    }

    .optibot-message-avatar,
    .optibot-typing-avatar {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .optibot-message-avatar svg,
    .optibot-typing-avatar svg {
        width: 18px;
        height: 18px;
    }

    .optibot-message-user .optibot-message-content,
    .optibot-message-assistant .optibot-message-content {
        padding: 10px 14px;
        font-size: 15px;
    }

    .optibot-message-user .optibot-message-content {
        max-width: 80%;
    }

    .optibot-message-assistant .optibot-message-content {
        max-width: 90%;
    }

    .optibot-typing-bubble {
        padding: 12px 16px;
    }

    .optibot-welcome-content h2 {
        font-size: 24px;
    }

    .optibot-position-floating {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .optibot-message-user .optibot-message-content {
        max-width: 85%;
    }

    .optibot-message-assistant .optibot-message-content {
        max-width: 92%;
    }

    .optibot-message-content {
        font-size: 14px;
    }
}

/* =========================================
   Animations
   ========================================= */
@keyframes optibot-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
    .optibot-input-area,
    .optibot-fab {
        display: none;
    }
    
    .optibot-messages {
        height: auto !important;
        overflow: visible;
    }

    .optibot-message-user .optibot-message-content,
    .optibot-message-assistant .optibot-message-content {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}


/* =========================================
   NEW FEATURES: Voice, Upload, Download
   Added: [Current Date]
   ========================================= */

/* =========================================
   1. INPUT WRAPPER - Updated Layout
   ========================================= */
.optibot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--optibot-bg);
    border: 1px solid var(--optibot-input-border);
    border-radius: var(--optibot-radius);
    padding: 8px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.optibot-input-wrapper.drag-over {
    border-color: #15BECF;
    background: rgba(21, 190, 207, 0.05);
    border-style: dashed;
}

/* =========================================
   2. ACTION BUTTONS - Base Styles
   ========================================= */
.optibot-action-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--optibot-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.optibot-action-btn:hover {
    background: rgba(21, 190, 207, 0.1);
    color: #15BECF;
}

.optibot-action-btn:active {
    transform: scale(0.95);
}

.optibot-action-btn svg {
    width: 20px;
    height: 20px;
}

.optibot-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================================
   3. VOICE BUTTON
   ========================================= */
.optibot-voice-btn.recording {
    background: #ef4444;
    color: white;
    animation: optibot-pulse-recording 1.5s infinite;
}

.optibot-voice-btn.recording:hover {
    background: #dc2626;
    color: white;
}

@keyframes optibot-pulse-recording {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

/* Voice not supported state */
.optibot-voice-btn.not-supported {
    display: none;
}

/* =========================================
   4. UPLOAD BUTTON
   ========================================= */
.optibot-file-input {
    display: none !important;
}


/* =========================================
   6. RECORDING INDICATOR
   ========================================= */
.optibot-recording-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-bottom: none;
    border-radius: var(--optibot-radius) var(--optibot-radius) 0 0;
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
}

.optibot-recording-indicator.active {
    display: flex;
}

.optibot-recording-indicator.active + .optibot-input-wrapper {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.optibot-recording-dot {
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    animation: optibot-blink 1s infinite;
}

@keyframes optibot-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.optibot-recording-text {
    font-size: 14px;
    color: #dc2626;
    font-weight: 500;
    flex: 1;
}

.optibot-recording-time {
    font-size: 14px;
    color: #ef4444;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* Dark theme */
.optibot-theme-dark .optibot-recording-indicator {
    background: #450a0a;
    border-color: #7f1d1d;
}

.optibot-theme-dark .optibot-recording-text {
    color: #fca5a5;
}

.optibot-theme-dark .optibot-recording-time {
    color: #f87171;
}

/* =========================================
   7. IMAGE PREVIEW
   ========================================= */
.optibot-preview-container {
    display: none;
    padding: 10px 14px;
    background: var(--optibot-input-bg);
    border: 1px solid var(--optibot-input-border);
    border-bottom: none;
    border-radius: var(--optibot-radius) var(--optibot-radius) 0 0;
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
}

.optibot-preview-container.active {
    display: block;
}

.optibot-preview-container.active + .optibot-input-wrapper,
.optibot-recording-indicator.active + .optibot-preview-container.active + .optibot-input-wrapper {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.optibot-preview-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--optibot-bg);
    border: 1px solid var(--optibot-border);
    border-radius: 8px;
    padding: 8px 12px;
    max-width: 280px;
}

.optibot-preview-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--optibot-input-bg);
}

.optibot-preview-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.optibot-preview-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--optibot-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.optibot-preview-size {
    font-size: 11px;
    color: var(--optibot-text-secondary);
    margin-top: 2px;
}

.optibot-preview-remove {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--optibot-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.optibot-preview-remove:hover {
    background: #fee2e2;
    color: #ef4444;
}

.optibot-preview-remove svg {
    width: 16px;
    height: 16px;
}

/* Dark theme */
.optibot-theme-dark .optibot-preview-remove:hover {
    background: #450a0a;
}

/* =========================================
   8. DOWNLOAD TRANSCRIPT BUTTON
   ========================================= */
.optibot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 10;
}

.optibot-download-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--optibot-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.optibot-download-btn:hover {
    background: rgba(21, 190, 207, 0.1);
    color: #15BECF;
}

.optibot-download-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.optibot-download-btn svg {
    width: 20px;
    height: 20px;
}

/* Tooltip */
.optibot-download-btn[title] {
    position: relative;
}

/* =========================================
   9. IMAGE IN USER MESSAGE
   ========================================= */
.optibot-message-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.optibot-message-image:hover {
    transform: scale(1.02);
}

/* Image lightbox */
.optibot-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    cursor: pointer;
    animation: optibot-fade-in 0.2s ease;
}

.optibot-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.optibot-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.optibot-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.optibot-lightbox-close svg {
    width: 24px;
    height: 24px;
}

/* =========================================
   10. ERROR STYLES (already exists, ensure it's there)
   ========================================= */
.optibot-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px 16px;
    color: #dc2626;
    font-size: 14px;
    margin: 8px 0;
    animation: optibot-fade-in 0.3s ease;
}

.optibot-theme-dark .optibot-error {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

/* =========================================
   11. RESPONSIVE ADJUSTMENTS
   ========================================= */
@media (max-width: 768px) {
    .optibot-action-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .optibot-action-btn svg {
        width: 18px;
        height: 18px;
    }

    .optibot-send {
        width: 32px;
        height: 32px;
        min-width: 32px;
        border-radius: 50% !important; /* ADDED: Keep circle on mobile */
    }

    .optibot-send svg {
        width: 16px;
        height: 16px;
    }

    .optibot-preview-thumb {
        width: 40px;
        height: 40px;
    }

    .optibot-preview-item {
        max-width: 220px;
    }

    .optibot-header-actions {
        top: 8px;
        right: 12px;
    }

    .optibot-download-btn {
        width: 32px;
        height: 32px;
    }

    .optibot-download-btn svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .optibot-input-wrapper {
        gap: 6px;
        padding: 6px 10px;
    }

    .optibot-recording-indicator,
    .optibot-preview-container {
        padding: 8px 10px;
    }
}


/* =========================================
   IMPROVED TYPING INDICATOR
   ========================================= */
.optibot-typing-bubble {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e5e5;
    min-width: 70px;
}

.optibot-typing-dot {
    width: 8px;
    height: 8px;
    background: #10a37f;
    border-radius: 50%;
    animation: optibot-typing-bounce 1.4s infinite ease-in-out both;
}

.optibot-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

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

@keyframes optibot-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Dark theme adjustments for bot messages */
.optibot-theme-dark .optibot-message-assistant .optibot-message-content {
    background: #2f2f2f;
    border-color: #424242;
}

.optibot-theme-dark .optibot-typing-bubble {
    background: #2f2f2f;
    border-color: #424242;
}

.optibot-theme-dark .optibot-typing-dot {
    background: #10a37f;
}



/* =========================================
   ACCESSIBILITY - Text-to-Speech & Hands-Free Mode
   ========================================= */

/* Accessibility Toggle Button */
.optibot-accessibility-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--optibot-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
    position: relative;
}

.optibot-accessibility-btn:hover {
    background: rgba(21, 190, 207, 0.1);
    color: #15BECF;
}

.optibot-accessibility-btn.active {
    background: #10a37f;
    color: white;
}

.optibot-accessibility-btn.active:hover {
    background: #0d8a6a;
}

.optibot-accessibility-btn svg {
    width: 20px;
    height: 20px;
}

/* Hands-free mode indicator */
.optibot-handsfree-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #10a37f 0%, #15BECF 100%);
    color: white;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    margin: 0 16px 12px 16px;
    max-width: var(--optibot-max-width);
    margin-left: auto;
    margin-right: auto;
}

.optibot-handsfree-indicator.active {
    display: flex;
    animation: optibot-fade-in 0.3s ease;
}

.optibot-handsfree-icon {
    width: 20px;
    height: 20px;
    animation: optibot-pulse-icon 2s ease-in-out infinite;
}

@keyframes optibot-pulse-icon {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.optibot-handsfree-text {
    flex: 1;
}

.optibot-handsfree-stop {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.optibot-handsfree-stop:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Speaking indicator on messages */
.optibot-message.speaking .optibot-message-content {
    box-shadow: 0 0 0 2px #10a37f, 0 2px 8px rgba(16, 163, 127, 0.3);
}

.optibot-message.speaking .optibot-message-avatar {
    animation: optibot-speaking-pulse 1s ease-in-out infinite;
}

@keyframes optibot-speaking-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 163, 127, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(16, 163, 127, 0);
    }
}

/* Speaker button on each message */
.optibot-speak-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--optibot-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    margin-left: 8px;
    flex-shrink: 0;
}

.optibot-message:hover .optibot-speak-btn {
    opacity: 1;
}

.optibot-speak-btn:hover {
    background: rgba(16, 163, 127, 0.1);
    color: #10a37f;
}

.optibot-speak-btn.speaking {
    background: #10a37f;
    color: white;
    opacity: 1;
    animation: optibot-pulse-icon 1s ease-in-out infinite;
}

.optibot-speak-btn svg {
    width: 16px;
    height: 16px;
}

/* Accessibility settings panel */
.optibot-a11y-panel {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--optibot-bg);
    border: 1px solid var(--optibot-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 8px;
    min-width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.optibot-a11y-panel.active {
    display: block;
    animation: optibot-fade-in 0.2s ease;
}

.optibot-a11y-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--optibot-text);
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.optibot-a11y-title svg {
    width: 18px;
    height: 18px;
    color: #10a37f;
}

.optibot-a11y-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--optibot-border);
}

.optibot-a11y-option:last-child {
    border-bottom: none;
}

.optibot-a11y-label {
    font-size: 13px;
    color: var(--optibot-text);
}

.optibot-a11y-description {
    font-size: 11px;
    color: var(--optibot-text-secondary);
    margin-top: 2px;
}

/* Toggle switch */
.optibot-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.optibot-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.optibot-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.optibot-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.optibot-toggle input:checked + .optibot-toggle-slider {
    background-color: #10a37f;
}

.optibot-toggle input:checked + .optibot-toggle-slider:before {
    transform: translateX(20px);
}

/* Voice speed selector */
.optibot-voice-speed {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.optibot-voice-speed select {
    padding: 4px 8px;
    border: 1px solid var(--optibot-border);
    border-radius: 4px;
    font-size: 12px;
    background: var(--optibot-bg);
    color: var(--optibot-text);
}

/* Dark theme */
.optibot-theme-dark .optibot-a11y-panel {
    background: #2f2f2f;
    border-color: #424242;
}

.optibot-theme-dark .optibot-toggle-slider {
    background-color: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .optibot-a11y-panel {
        position: fixed;
        bottom: auto;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        right: auto;
        margin: 0;
        width: calc(100% - 32px);
        max-width: 320px;
    }
    
    .optibot-handsfree-indicator {
        margin: 0 12px 12px 12px;
        font-size: 12px;
    }
}

/* =========================================
   FULL AUTO MODE - For Disabled Users
   ========================================= */

/* Full Auto Mode Start Button */
.optibot-fullscreen-toggle {
    position: absolute;
    top: 12px;
    left: 16px;
    z-index: 10;
}

.optibot-auto-mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #10a37f 0%, #15BECF 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(16, 163, 127, 0.3);
}

.optibot-auto-mode-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(16, 163, 127, 0.4);
}

.optibot-auto-mode-btn svg {
    width: 18px;
    height: 18px;
}

.optibot-auto-mode-btn.active {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.optibot-auto-mode-btn.active:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Full Auto Mode Overlay */
.optibot-auto-mode-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 999999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.optibot-auto-mode-overlay.active {
    display: flex;
    animation: optibot-fade-in 0.5s ease;
}

/* Auto Mode Header */
.optibot-auto-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.optibot-auto-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.optibot-auto-logo-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.optibot-auto-logo-icon svg {
    width: 28px;
    height: 28px;
    color: #10a37f;
}

.optibot-auto-logo-text {
    font-size: 24px;
    font-weight: 700;
}

.optibot-auto-exit {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.optibot-auto-exit:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Content Area */
.optibot-auto-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 800px;
    width: 100%;
    text-align: center;
}

/* Status Display */
.optibot-auto-status {
    margin-bottom: 40px;
}

.optibot-auto-status-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 163, 127, 0.2);
    border: 3px solid #10a37f;
    transition: all 0.3s ease;
}

.optibot-auto-status-icon svg {
    width: 60px;
    height: 60px;
    color: #10a37f;
}

.optibot-auto-status-icon.listening {
    background: rgba(21, 190, 207, 0.2);
    border-color: #15BECF;
    animation: optibot-pulse-large 2s ease-in-out infinite;
}

.optibot-auto-status-icon.listening svg {
    color: #15BECF;
}

.optibot-auto-status-icon.thinking {
    background: rgba(251, 191, 36, 0.2);
    border-color: #fbbf24;
    animation: optibot-spin-slow 2s linear infinite;
}

.optibot-auto-status-icon.thinking svg {
    color: #fbbf24;
}

.optibot-auto-status-icon.speaking {
    background: rgba(16, 163, 127, 0.2);
    border-color: #10a37f;
    animation: optibot-pulse-large 1s ease-in-out infinite;
}

.optibot-auto-status-icon.speaking svg {
    color: #10a37f;
}

@keyframes optibot-pulse-large {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(21, 190, 207, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 20px rgba(21, 190, 207, 0);
    }
}

@keyframes optibot-spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.optibot-auto-status-text {
    font-size: 28px;
    font-weight: 600;
    color: white;
    margin-bottom: 8px;
}

.optibot-auto-status-hint {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.6);
}

/* Message Display */
.optibot-auto-message {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px 32px;
    margin-bottom: 24px;
    max-width: 100%;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.optibot-auto-message-text {
    font-size: 20px;
    line-height: 1.6;
    color: white;
}

.optibot-auto-message-text.user {
    color: #15BECF;
    font-style: italic;
}

.optibot-auto-message-text.user::before {
    content: '"';
}

.optibot-auto-message-text.user::after {
    content: '"';
}

/* Waveform Animation */
.optibot-auto-waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 40px;
    margin-top: 20px;
}

.optibot-auto-waveform.hidden {
    visibility: hidden;
}

.optibot-auto-wave-bar {
    width: 4px;
    height: 20px;
    background: #15BECF;
    border-radius: 2px;
    animation: optibot-wave 1s ease-in-out infinite;
}

.optibot-auto-wave-bar:nth-child(1) { animation-delay: 0s; }
.optibot-auto-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.optibot-auto-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.optibot-auto-wave-bar:nth-child(4) { animation-delay: 0.3s; }
.optibot-auto-wave-bar:nth-child(5) { animation-delay: 0.4s; }
.optibot-auto-wave-bar:nth-child(6) { animation-delay: 0.5s; }
.optibot-auto-wave-bar:nth-child(7) { animation-delay: 0.4s; }
.optibot-auto-wave-bar:nth-child(8) { animation-delay: 0.3s; }
.optibot-auto-wave-bar:nth-child(9) { animation-delay: 0.2s; }

@keyframes optibot-wave {
    0%, 100% {
        height: 10px;
        opacity: 0.5;
    }
    50% {
        height: 35px;
        opacity: 1;
    }
}

/* Footer */
.optibot-auto-footer {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
    .optibot-auto-mode-overlay {
        padding: 20px;
    }

    .optibot-auto-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .optibot-auto-logo-text {
        font-size: 20px;
    }

    .optibot-auto-status-icon {
        width: 100px;
        height: 100px;
    }

    .optibot-auto-status-icon svg {
        width: 50px;
        height: 50px;
    }

    .optibot-auto-status-text {
        font-size: 22px;
    }

    .optibot-auto-message {
        padding: 16px 20px;
    }

    .optibot-auto-message-text {
        font-size: 16px;
    }

    .optibot-auto-mode-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}