/**
 * MxChat Plugin Editor Styles
 * Matching MxChat Admin Chat interface exactly
 */

/* Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Main Container */
.mxchatpe-page-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 32px);
    background-color: #fff;
    color: #212529;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    width: calc(100vw - 175px);
    position: fixed;
    margin-top: 0px;
    z-index: 2;
}

/* Header */
.mxchatpe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #212121;
    border-bottom: 4px solid transparent;
    border-image: linear-gradient(135deg, #fa73e6, #7873f5, #3ac9d1);
    border-image-slice: 1;
    position: relative;
    z-index: 10;
}

.mxchatpe-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle at center,
        rgba(250, 115, 230, 0.08) 0%,
        rgba(120, 115, 245, 0.08) 50%,
        rgba(58, 201, 209, 0.08) 100%
    );
    z-index: -1;
}

.mxchatpe-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mxchatpe-logo img {
    height: 32px;
    width: auto;
}

.mxchatpe-logo h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    padding: 0;
    color: white;
}

/* Action buttons */
.mxchatpe-actions {
    display: flex;
    gap: 8px;
}

.mxchatpe-action-btn {
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
}

.mxchatpe-action-btn.settings {
    background: #f272f2;
}

.mxchatpe-action-btn.history {
    background: #4a9cff;
}

.mxchatpe-action-btn.new {
    background: #4ae2e2;
}

.mxchatpe-action-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.mxchatpe-btn-icon {
    margin-right: 4px;
}

/* Mobile menu toggle */
.mxchatpe-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}

/* Mobile dropdown menu */
.mxchatpe-mobile-menu {
    display: none;
    position: absolute;
    top: 60px;
    right: 15px;
    background: #2a2a30;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 100;
    flex-direction: column;
    overflow: hidden;
}

.mxchatpe-mobile-menu .mxchatpe-action-btn {
    border-radius: 0;
    padding: 10px 15px;
    width: 100%;
    justify-content: flex-start;
}

/* Content Area */
.mxchatpe-content-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Conversation Area */
.mxchatpe-conversation {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Message Styling */
.mxchatpe-message {
    display: flex;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    padding: 8px 0;
}

.mxchatpe-message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0px;
    padding: 0px;
    max-width: 100%;
}

.mxchatpe-message-header {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mxchatpe-message-sender {
    font-weight: 500;
    font-size: 14px;
    color: #666;
}

.mxchatpe-message-text {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    overflow: auto;
}

.mxchatpe-message-text pre {
    background: #f1f3f9;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 14px;
    margin: 15px 0;
    border: 1px solid #e0e0e0;
}

.mxchatpe-message-text code {
    background: #f1f3f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.mxchatpe-message-text pre code {
    background: transparent;
    padding: 0;
}

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

.mxchatpe-message-text p:first-child {
    margin-top: 0;
}

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

/* Message timestamp */
.mxchatpe-message-timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
}

.mxchatpe-message-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mxchatpe-message:hover .mxchatpe-message-actions {
    opacity: 1;
}

/* User vs Assistant Messages */
.mxchatpe-user .mxchatpe-message-sender {
    color: #7873f5;
}

.mxchatpe-assistant .mxchatpe-message-sender {
    color: #fa73e6;
}

/* Copy button */
.mxchatpe-copy-btn {
    background: transparent;
    border: 1px solid rgba(120, 115, 245, 0.2);
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.mxchatpe-copy-btn:hover {
    background: rgba(120, 115, 245, 0.05);
    border-color: #7873f5;
    color: #7873f5;
}

/* Input Area */
.mxchatpe-input-area {
    padding: 16px 24px 20px;
    background: #fff;
    border-top: 1px solid rgba(120, 115, 245, 0.1);
}

.mxchatpe-input-container {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

#mxchatpe-message-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

/* Top row with input and send button */
.mxchatpe-input-row {
    display: flex;
    align-items: flex-end;
    position: relative;
    padding: 12px 16px;
    background: #f8f9ff;
    border-radius: 24px;
    border: 1px solid rgba(120, 115, 245, 0.2);
    transition: all 0.3s ease;
}

.mxchatpe-input-row:focus-within {
    border-color: #7873f5;
    box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.1);
    background: rgba(250, 115, 230, 0.03);
}

.mxchatpe-input-field-wrapper {
    flex: 1;
    position: relative;
}

.mxchatpe-message-input {
    width: 100%;
    min-height: 38px;
    max-height: 200px;
    border: none;
    outline: none;
    resize: none;
    padding: 10px;
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
    background: transparent;
}

.mxchatpe-message-input::placeholder {
    color: #999;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.mxchatpe-message-input:focus::placeholder {
    opacity: 0.5;
}

.mxchatpe-message-input:focus {
    outline: none;
    box-shadow: none;
    border: none;
}

/* Send button */
.mxchatpe-send-btn-wrapper {
    margin-left: 8px;
}

.mxchatpe-send-btn {
    background: linear-gradient(135deg, #fa73e6, #7873f5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mxchatpe-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(120, 115, 245, 0.3);
}

.mxchatpe-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Bottom row with tools and plugin selector */
.mxchatpe-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

/* Tools section */
.mxchatpe-tools {
    display: flex;
    gap: 4px;
}

.mxchatpe-tool-button {
    background: transparent;
    border: 1px solid rgba(120, 115, 245, 0.2);
    color: #666;
    padding: 8px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.mxchatpe-tool-button:hover {
    background: rgba(120, 115, 245, 0.05);
    border-color: #7873f5;
    color: #7873f5;
}

/* Plugin Selector */
.mxchatpe-model-selector {
    position: relative;
}

.mxchatpe-plugin-select {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    color: #666;
    background: white;
    border: 1px solid rgba(120, 115, 245, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 180px;
    max-width: 250px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.mxchatpe-plugin-select:hover {
    border-color: #7873f5;
}

.mxchatpe-plugin-select:focus {
    outline: none;
    border-color: #7873f5;
    box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.1);
}

.mxchatpe-plugin-select option {
    padding: 8px;
}

/* Tool Actions */
.mxchatpe-tool-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #ecfdf5;
    border-radius: 6px;
    font-size: 12px;
    color: #059669;
    max-width: fit-content;
    margin-bottom: 8px;
}

.mxchatpe-tool-action.error {
    background: #fef2f2;
    color: #dc2626;
}

.mxchatpe-status-icon {
    font-weight: bold;
}

.mxchatpe-tool-timestamp {
    font-size: 10px;
    color: #888;
    margin-left: auto;
    padding-left: 12px;
}

/* Thinking Animation */
.mxchatpe-thinking-indicator {
    display: flex;
    gap: 5px;
    align-items: center;
    height: 24px;
    padding: 12px 0;
}

.mxchatpe-thinking-dot {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #fa73e6, #7873f5);
    border-radius: 50%;
    animation: mxchatpe-thinking-animation 1.4s infinite;
    opacity: 0.7;
}

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

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

@keyframes mxchatpe-thinking-animation {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

/* Error Message */
.mxchatpe-error .mxchatpe-message-text {
    color: #d63638;
    border-left: 4px solid #d63638;
    padding-left: 12px;
}

/* Settings Modal */
.mxchatpe-modal-settings {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 0px;
}

.mxchatpe-modal-content-settings {
    background-color: #fff;
    margin: 50px auto;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(120, 115, 245, 0.2);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 100px);
    border: 1px solid rgba(120, 115, 245, 0.1);
    overflow: hidden;
}

.mxchatpe-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(120, 115, 245, 0.1);
    background: #f8f9ff;
    border-radius: 12px 12px 0 0;
}

.mxchatpe-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.mxchatpe-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.mxchatpe-modal-close:hover {
    background: rgba(120, 115, 245, 0.1);
    color: #7873f5;
}

.mxchatpe-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Settings form */
#mxchatpe-settings-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Settings sections */
.mxchatpe-settings-section {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mxchatpe-settings-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(120, 115, 245, 0.1);
}

/* Settings fields */
.mxchatpe-settings-field {
    margin-bottom: 16px;
}

.mxchatpe-settings-field:last-child {
    margin-bottom: 0;
}

.mxchatpe-settings-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #555;
}

.mxchatpe-settings-field input,
.mxchatpe-settings-field select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(120, 115, 245, 0.2);
    background-color: #fff;
    font-size: 14px;
    color: #333;
    transition: all 0.2s ease;
}

.mxchatpe-settings-field input:focus,
.mxchatpe-settings-field select:focus {
    outline: none;
    border-color: #7873f5;
    box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.1);
}

.mxchatpe-settings-field input:hover,
.mxchatpe-settings-field select:hover {
    border-color: #7873f5;
}

/* Settings action buttons */
.mxchatpe-settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.mxchatpe-save-settings-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    background: linear-gradient(135deg, #fa73e6, #7873f5);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mxchatpe-save-settings-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(120, 115, 245, 0.3);
}

/* Notification */
.mxchatpe-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
}

.mxchatpe-notification-visible {
    transform: translateY(0);
    opacity: 1;
}

/* Hide WP admin elements */
#wpcontent {
    padding-left: 0px;
}

#wpfooter {
    display: none;
}

/* Scrollbar */
.mxchatpe-conversation::-webkit-scrollbar {
    width: 5px;
}

.mxchatpe-conversation::-webkit-scrollbar-track {
    background: transparent;
}

.mxchatpe-conversation::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

/* Responsive Styles */
@media screen and (max-width: 782px) {
    .mxchatpe-page-wrapper {
        height: calc(100vh - 46px - 50px);
        width: 100%;
        margin: 0;
    }

    .mxchatpe-logo h2 {
        display: none;
    }

    .mxchatpe-message-content {
        max-width: 100%;
    }

    .auto-fold #wpcontent {
        padding-left: 0px;
    }

    .mxchatpe-header {
        padding: 12px 16px;
    }

    .mxchatpe-conversation {
        padding: 16px;
        padding-bottom: 100px;
    }

    .mxchatpe-input-area {
        padding: 16px;
    }

    .mxchatpe-message-input {
        padding: 12px;
    }

    .mxchatpe-plugin-select {
        min-width: 100px;
        max-width: 150px;
        font-size: 12px;
    }

    .mxchatpe-bottom-row {
        gap: 8px;
    }
}

@media (max-width: 768px) {
    .mxchatpe-action-btn .mxchatpe-btn-text {
        display: none;
    }

    .mxchatpe-action-btn {
        width: 32px;
        height: 32px;
        padding: 0;
        justify-content: center;
    }

    .mxchatpe-btn-icon {
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .mxchatpe-actions {
        display: none;
    }

    .mxchatpe-menu-toggle {
        display: block;
    }

    .mxchatpe-mobile-menu.active {
        display: flex;
    }
}

/* ========================================
   Frontend Plugin Editor Styles
   ======================================== */

/* Full-page webapp mode - hide WordPress theme elements when plugin editor is active */
body:has(.mxchatpe-wrapper) {
    overflow: hidden !important;
}

body:has(.mxchatpe-wrapper) > header,
body:has(.mxchatpe-wrapper) > footer,
body:has(.mxchatpe-wrapper) > .site-header,
body:has(.mxchatpe-wrapper) > .site-footer,
body:has(.mxchatpe-wrapper) #masthead,
body:has(.mxchatpe-wrapper) #colophon,
body:has(.mxchatpe-wrapper) .wp-site-blocks > header,
body:has(.mxchatpe-wrapper) .wp-site-blocks > footer,
body:has(.mxchatpe-wrapper) .elementor-location-header,
body:has(.mxchatpe-wrapper) .elementor-location-footer,
body:has(.mxchatpe-wrapper) nav.main-navigation,
body:has(.mxchatpe-wrapper) .site-branding,
body:has(.mxchatpe-wrapper) #site-header,
body:has(.mxchatpe-wrapper) #site-footer {
    display: none !important;
}

/* Make the main content area full viewport */
body:has(.mxchatpe-wrapper) .site-content,
body:has(.mxchatpe-wrapper) .entry-content,
body:has(.mxchatpe-wrapper) .page-content,
body:has(.mxchatpe-wrapper) main,
body:has(.mxchatpe-wrapper) #primary,
body:has(.mxchatpe-wrapper) #main,
body:has(.mxchatpe-wrapper) .content-area,
body:has(.mxchatpe-wrapper) article {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Frontend Container - Fixed height chatbot-style layout */
.mxchatpe-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    height: 700px;
    max-height: 700px;
    display: flex;
    flex-direction: column;
}

/* Header in frontend container must not shrink */
.mxchatpe-container > .mxchatpe-header {
    flex-shrink: 0;
}

/* Upload Area */
.mxchatpe-upload-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 24px;
}

/* Dual Upload Grid */
.mxchatpe-upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    width: 100%;
    max-width: 900px;
}

.mxchatpe-upload-box {
    width: 100%;
    padding: 40px 30px;
    border: 2px dashed rgba(120, 115, 245, 0.3);
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
    position: relative;
}

.mxchatpe-upload-box:hover,
.mxchatpe-upload-box.dragover {
    border-color: #7873f5;
    background: rgba(120, 115, 245, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(120, 115, 245, 0.15);
}

.mxchatpe-upload-box.file-selected {
    border-color: #10b981;
    border-style: solid;
    background: rgba(16, 185, 129, 0.05);
}

/* Primary (Core Plugin) styling */
.mxchatpe-upload-primary {
    border-color: rgba(250, 115, 230, 0.4);
}

.mxchatpe-upload-primary:hover,
.mxchatpe-upload-primary.dragover {
    border-color: #fa73e6;
    background: rgba(250, 115, 230, 0.05);
}

/* Secondary (Add-on Plugin) styling */
.mxchatpe-upload-secondary {
    border-color: rgba(120, 115, 245, 0.3);
    opacity: 0.9;
}

.mxchatpe-upload-secondary:hover,
.mxchatpe-upload-secondary.dragover {
    border-color: #7873f5;
    opacity: 1;
}

/* Upload Badge */
.mxchatpe-upload-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 16px;
    background: linear-gradient(135deg, #fa73e6, #7873f5);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}

.mxchatpe-upload-badge.mxchatpe-badge-optional {
    background: linear-gradient(135deg, #7873f5, #5a55d4);
}

.mxchatpe-upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.mxchatpe-upload-box h3 {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.mxchatpe-upload-box p {
    margin: 0 0 6px;
    color: #666;
    font-size: 14px;
}

.mxchatpe-upload-hint {
    font-size: 12px !important;
    color: #999 !important;
}

.mxchatpe-upload-btn {
    margin-top: 16px;
    padding: 10px 24px;
    background: linear-gradient(135deg, #fa73e6, #7873f5);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mxchatpe-upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(120, 115, 245, 0.3);
}

.mxchatpe-upload-btn.mxchatpe-btn-secondary {
    background: linear-gradient(135deg, #7873f5, #5a55d4);
}

/* File Selected Indicator */
.mxchatpe-file-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    margin-top: 16px;
}

.mxchatpe-file-icon {
    color: #10b981;
    font-size: 18px;
    font-weight: bold;
}

.mxchatpe-file-name {
    color: #333;
    font-size: 14px;
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mxchatpe-file-remove {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.mxchatpe-file-remove:hover {
    transform: scale(1.2);
}

/* Upload Actions (Start Button) */
.mxchatpe-upload-actions {
    margin-top: 8px;
}

.mxchatpe-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 48px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.mxchatpe-start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.mxchatpe-start-icon {
    font-size: 16px;
}

/* Upload Progress */
.mxchatpe-upload-progress {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.mxchatpe-progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.mxchatpe-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #fa73e6, #7873f5);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

#mxchatpe-upload-status {
    color: #666;
    font-size: 14px;
}

/* Editor Area - Takes remaining space with internal scroll */
.mxchatpe-editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Important for flexbox to allow shrinking */
}

/* Plugin info bar stays at top */
.mxchatpe-container .mxchatpe-editor-area .mxchatpe-plugin-info {
    flex-shrink: 0;
}

/* Conversation scroll container - takes remaining space */
.mxchatpe-container .mxchatpe-editor-area .mxchatpe-conversation {
    flex: 1 1 0;
    overflow-y: auto !important;
    min-height: 0;
    max-height: none;
}

/* Input area stays fixed at bottom */
.mxchatpe-container .mxchatpe-editor-area .mxchatpe-input-area {
    flex-shrink: 0;
    border-top: 1px solid rgba(120, 115, 245, 0.1);
    background: #fff;
}

/* Plugin Info Bar */
.mxchatpe-plugin-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #f8f9ff;
    border-bottom: 1px solid rgba(120, 115, 245, 0.1);
}

.mxchatpe-plugin-name {
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

.mxchatpe-download-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mxchatpe-download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Token Usage Indicator */
.mxchatpe-token-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: rgba(120, 115, 245, 0.08);
    border-radius: 20px;
    font-size: 12px;
}

.mxchatpe-token-bar {
    width: 60px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.mxchatpe-token-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
    width: 0%;
}

.mxchatpe-token-text {
    color: #666;
    font-weight: 500;
    min-width: 75px;
    text-align: right;
}

/* Thinking text */
.mxchatpe-thinking-text {
    color: #7873f5;
    font-size: 14px;
    margin-right: 8px;
}

/* Login Required Message */
.mxchatpe-login-required,
.mxchatpe-error {
    padding: 40px;
    text-align: center;
    background: #fef2f2;
    border-radius: 12px;
    color: #dc2626;
}

.mxchatpe-login-required a,
.mxchatpe-error a {
    color: #7873f5;
    text-decoration: none;
}

.mxchatpe-login-required a:hover,
.mxchatpe-error a:hover {
    text-decoration: underline;
}

/* Notification types */
.mxchatpe-notification-success {
    background: #10b981 !important;
}

.mxchatpe-notification-error {
    background: #ef4444 !important;
}

/* Frontend-specific responsive */
@media (max-width: 768px) {
    .mxchatpe-container {
        border-radius: 0;
        height: 100%;
        max-height: 100%;
    }

    .mxchatpe-upload-area {
        padding: 20px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    /* Stack upload boxes vertically on mobile */
    .mxchatpe-upload-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        max-width: 100%;
    }

    .mxchatpe-upload-box {
        padding: 30px 20px;
    }

    .mxchatpe-upload-icon {
        font-size: 40px;
    }

    .mxchatpe-upload-box h3 {
        font-size: 16px;
    }

    .mxchatpe-upload-box p {
        font-size: 13px;
    }

    .mxchatpe-upload-badge {
        font-size: 11px;
        padding: 3px 12px;
    }

    .mxchatpe-start-btn {
        padding: 14px 36px;
        font-size: 16px;
    }

    .mxchatpe-file-name {
        max-width: 150px;
    }

    .mxchatpe-plugin-info {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        flex-shrink: 0;
    }

    .mxchatpe-token-indicator {
        order: 2;
    }

    .mxchatpe-download-btn {
        width: 100%;
        order: 3;
    }

    .mxchatpe-editor-area {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Override admin responsive padding for frontend container */
    .mxchatpe-container .mxchatpe-conversation {
        padding-bottom: 16px;
        flex: 1;
        min-height: 0;
        overflow-y: auto !important;
    }

    .mxchatpe-container .mxchatpe-input-area {
        flex-shrink: 0;
    }
}

/* ========================================
   Sidebar / Chat History Styles
   ======================================== */

/* Wrapper for sidebar + main content */
.mxchatpe-wrapper {
    display: flex;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    margin: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: #f0f0f0;
}

/* Sidebar */
.mxchatpe-sidebar {
    width: 280px;
    background: #171717;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
}

.mxchatpe-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mxchatpe-new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #7873f5, #5a55d4);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mxchatpe-new-chat-btn:hover {
    background: linear-gradient(135deg, #8a86f7, #6b66e0);
    transform: translateY(-1px);
}

.mxchatpe-sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 4px;
}

.mxchatpe-sidebar-close:hover {
    color: #fff;
}

/* Session list */
.mxchatpe-session-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.mxchatpe-session-loading {
    color: #888;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.mxchatpe-session-empty {
    color: #666;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.mxchatpe-session-item {
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 4px;
}

.mxchatpe-session-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.mxchatpe-session-item.active {
    background: rgba(120, 115, 245, 0.2);
}

.mxchatpe-session-name {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mxchatpe-session-date {
    color: #888;
    font-size: 12px;
}

/* Sidebar overlay for mobile */
.mxchatpe-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

/* Menu button in header */
.mxchatpe-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    margin-right: 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.mxchatpe-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* When sidebar present, container adjusts */
.mxchatpe-wrapper .mxchatpe-container {
    border-radius: 0;
    flex: 1;
    min-width: 0;
    height: 100%;
    max-height: 100%;
    max-width: none;
}

/* Desktop: sidebar always visible */
@media (min-width: 769px) {
    .mxchatpe-sidebar {
        display: flex;
    }

    .mxchatpe-menu-btn {
        display: none;
    }
}

/* Mobile: sidebar is a slide-out drawer */
@media (max-width: 768px) {
    .mxchatpe-wrapper {
        flex-direction: column;
    }

    .mxchatpe-wrapper .mxchatpe-container {
        border-radius: 0;
        height: 100%;
        max-height: 100%;
    }

    .mxchatpe-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        z-index: 10000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .mxchatpe-sidebar.open {
        transform: translateX(0);
    }

    .mxchatpe-sidebar-overlay {
        z-index: 9999;
    }

    .mxchatpe-sidebar-overlay.open {
        display: block;
    }

    .mxchatpe-sidebar-close {
        display: block;
    }

    .mxchatpe-menu-btn {
        display: block;
    }

    /* Mobile editor area fills remaining space */
    .mxchatpe-editor-area {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Mobile conversation scrolling */
    .mxchatpe-conversation {
        flex: 1;
        min-height: 0;
        overflow-y: auto !important;
    }

    /* Mobile input area stays at bottom */
    .mxchatpe-input-area {
        flex-shrink: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}
