/* AI Curator Frontend Chat Styles */

.ai-curator-chat-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 100%;
    font-size: 18px;
    /* Larger base font size */
}

/* Header */
.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ai-chat-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-header-main {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ai-artifact-quick-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-artifact-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    opacity: 0.25;
    filter: grayscale(1) opacity(0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-artifact-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 0.7;
    filter: grayscale(0.5);
}

.ai-artifact-btn.ai-artifact-active {
    opacity: 1;
    filter: grayscale(0);
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.ai-artifact-btn.ai-artifact-active:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
}

.ai-artifact-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.ai-chat-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.ai-mobile-menu-toggle {
    display: none;
}

@media (max-width: 768px) {
    .ai-mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.3);
        color: white;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        cursor: pointer;
    }

    .ai-chat-controls .ai-btn-text,
    .ai-prompt-selector,
    .ai-session-selector,
    .ai-btn-primary,
    #ai-refresh-prompts-btn {
        display: none !important;
    }

    .ai-chat-controls {
        gap: 4px;
    }

    .ai-btn-magic,
    .ai-btn-secondary {
        display: flex !important;
    }
}

.ai-prompt-selector {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    max-width: 200px;
    min-width: 150px;
    transition: all 0.3s ease;
}

.ai-prompt-selector:hover {
    background: white;
    border-color: rgba(255, 255, 255, 0.5);
}

.ai-prompt-selector option {
    background: white;
    color: #667eea;
    padding: 8px;
}

.ai-session-selector {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 13px;
    cursor: pointer;
    max-width: 150px;
    min-width: 100px;
}

.ai-session-selector option {
    background: #667eea;
    color: white;
}

.ai-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.ai-btn-primary {
    background: white;
    color: #667eea;
}

.ai-btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.ai-btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.ai-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.ai-btn-secondary.ai-btn-active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.ai-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* Chat Body */
.ai-chat-body {
    display: flex;
    flex-direction: column;
    background: #f9f9f9;
    position: relative;
    overflow: hidden;
    transition: background 0.5s ease;
}

/* Show background image through the body if set on container */
.ai-curator-chat-container[style*="background-image"] .ai-chat-body {
    background: rgba(249, 249, 249, 0.85);
}

.ai-curator-chat-container[style*="background-image"] .ai-chat-messages {
    background: transparent;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

/* Welcome Message */
.ai-welcome-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: fadeInUp 0.5s ease;
}

.ai-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-user-avatar {
    background: #f0f0f0;
    padding: 4px;
}

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

.ai-impersonate-welcome {
    background: #fff3cd;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
}

.ai-message-content {
    background: white;
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    max-width: 85%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    font-size: 16px;
    line-height: 1.5;
    position: relative;
}

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

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

.ai-message-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.ai-message-content a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.ai-message-content .post-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    margin: 2px 4px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.ai-message-content .post-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
    color: white;
}

.ai-message-content .post-link .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.ai-message-content .ai-chat-image,
.ai-message-content .ai-chat-video {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    margin: 10px 0;
    display: block;
}

.ai-message-content .ai-chat-audio {
    width: 100%;
    max-width: 400px;
    margin: 10px 0;
    display: block;
}

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

.ai-message-content li {
    margin-bottom: 6px;
    line-height: 1.6;
}

.ai-message-content strong {
    color: #333;
    font-weight: 600;
}

.ai-message-content em {
    font-style: italic;
    color: #555;
}

.ai-message-content h3 {
    font-size: 16px;
    margin: 12px 0 8px 0;
    color: #667eea;
    font-weight: 600;
}

/* RTL Support */
.ai-message-content[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

.ai-message-content[dir="rtl"] ul,
.ai-message-content[dir="rtl"] ol {
    padding-left: 0;
    padding-right: 20px;
}

.ai-message-content[dir="rtl"] .post-link {
    direction: ltr;
    display: inline-flex;
}

.ai-tips {
    background: #f0f0f0;
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.ai-tips strong {
    display: block;
    margin-bottom: 8px;
    color: #667eea;
}

/* Chat Messages */
.ai-user-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: flex-end;
    animation: fadeInUp 0.3s ease;
    clear: both;
}

.ai-user-message .ai-message-content {
    background: #667eea;
    color: white;
    text-align: left;
}

.ai-ai-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: fadeInUp 0.3s ease;
    clear: both;
}

.ai-ai-message .ai-message-content {
    line-height: 1.6;
    white-space: normal;
}

/* Message Actions */
.ai-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    margin-left: 44px;
    /* Align with content */
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.ai-action-btn {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.ai-action-btn:hover {
    background: #f0f0f0;
    color: #667eea;
}

.ai-action-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.ai-action-tip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    margin-bottom: 4px;
    pointer-events: none;
}

/* Share Tooltip */
.ai-share-tooltip {
    position: absolute;
    bottom: 40px;
    left: 44px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    width: 280px;
    animation: fadeInUp 0.2s ease;
}

.ai-share-url-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.ai-share-url-row input {
    flex: 1;
    font-size: 12px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
}

.ai-copy-link-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Timing and Usage Stats */
.ai-usage-metrics {
    font-size: 11px;
    color: #888;
    margin-left: 44px;
    margin-top: 8px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 1;
    flex-wrap: wrap;
}

.ai-usage-metrics strong {
    color: #555;
    font-weight: 600;
}

.ai-usage-separator {
    color: #ddd;
    font-weight: 300;
}

.ai-cost-display {
    color: #28a745;
    /* Success green for money */
}

.ai-total-conversation-cost {
    color: #0066cc;
    font-weight: 600;
    font-size: 12px;
}

.ai-typing-stats {
    opacity: 0.8;
}

.ai-copy-link-btn.success {
    background: #28a745;
}

.ai-share-social-row {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.ai-share-social-row a {
    color: #555;
    text-decoration: none;
    transition: color 0.2s ease;
}

.ai-share-social-row a:hover {
    color: #667eea;
}

.ai-share-social-row .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.ai-share-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
}

.ai-share-close:hover {
    color: #333;
}

.ai-spin {
    animation: ai-spin 1s linear infinite;
}

@keyframes ai-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Typing Indicator */
.ai-typing-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 20px;
    background: #f0f0f0;
    animation: fadeIn 0.3s ease;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ai-typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.ai-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.ai-typing-stats {
    margin-left: auto;
    font-size: 12px;
    color: #666;
}

/* Input Container */
.ai-chat-input-container {
    border-top: 1px solid #e0e0e0;
    background: white;
}

.ai-input-wrapper {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    transition: border-color 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

.ai-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.ai-send-btn,
.ai-stop-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #667eea;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ai-send-btn:hover,
.ai-stop-btn:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.ai-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: scale(1);
}

.ai-stop-btn {
    background: #dc3545;
}

.ai-stop-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.ai-send-btn .dashicons,
.ai-stop-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Footer */
.ai-chat-footer {
    background: #f9f9f9;
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
}

.ai-session-info {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-separator {
    color: #ccc;
}

.ai-powered-by strong {
    color: #667eea;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Scrollbar Styling */
.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Gallery Modal */
.ai-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

.ai-gallery-container {
    background: white;
    border-radius: 12px;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.ai-gallery-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-gallery-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.ai-gallery-close {
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.ai-gallery-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-gallery-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.ai-gallery-tab {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.ai-gallery-tab .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.ai-gallery-tab:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.ai-gallery-tab.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
}

.ai-gallery-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    min-height: 400px;
}

.ai-gallery-loading,
.ai-gallery-empty,
.ai-gallery-error {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

.ai-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.ai-gallery-item {
    background: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ai-gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ai-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-item-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.ai-gallery-item:hover .ai-item-caption {
    transform: translateY(0);
}

.ai-gallery-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #ff4d4d;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    padding: 0;
}

.ai-gallery-item:hover .ai-gallery-delete-btn {
    opacity: 1;
}

.ai-gallery-delete-btn:hover {
    background: #ff1a1a;
    transform: scale(1.1);
}

.ai-gallery-delete-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ai-gallery-video-item {
    aspect-ratio: 16/9;
    cursor: default;
}

.ai-gallery-video-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-gallery-link-item {
    aspect-ratio: auto;
    text-align: left;
    background: white;
    border: 1px solid #eee;
    height: 100%;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.ai-link-preview {
    width: 100%;
    height: 120px;
    background: #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #eee;
}

.ai-link-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-link-icon {
    font-size: 32px;
    color: #667eea;
}

.ai-link-icon .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
}

.ai-link-details {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-link-title {
    display: block;
    font-weight: 600;
    color: #333;
    font-size: 13px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-link-domain {
    display: block;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-gallery-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 0 0 12px 12px;
}

.ai-gallery-nav-btn {
    padding: 10px 20px;
    border: 1px solid #667eea;
    border-radius: 6px;
    background: white;
    color: #667eea;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-gallery-nav-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.ai-gallery-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-gallery-nav-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

#ai-gallery-page-info {
    color: #666;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-chat-header {
        padding: 10px 12px;
    }

    .ai-chat-header h2 {
        font-size: 16px;
        width: 100%;
    }

    .ai-chat-controls {
        width: 100%;
        justify-content: space-between;
    }

    .ai-session-selector {
        flex: 1;
        max-width: none;
    }

    .ai-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .ai-message-content {
        max-width: 90%;
        font-size: 14px;
        padding: 10px 12px;
    }

    .ai-chat-messages {
        padding: 10px;
        gap: 10px;
    }

    .ai-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .ai-input-wrapper {
        padding: 8px 10px;
    }

    .ai-chat-input {
        font-size: 16px;
        padding: 8px 12px;
    }

    .ai-send-btn,
    .ai-stop-btn {
        width: 32px;
        height: 32px;
    }

    .ai-chat-footer {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 8px;
        font-size: 11px;
    }

    .ai-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .ai-gallery-content {
        padding: 15px;
    }

    .ai-gallery-pagination {
        flex-direction: column;
        gap: 10px;
    }

    .ai-gallery-nav-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .ai-curator-chat-container {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .ai-chat-header {
        padding: 8px 10px;
        border-radius: 0;
    }

    .ai-chat-header h2 {
        font-size: 15px;
    }

    .ai-btn {
        padding: 5px 8px;
        font-size: 11px;
        gap: 3px;
    }

    .ai-btn .dashicons {
        font-size: 12px;
        width: 12px;
        height: 12px;
    }

    .ai-chat-messages {
        padding: 8px;
    }

    .ai-message-content {
        max-width: 92%;
        font-size: 14px;
        padding: 8px 10px;
    }

    .ai-avatar {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* Response Time Label */
.ai-response-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

/* Media Grid (3x3 table for multiple images/videos/audio) */
.ai-media-grid {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.ai-media-grid td {
    padding: 5px;
    text-align: center;
    vertical-align: middle;
}

.ai-media-grid img,
.ai-media-grid video {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-media-grid audio {
    width: 100%;
}

/* Magic Button Styling */
.ai-btn-magic {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    animation: magicPulse 2s ease-in-out infinite;
}

.ai-btn-magic:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

@keyframes magicPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
}

/* Magic Artifact Display */
.ai-magic-artifact {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin: 15px 0;
}

.ai-magic-cover {
    width: 100%;
    height: 250px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ai-magic-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-magic-content {
    padding: 20px;
}

.ai-magic-type {
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.ai-magic-text {
    font-size: 16px;
    line-height: 1.8;
    color: #333;
    white-space: pre-wrap;
    margin-bottom: 15px;
    font-family: Georgia, serif;
}

.ai-magic-meta {
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.ai-magic-meta small {
    color: #888;
    font-size: 12px;
    font-style: italic;
}

/* ================================
   MOBILE & IPHONE OPTIMIZATIONS
   ================================ */

/* Larger fonts for better readability on all devices */
.ai-message-content {
    font-size: 20px !important;
    line-height: 1.8 !important;
}

.ai-user-message .ai-message-content {
    font-size: 20px !important;
}

.ai-ai-message .ai-message-content {
    font-size: 20px !important;
}

.ai-message-content p {
    font-size: 20px !important;
}

.ai-message-content li {
    font-size: 20px !important;
}

/* Larger buttons for touch targets (44px minimum) */
.ai-btn {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 16px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ai-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Larger input area */
.ai-chat-input {
    font-size: 20px !important;
    min-height: 50px;
    padding: 12px 16px !important;
    line-height: 1.5;
}

/* Larger send button */
#ai-frontend-chat-send,
#ai-stop-btn {
    min-width: 50px;
    min-height: 50px;
    padding: 12px;
}

#ai-frontend-chat-send .dashicons,
#ai-stop-btn .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* Header text larger */
.ai-chat-header h2 {
    font-size: 20px;
}

/* Session selector larger */
.ai-session-selector {
    font-size: 16px;
    padding: 10px 12px;
    min-height: 44px;
}

/* Mobile Menu Toggle Button */
.ai-mobile-menu-toggle {
    display: none;
}

/* Mobile Menu Modal */
.ai-mobile-menu-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10001;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
}

.ai-mobile-menu-modal.show {
    display: flex;
}

.ai-mobile-menu-content {
    background: white;
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #667eea;
}

.ai-mobile-menu-header h3 {
    margin: 0;
    font-size: 20px;
    color: #667eea;
}

.ai-mobile-menu-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-mobile-menu-item {
    margin-bottom: 15px;
}

.ai-mobile-menu-item label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-mobile-menu-item select,
.ai-mobile-menu-item button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ai-mobile-menu-item select:focus,
.ai-mobile-menu-item button:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-mobile-menu-item button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-mobile-menu-item button:active {
    transform: scale(0.98);
}

.ai-mobile-menu-item button .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    .ai-curator-chat-container {
        border-radius: 0;
        border-left: none;
        border-right: none;
        font-size: 18px;
    }

    .ai-chat-header {
        padding: 8px 12px;
        flex-direction: row;
        align-items: center;
        min-height: 48px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .ai-chat-header h2 {
        font-size: 16px;
        margin-bottom: 0;
        text-align: left;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ai-chat-controls {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        flex-wrap: nowrap;
        align-items: center;
        flex-shrink: 0;
    }

    /* Show mobile menu toggle */
    .ai-mobile-menu-toggle {
        display: inline-flex;
        background: rgba(255, 255, 255, 0.2);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.3);
        padding: 8px;
        border-radius: 6px;
        min-height: 36px;
        min-width: 36px;
        justify-content: center;
        align-items: center;
    }

    .ai-mobile-menu-toggle .dashicons {
        font-size: 20px;
        width: 20px;
        height: 20px;
    }

    /* Hide controls in a dropdown on mobile */
    .ai-chat-controls .ai-prompt-selector,
    .ai-chat-controls .ai-session-selector {
        display: none;
        position: absolute;
        top: 100%;
        right: 12px;
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        min-width: 200px;
        max-width: 300px;
    }

    .ai-chat-controls .ai-prompt-selector.show,
    .ai-chat-controls .ai-session-selector.show {
        display: block;
    }

    /* Keep only essential buttons visible */
    .ai-btn {
        flex: 0 0 auto;
        min-width: 36px;
        justify-content: center;
        min-height: 36px;
        font-size: 0;
        padding: 8px;
    }

    .ai-btn .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
        margin: 0;
    }

    /* Hide button text, show only icons on mobile */
    .ai-btn .ai-btn-text {
        display: none;
    }

    .ai-btn {
        gap: 0;
    }

    .ai-btn-primary,
    .ai-btn-secondary,
    .ai-btn-magic {
        padding: 8px;
    }

    /* Larger message text on mobile */
    .ai-message-content {
        font-size: 21px !important;
        padding: 14px 16px !important;
        max-width: 95% !important;
    }

    .ai-message-content p {
        font-size: 21px !important;
        line-height: 1.8 !important;
    }

    .ai-message-content li {
        font-size: 21px !important;
        line-height: 1.8 !important;
        margin-bottom: 10px;
    }

    .ai-message-content h3 {
        font-size: 22px !important;
    }

    /* Input area optimization */
    .ai-input-wrapper {
        padding: 12px;
        gap: 10px;
    }

    .ai-chat-input {
        font-size: 20px !important;
        min-height: 54px;
        padding: 14px 16px !important;
    }

    #ai-frontend-chat-send,
    #ai-stop-btn {
        min-width: 54px;
        min-height: 54px;
    }

    /* Avatar sizes */
    .ai-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
        flex-shrink: 0;
    }

    /* Footer text */
    .ai-chat-footer {
        padding: 12px;
        font-size: 14px;
    }

    .ai-session-info {
        font-size: 14px;
    }

    .ai-powered-by {
        font-size: 13px;
    }

    /* Gallery optimizations */
    .ai-gallery-modal {
        padding: 0;
    }

    .ai-gallery-content {
        padding: 20px 12px;
    }

    .ai-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    /* Magic artifact mobile */
    .ai-magic-artifact {
        margin: 10px 0;
    }

    .ai-magic-cover {
        height: 200px;
    }

    .ai-magic-content {
        padding: 16px;
    }

    .ai-magic-text {
        font-size: 18px !important;
        line-height: 1.8 !important;
    }

    .ai-magic-type {
        font-size: 12px;
    }

    /* Typing indicator */
    .ai-typing-indicator {
        padding: 12px 16px;
    }

    .ai-typing-stats {
        font-size: 13px;
    }
}

/* iPhone specific optimizations */
@media (max-width: 480px) {
    .ai-chat-header h2 {
        font-size: 18px;
    }

    .ai-chat-input {
        font-size: 18px !important;
        min-height: 48px;
        border-radius: 24px;
    }

    #ai-frontend-chat-send,
    #ai-stop-btn {
        min-width: 48px;
        min-height: 48px;
    }

    .ai-message-content {
        font-size: 16px !important;
        padding: 12px 16px;
    }

    .ai-message-content p,
    .ai-message-content li {
        font-size: 16px !important;
    }

    .ai-message-content h3 {
        font-size: 18px !important;
    }

    .ai-btn {
        font-size: 12px;
        padding: 6px 8px;
    }
}

@supports (padding: max(0px)) {
    .ai-curator-chat-container {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .ai-input-wrapper {
        padding-bottom: max(12px, calc(12px + env(safe-area-inset-bottom)));
    }
}

/* Prevent zoom on input focus (iOS) - but keep readability */
@media (max-width: 768px) {

    .ai-session-selector,
    input:not(.ai-chat-input),
    textarea:not(.ai-chat-input),
    select {
        font-size: 16px !important;
    }

    /* Chat input stays large for readability */
    .ai-chat-input {
        font-size: 20px !important;
    }
}

/* Improve touch scrolling */
.ai-chat-messages {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent text selection on buttons */
.ai-btn,
.ai-avatar,
.ai-chat-controls button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.ai-curator-chat-container.rtl {
    direction: rtl;
}

.ai-curator-chat-container.rtl .ai-user-message .ai-message-content {
    text-align: right;
}

.ai-curator-chat-container.rtl .ai-message-actions {
    margin-left: 0;
    margin-right: 44px;
}

.ai-curator-chat-container.rtl .ai-typing-stats {
    margin-left: 0;
    margin-right: auto;
}

.ai-curator-chat-container.rtl .ai-share-tooltip {
    left: auto;
    right: 44px;
}

.ai-curator-chat-container.rtl .ai-usage-metrics {
    margin-left: 0;
    margin-right: 44px;
}

/* Layout Container Styles */
.ai-layout-container {
    margin: 20px 0;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background: white;
}

.ai-layout-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-layout-badge {
    color: white;
    font-weight: 600;
    font-size: 14px;
    text-transform: capitalize;
}

.ai-layout-actions {
    display: flex;
    gap: 8px;
}

.ai-layout-share,
.ai-layout-fullscreen {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-layout-share:hover,
.ai-layout-fullscreen:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-layout-share .dashicons,
.ai-layout-fullscreen .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.ai-layout-share-tooltip {
    position: absolute;
    top: 60px;
    right: 16px;
    z-index: 1000;
    display: none;
}

.ai-share-tooltip-content {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 16px;
    min-width: 300px;
    position: relative;
}

.ai-share-tooltip-content p {
    margin: 0 0 12px 0;
    color: #27ae60;
    font-size: 14px;
}

.ai-share-tooltip-content input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 12px;
    font-family: monospace;
}

.ai-share-social {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.ai-share-social a {
    background: #f5f5f5;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #666;
    transition: all 0.2s;
    text-decoration: none;
}

.ai-share-social a:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

.ai-share-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ai-share-close:hover {
    color: #333;
}

.ai-layout-iframe {
    width: 100%;
    border: none;
    display: block;
    min-height: 400px;
    background: white;
}

/* Telegram Mobile Optimization */
@media (max-width: 480px) {
    .ai-layout-container {
        margin: 15px -10px;
        border-radius: 8px;
    }

    .ai-layout-header {
        padding: 10px 12px;
    }

    .ai-layout-badge {
        font-size: 12px;
    }

    .ai-layout-fullscreen {
        padding: 4px 8px;
        font-size: 12px;
    }

    .ai-layout-iframe {
        min-height: 300px;
    }
}

/* Very small screens (Telegram inline) */
@media (max-width: 360px) {
    .ai-layout-container {
        margin: 10px -5px;
    }

    .ai-layout-iframe {
        min-height: 250px;
    }
}

@media (max-width: 768px) {

    .ai-user-message,
    .ai-ai-message {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }

    .ai-user-message {
        align-items: flex-end !important;
    }
}

/* Mobile: Move actions and stats under text instead of beside */
@media (max-width: 768px) {

    .ai-message-content {
        max-width: 95% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: auto !important;
        min-width: 120px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    }

    .ai-message-actions {
        margin-left: 0 !important;
        margin-top: 8px;
        width: 100%;
        justify-content: flex-start;
        opacity: 1 !important;
        /* Always visible on mobile */
    }

    .ai-typing-indicator {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .ai-typing-stats {
        margin-left: 0 !important;
        margin-top: 8px;
        width: 100%;
    }

    .ai-usage-metrics {
        margin-left: 0 !important;
        margin-top: 6px;
        width: 100%;
        background: rgba(0, 0, 0, 0.03);
        padding: 6px 10px;
        border-radius: 8px;
        font-size: 13px !important;
    }

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

/* Cache Rebuilding Message */
.ai-cache-rebuilding-message {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    margin: 10px 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    animation: fadeInUp 0.5s ease;
}

.ai-cache-rebuilding-message .ai-avatar {
    font-size: 28px;
    margin-right: 12px;
    flex-shrink: 0;
}

.ai-cache-rebuilding-message .ai-message-content {
    flex: 1;
}

.ai-cache-rebuilding-message strong {
    display: block;
    color: #667eea;
    font-size: 18px;
    margin-bottom: 8px;
}

.ai-cache-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: ai-spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

/* Artifact Popup Modal */
.ai-artifact-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100000;
    /* Extremely high to be above everything */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    backdrop-filter: blur(5px);
}

.ai-artifact-popup-content {
    background: white;
    width: 100%;
    max-width: 1100px;
    height: 90vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: artifactPopupScale 0.3s ease-out;
}

@keyframes artifactPopupScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ai-artifact-popup-header {
    background: #f8f9fa;
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-artifact-popup-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

.ai-artifact-popup-close {
    background: #eee;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #666;
}

.ai-artifact-popup-close:hover {
    background: #e0e0e0;
    color: #333;
    transform: rotate(90deg);
}

.ai-artifact-popup-body {
    flex: 1;
    background: #fff;
    position: relative;
}

.ai-artifact-popup-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Ensure quick links container looks good */
.ai-artifact-quick-links {
    display: flex;
    gap: 6px;
    margin-left: 15px;
    align-items: center;
}

.ai-artifact-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.25;
    filter: grayscale(1) opacity(0.5);
    padding: 0;
}

.ai-artifact-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    opacity: 0.8;
    filter: grayscale(0.5);
    transform: translateY(-1px);
}

.ai-artifact-active {
    opacity: 1 !important;
    filter: none !important;
    background: rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ai-artifact-active:hover {
    background: white !important;
    color: #667eea !important;
    transform: translateY(-2px);
}

.ai-artifact-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

@media (max-width: 768px) {
    .ai-artifact-popup-modal {
        padding: 10px;
    }

    .ai-artifact-popup-content {
        height: 95vh;
    }
}

.ai-cache-status {
    color: #666;
    font-size: 14px;
    vertical-align: middle;
}