/* Ask Egon Chat Widget Styles */
/* Gallery-inspired styling matching Egon's design system */

/* ============================================
   FLOATING WIDGET & TOGGLE
   ============================================ */

.ask-egon-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1050;
    font-family: var(--font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

.ask-egon-toggle {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-secondary, #1a1a1a);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.1));
    border-radius: 50%;
    padding: 0;
    width: 48px;
    height: 48px;
    cursor: pointer;
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.15),
        0 0 20px rgba(212, 175, 55, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    animation: subtleGlow 3s ease-in-out infinite;
}

@keyframes subtleGlow {
    0%, 100% {
        box-shadow:
            0 2px 12px rgba(0, 0, 0, 0.15),
            0 0 15px rgba(212, 175, 55, 0.1);
    }
    50% {
        box-shadow:
            0 2px 12px rgba(0, 0, 0, 0.15),
            0 0 25px rgba(212, 175, 55, 0.25);
    }
}

.ask-egon-toggle:hover {
    width: auto;
    border-radius: 24px;
    padding: 0 16px 0 0;
    gap: 10px;
    background: var(--bg-tertiary, #242424);
    border-color: var(--gallery-amber, #d4af37);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.2),
        0 0 30px rgba(212, 175, 55, 0.3);
    transform: translateY(-1px);
    animation: none;
}

.ask-egon-toggle:active {
    transform: translateY(0);
}

.egon-icon {
    width: 46px;
    height: 46px;
    min-width: 46px;
    background: linear-gradient(135deg, var(--gallery-amber, #d4af37) 0%, #c4a030 100%);
    color: var(--gallery-obsidian, #0f0f0f);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
}

.ask-egon-toggle:hover .egon-icon {
    transform: scale(0.95);
}

.egon-icon i {
    line-height: 1;
    animation: subtleBounce 3s ease-in-out infinite;
}

@keyframes subtleBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

.ask-egon-toggle:hover .egon-icon i {
    animation: none;
}

.ask-label {
    letter-spacing: 0.3px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary, #fff);
    white-space: nowrap;
    opacity: 0;
    max-width: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ask-egon-toggle:hover .ask-label {
    opacity: 1;
    max-width: 100px;
}

/* ============================================
   CHAT PANEL
   ============================================ */

.ask-egon-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    transition: width 0.3s ease, height 0.3s ease;
}

/* Expanded panel state - larger on desktop */
.ask-egon-panel.expanded {
    width: 700px;
    height: 85vh;
    max-height: calc(100vh - 100px);
}

/* Only show expand button on larger screens */
@media (max-width: 768px) {
    .egon-expand-btn {
        display: none !important;
    }

    .ask-egon-panel.expanded {
        width: calc(100vw - 48px);
        height: calc(100vh - 140px);
    }
}

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

/* ============================================
   HEADER
   ============================================ */

.egon-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.egon-avatar {
    width: 40px;
    height: 40px;
    background: var(--gallery-amber, #d4af37);
    color: var(--gallery-obsidian, #0f0f0f);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    font-family: 'Cormorant Garamond', Georgia, serif;
}

.header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-text {
    font-size: 12px;
    color: var(--text-tertiary);
}

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

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    border-color: var(--gallery-amber);
    color: var(--gallery-amber);
}

/* ============================================
   CONTEXT BAR
   ============================================ */

.egon-context-bar {
    display: flex;
    gap: 16px;
    padding: 10px 20px;
    background: rgba(201, 168, 106, 0.08);
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.context-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.context-item i {
    color: var(--gallery-amber);
    font-size: 11px;
}

.context-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.egon-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.egon-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* ============================================
   MESSAGE BUBBLES
   ============================================ */

.message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.egon-message .message-avatar {
    background: var(--gallery-amber, #d4af37);
    color: var(--gallery-obsidian, #0f0f0f);
    font-family: 'Cormorant Garamond', Georgia, serif;
}

.user-message .message-avatar {
    background: var(--gallery-sage, #87a96b);
    color: white;
}

.message-content {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 12px 16px;
    max-width: 85%;
    line-height: 1.5;
    font-size: 14px;
    color: var(--text-primary);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: var(--gallery-sage, #87a96b);
    color: white;
}

/* Message content styling */
.message-content p {
    margin: 0 0 8px 0;
}

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

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

.message-content li {
    margin: 4px 0;
}

.message-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.message-content strong {
    color: var(--gallery-amber);
}

/* Heading hierarchy for chat - clear visual distinction */
.message-content h1,
.message-content h2 {
    font-size: 17px;
    font-weight: 700;
    margin: 16px 0 8px 0;
    color: var(--gallery-amber);
    border-bottom: none;
    padding-bottom: 0;
}

.message-content h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 14px 0 6px 0;
    color: var(--gallery-amber);
    border-bottom: none;
    padding-bottom: 0;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
    margin-top: 0;
}

.message-content h4,
.message-content h5,
.message-content h6 {
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0 4px 0;
    color: var(--text-primary);
}

/* ===========================================
   ARTWORK IMAGE GRID - Ask Egon Chat
   Responsive thumbnail grid for artist images
   =========================================== */

/* Image grid container (added by JS) */
.egon-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin: 16px 0;
    max-width: 100%;
}

/* Individual image cards in grid */
.egon-image-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.egon-image-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: var(--gallery-amber);
}

.egon-image-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    cursor: pointer;
    background: var(--bg-tertiary);
}

.egon-image-card .image-caption {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.3;
    min-height: 36px;
}

.egon-image-card .image-caption .title {
    color: var(--text-primary);
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.egon-image-card .image-caption .year {
    color: var(--text-tertiary);
    font-size: 11px;
}

/* Fallback for images not in grid (inline images) */
.message-content img:not(.egon-image-card img) {
    max-width: 200px;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--bg-tertiary);
    margin: 4px;
    vertical-align: top;
    border: 1px solid var(--border-primary);
}

.message-content img:not(.egon-image-card img):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: var(--gallery-amber);
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .egon-image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .egon-image-card img {
        height: 140px;
    }
}

/* ===========================================
   LIGHTBOX FOR FULL-SIZE IMAGES
   =========================================== */

.egon-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: lightboxFadeIn 0.2s ease;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.egon-lightbox .lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

.egon-lightbox .lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.egon-lightbox .lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: none;
    aspect-ratio: unset;
    cursor: default;
}

.egon-lightbox .lightbox-content img:hover {
    transform: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.egon-lightbox .lightbox-caption {
    text-align: center;
    color: var(--text-secondary, #ccc);
    padding: 16px;
    font-size: 14px;
    max-width: 600px;
}

.egon-lightbox .lightbox-close {
    position: absolute;
    top: -48px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    line-height: 1;
    padding: 8px;
}

.egon-lightbox .lightbox-close:hover {
    opacity: 1;
}

.egon-capabilities {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
}

.egon-capabilities li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.egon-capabilities li i {
    color: var(--gallery-amber);
    width: 16px;
    text-align: center;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.egon-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--gallery-amber);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

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

.typing-text {
    font-size: 13px;
    color: var(--text-tertiary);
    font-style: italic;
}

/* ============================================
   SUGGESTIONS
   ============================================ */

.egon-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
}

.suggestion-chip {
    padding: 8px 14px;
    border: 1px solid var(--border-primary);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.suggestion-chip:hover {
    border-color: var(--gallery-amber);
    color: var(--gallery-amber);
    background: rgba(201, 168, 106, 0.1);
}

.suggestion-chip i {
    margin-right: 6px;
}

/* ============================================
   INPUT AREA
   ============================================ */

.egon-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#egon-input {
    flex: 1;
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

#egon-input:focus {
    outline: none;
    border-color: var(--gallery-amber);
}

#egon-input::placeholder {
    color: var(--text-tertiary);
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--gallery-amber, #d4af37);
    border: none;
    color: var(--gallery-obsidian, #0f0f0f);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    background: #e5c048;
    transform: scale(1.05);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-send i {
    font-size: 16px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 480px) {
    .ask-egon-widget {
        bottom: 16px;
        right: 16px;
    }

    .ask-egon-toggle {
        width: 44px;
        height: 44px;
    }

    .ask-egon-toggle:hover {
        /* Keep circular on mobile - no expand effect */
        width: 44px;
        border-radius: 50%;
        padding: 0;
        gap: 0;
    }

    .ask-label {
        display: none;
    }

    .egon-icon {
        width: 42px;
        height: 42px;
        min-width: 42px;
        font-size: 16px;
    }

    /* Mobile: Full-screen takeover when panel is open */
    .ask-egon-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        z-index: 1060;
    }

    /* Hide toggle button when panel is open on mobile */
    .ask-egon-widget.panel-open .ask-egon-toggle {
        display: none;
    }
}

/* Body scroll lock when chat is open on mobile */
body.ask-egon-mobile-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ============================================
   THEME SUPPORT - Uses CSS variables from style.css
   Variables are defined in :root and [data-theme="dark"]
   No explicit overrides needed - variables handle it
   ============================================ */

/* History overlay */
.egon-history-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: var(--bg-primary);
}

[data-theme="dark"] .egon-history-overlay {
    background: rgba(15, 15, 15, 0.97);
}

[data-theme="light"] .egon-history-overlay,
:root:not([data-theme="dark"]) .egon-history-overlay {
    background: rgba(255, 255, 255, 0.97);
}

.egon-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-primary);
}

.egon-history-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.egon-close-history {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
    color: var(--text-tertiary);
}

.egon-close-history:hover {
    color: var(--text-primary);
}

.egon-history-item:hover {
    background: var(--bg-tertiary);
}

.egon-history-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.egon-history-meta {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Toast message */
.egon-toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 20;
    animation: fadeInOut 2s ease;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

/* ============================================
   CONVERSATION HISTORY PANEL
   ============================================ */

.egon-history-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.egon-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.egon-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 10px;
    transition: background 0.2s;
    margin-bottom: 8px;
}

.egon-history-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.egon-delete-conversation {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    opacity: 0;
    margin-left: 8px;
    flex-shrink: 0;
}

.egon-history-item:hover .egon-delete-conversation {
    opacity: 1;
}

.egon-delete-conversation:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* Note: .egon-history-overlay, .egon-history-header, .egon-history-title,
   .egon-history-meta, .egon-close-history, .egon-toast styles are
   defined in the THEME SUPPORT section above using CSS variables */

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}
