/**
 * KokoAI - Main Application Styles
 * Clean, production-ready chat interface
 */

/* App Layout */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.app.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    border: none;
    overflow: hidden;
}

.app.sidebar-collapsed .main {
    margin-left: 0;
}

.app.sidebar-collapsed .sidebar-open-btn {
    display: flex;
}

/* ========================================
   SIDEBAR
======================================== */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}

.sidebar-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.new-chat-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition-fast);
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.new-chat-btn:hover {
    background: var(--glass-bg);
}

.new-chat-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.history-item .history-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.history-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.history-delete-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.history-item:hover .history-delete-btn {
    display: flex;
}

.history-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.sidebar-link:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.version-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem;
}

/* ========================================
   MAIN CONTENT
======================================== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
    background-image: radial-gradient(at 0% 0%, rgba(217, 70, 239, 0.05) 0, transparent 50%), radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.05) 0, transparent 50%);
    background-attachment: fixed;
    transition: margin-left 0.3s ease;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    height: var(--header-height);
}

.sidebar-open-btn {
    width: 36px;
    height: 36px;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-open-btn:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.sidebar-open-btn svg {
    width: 20px;
    height: 20px;
}

.header-title {
    font-weight: 600;
    font-size: 1rem;
}

/* Model Selector */
.model-selector {
    margin-left: auto;
    position: relative;
}

.model-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition-fast);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.model-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.model-btn svg {
    width: 14px;
    height: 14px;
}

.model-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 280px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    overflow-y: auto;
    max-height: 60vh;
}

.model-dropdown.open {
    display: block;
    animation: dropdownIn 0.15s ease;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

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

.dropdown-header {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-label {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

.provider-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.35rem;
}

.provider-dot.groq {
    background: #f55036;
}

.provider-dot.cohere {
    background: #6e56cf;
}

.provider-dot.google {
    background: #4285f4;
}

.provider-dot.huggingface {
    background: #ffd21e;
}

.provider-dot.openrouter {
    background: #10a37f;
}

/* Gradient Headers */
.gradient-text {
    background: linear-gradient(135deg, #a78bfa 0%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    margin: 1.5rem 0 1rem;
    font-size: 1.1rem;
    display: inline-block;
}

.model-option {
    width: 100%;
    display: block;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    text-align: left;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.model-option:hover {
    background: var(--glass-bg);
}

.model-option.active {
    background: rgba(99, 102, 241, 0.15);
}

.model-option .model-name {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.model-option .model-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Estados Offline de Proveedores */
.provider-dot.offline {
    background: #6b7280 !important;
    animation: pulse-offline 2s ease-in-out infinite;
}

@keyframes pulse-offline {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

.offline-badge {
    margin-left: auto;
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.dropdown-label {
    display: flex;
    align-items: center;
}

.model-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.model-option.disabled:hover {
    background: transparent;
}

.model-option.disabled .model-name::after {
    content: ' (offline)';
    color: #ef4444;
    font-size: 0.7rem;
    font-weight: 400;
}

/* ========================================
   CHAT AREA
======================================== */
.chat-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Welcome Screen */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

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

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

.welcome-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 1.5rem;
    color: var(--accent-primary);
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.3));
    }

    50% {
        filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.5));
    }
}

.welcome-logo svg {
    width: 100%;
    height: 100%;
}

.welcome h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-width: 900px;
    width: 100%;
}

.suggestion {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
    text-align: left;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.suggestion::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-normal);
    z-index: 0;
}

.suggestion:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: transparent;
    color: white;
}

.suggestion:hover::before {
    opacity: 1;
}

.suggestion>* {
    position: relative;
    z-index: 1;
}

.suggestion svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: var(--accent-primary);
    transition: color var(--transition-normal);
}

.suggestion:hover svg {
    color: white;
}

/* ========================================
   MESSAGES
======================================== */
.messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.message-user {
    align-self: flex-end;
    align-items: flex-end;
}

.message-assistant {
    align-self: flex-start;
    align-items: flex-start;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

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

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Hide user avatar in bubble style */
.message-user .message-header {
    display: none;
}

.message-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.message-assistant .message-avatar {
    background: var(--bg-primary);
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
}

.message-author {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Message Quote Button */
.message-quote-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.message-quote-btn svg {
    width: 14px;
    height: 14px;
}

.message:hover .message-quote-btn {
    display: flex;
}

.message-quote-btn:hover {
    background: var(--glass-bg);
    color: var(--accent-primary);
}

.message-speak-btn, .message-export-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.message-speak-btn svg, .message-export-btn svg {
    width: 14px;
    height: 14px;
}

.message:hover .message-speak-btn, 
.message:hover .message-export-btn {
    display: flex;
}

.message-speak-btn:hover, .message-export-btn:hover {
    background: var(--glass-bg);
    color: var(--accent-primary);
}

.message-speak-btn.speaking {
    color: var(--accent-primary);
    animation: speak-pulse 1.5s infinite ease-in-out;
    background: rgba(217, 70, 239, 0.1) !important;
}

@keyframes speak-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Typing Indicator (Pensando...) */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    width: fit-content;
    margin-bottom: 0.5rem;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

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

/* Cursor animado para efecto de máquina de escribir */
.typewriter-cursor {
    display: inline-block;
    width: 6px;
    height: 1.1em;
    background-color: var(--text-primary);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: blink-cursor 0.8s infinite steps(2, start);
}

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

/* Quote Preview */
.quote-preview {
    max-width: 1000px;
    margin: 0 auto 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-left: 3px solid var(--accent-primary);
    border-radius: 8px;
    animation: slideIn 0.2s ease;
}

.quote-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.quote-preview-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quote-preview-label svg {
    width: 14px;
    height: 14px;
}

.quote-preview-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.quote-preview-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.quote-preview-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 100px;
    overflow-y: auto;
}

/* Text Selection Quote Popup - ChatGPT Style */
.selection-quote-popup {
    background: #2d2d2d;
    border: none;
    border-radius: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    animation: popupFadeIn 0.15s ease;
    padding: 0;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -100%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -100%) scale(1);
    }
}

.selection-quote-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    background: transparent;
    border: none;
    border-radius: 24px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.selection-quote-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.selection-quote-btn svg {
    width: 16px;
    height: 16px;
    opacity: 0.9;
}



/* Image Generation Styles */
.generated-image-container {
    margin-top: 0.5rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    max-width: 512px;
}

.generated-image {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease;
}

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

.image-meta {
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.image-model {
    font-family: 'Fira Code', monospace;
    color: var(--accent-secondary);
}

/* Image Loading Spinner */
.image-loading-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    width: fit-content;
}

.image-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-secondary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.suggestion.image-suggestion {
    border-color: var(--accent-secondary);
    background: rgba(16, 185, 129, 0.05);
}

.suggestion.image-suggestion:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--accent-primary);
}

.suggestion.image-suggestion svg {
    color: var(--accent-secondary);
}

.message-body {
    padding: 1rem 1.25rem;
    line-height: 1.5;
    font-size: 0.95rem;
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    word-break: break-word;
}

.message-user .message-body {
    background: var(--bubble-gradient);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.message-assistant .message-body {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

.message-body p {
    margin-bottom: 0.75rem;
}

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

/* Inline Code */
.message-body code.inline-code,
.message-body code:not([class*="language-"]) {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.875em;
    color: #e879f9;
    border: 1px solid var(--border-color);
}

/* Code Block Container */
.code-block-container {
    margin: 1rem 0;
    border-radius: 10px;
    overflow: hidden;
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-lang {
    font-size: 0.75rem;
    font-weight: 600;
    color: #a5b4fc;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.code-copy-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.code-copy-btn.copied {
    color: #10b981;
    border-color: #10b981;
}

/* Run button (sandbox) */
.code-run-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 6px;
    color: #10b981;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.code-run-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

/* Voice recording pulse animation */
@keyframes voicePulse {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    70%  { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#voice-btn.recording,
#voice-btn[style*="ef4444"] {
    color: #ef4444;
}

.code-copy-btn svg {
    width: 14px;
    height: 14px;
}

/* Agent thinking block (collapsible) */
.think-block {
    margin: 0.75rem 0;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-left: 3px solid rgba(99, 102, 241, 0.5);
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.04);
    overflow: hidden;
}

.think-block summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    letter-spacing: 0.02em;
    transition: background 0.15s;
}

.think-block summary:hover {
    background: rgba(99, 102, 241, 0.08);
}

.think-block[open] summary {
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.think-content {
    padding: 0.65rem 1rem;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-muted);
    font-family: 'Fira Code', 'Consolas', monospace;
}

.think-content p {
    margin: 0.2rem 0;
}


.code-block-container pre {
    margin: 0;
    padding: 1rem;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow-x: auto;
}

.code-block-container pre code {
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e2e8f0;
    background: transparent;
    padding: 0;
}

/* Syntax highlighting colors */
.code-block-container pre code .keyword {
    color: #c792ea;
}

.code-block-container pre code .string {
    color: #c3e88d;
}

.code-block-container pre code .comment {
    color: #676e95;
    font-style: italic;
}

.code-block-container pre code .number {
    color: #f78c6c;
}

.code-block-container pre code .function {
    color: #82aaff;
}

/* Legacy pre/code (fallback) */
.message-body pre:not(.code-block-container pre) {
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.message-body pre code {
    background: transparent;
    padding: 0;
    font-size: 0.85rem;
    color: #e2e8f0;
}

/* Math Styling */
.math-block {
    display: block;
    padding: 1.25rem;
    margin: 1rem 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: 1.2rem;
    text-align: center;
    color: var(--text-primary);
    overflow-x: auto;
}

.math-inline {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: 1.05em;
    color: #a5b4fc;
    padding: 0 0.2rem;
}

.math-frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 0.25rem;
}

.math-num {
    border-bottom: 1px solid currentColor;
    padding: 0 0.3rem 0.1rem;
}

.math-den {
    padding: 0.1rem 0.3rem 0;
}

.math-sqrt {
    text-decoration: overline;
    padding-left: 0.1rem;
}

.message-body sup {
    font-size: 0.7em;
    vertical-align: super;
}

.message-body sub {
    font-size: 0.7em;
    vertical-align: sub;
}

/* Inline equation styling */
.math-equation {
    display: block;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.08) 100%);
    border-left: 3px solid #a78bfa;
    border-radius: 0 8px 8px 0;
    font-family: 'Cambria Math', 'Times New Roman', Georgia, serif;
    font-size: 1.1rem;
    font-style: italic;
    color: #e2e8f0;
    letter-spacing: 0.02em;
}

.math-equation::before {
    content: '';
}


.message-meta {
    padding-left: calc(28px + 0.75rem);
    margin-top: 0.75rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.meta-tag svg {
    width: 12px;
    height: 12px;
}

/* Web Search indicator */
.meta-tag-search {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(16, 185, 129, 0.2) 100%);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Loading State */
.message-loading {
    display: flex;
    gap: 0.35rem;
    padding: 0.5rem 0;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {

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

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

/* ========================================
   INPUT AREA
======================================== */
.input-area {
    padding: 0.75rem 1rem 1.25rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

/* Mode Selector */
.mode-selector {
    max-width: 1000px;
    margin: 0 auto 0.75rem;
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.mode-selector::-webkit-scrollbar {
    height: 0;
}

.mode-selector .mode-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
    transition: var(--transition-fast);
}

.mode-selector .mode-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.mode-selector .mode-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.mode-selector .mode-btn svg {
    width: 14px;
    height: 14px;
}

.input-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem 0.4rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 40px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.15);
}

.input-container textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    padding: 0.5rem 0;
    outline: none;
}

.input-container textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bubble-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    transition: var(--transition-fast);
    flex-shrink: 0;
    cursor: pointer;
}

.send-btn:hover:not(:disabled) {
    box-shadow: var(--shadow-glow);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

.input-hint {
    max-width: 1000px;
    margin: 0.5rem auto 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.hint-separator {
    color: var(--border-color);
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 100;
    }

    .app.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }

    .sidebar-open-btn {
        display: flex;
    }

    .suggestions {
        grid-template-columns: 1fr;
    }

    .welcome h1 {
        font-size: 1.5rem;
    }

    .mode-selector .mode-btn span {
        display: none;
    }

    .mode-selector .mode-btn {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .message-body {
        padding-left: 0;
    }

    .message-meta {
        padding-left: 0;
    }

    .input-container {
        flex-wrap: wrap;
        border-radius: 20px;
        padding: 0.5rem;
    }

    .input-container textarea {
        flex-basis: 100%;
        min-width: 100%;
        padding: 0.5rem;
        margin-bottom: 0.25rem;
    }

    .input-tool-btn {
        margin-right: 0.5rem;
        width: 32px;
        height: 32px;
    }

    .send-btn {
        margin-left: auto;
    }

    .search-tools-wrapper {
        margin-right: 0.5rem;
    }
}

/* ========================================
   MODO IMAGEN Y MODAL
======================================== */
.input-tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-right: 2px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.input-tool-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.input-tool-btn.active {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.input-tool-btn svg {
    width: 15px;
    height: 15px;
}

.image-options-panel {
    max-width: 800px;
    margin: 0 auto 0.5rem;
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.image-option {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.image-option label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

.image-option select {
    padding: 0.35rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
}

.image-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.modal-content {
    max-width: 90%;
    max-height: 85vh;
    border-radius: 4px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    animation: zoomIn 0.2s ease-out;
}

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

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

.modal-caption {
    margin-top: 1rem;
    color: white;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    text-align: center;
    max-width: 80%;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #f1f1f1;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    line-height: 1;
}

.close-modal:hover {
    color: var(--accent-primary);
}

.generated-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.5rem;
}

.generated-image-grid img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid var(--border-color);
    aspect-ratio: 1;
    object-fit: cover;
}

.generated-image-grid img:hover {
    transform: scale(1.02);
    border-color: var(--accent-primary);
}

.image-fade-in {
    opacity: 0;
    animation: imageFadeIn 0.8s ease-out forwards;
}

@keyframes imageFadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

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

/* Web Search and Toast Styles */
.search-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-loading .search-icon-pulse {
    color: var(--accent-primary);
    animation: searchPulse 1.5s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-loading .search-icon-pulse svg {
    width: 20px;
    height: 20px;
}

@keyframes searchPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
        filter: drop-shadow(0 0 5px var(--accent-primary));
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Web Search Button Active State */
#web-search-btn.active {
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-primary);
}

#web-search-btn.active svg {
    fill: rgba(99, 102, 241, 0.1);
}

/* Markdown Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

th,
td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-primary);
}

tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

tr:last-child td {
    border-bottom: none;
}

/* Video Embeds */
.video-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 1rem 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 16/9;
    box-shadow: var(--shadow-md);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-container.tiktok-container,
.video-container.instagram-container {
    max-width: 340px;
    /* Mobile width */
    aspect-ratio: 9/16;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    /* Lighter bg for vertical */
}

/* Search Options Menu */
.search-options-menu {
    position: absolute;
    bottom: calc(100% + 15px);
    left: -10px;
    width: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    padding: 0.5rem;
    z-index: 1000;
    display: none;
    flex-direction: column;
    gap: 4px;
}

.search-options-menu.show {
    display: flex;
    animation: fadeIn 0.15s ease-out;
}

.search-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.search-option:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.search-option.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    font-weight: 500;
}

.search-option svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   SOURCES POPUP
======================================== */
.sources-btn {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
    border: 1px solid rgba(99, 102, 241, 0.3);
    transition: all 0.2s ease;
}

.sources-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25));
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.sources-btn svg {
    width: 12px;
    height: 12px;
}

.sources-btn svg:last-child {
    width: 10px;
    height: 10px;
    opacity: 0.6;
    margin-left: 0.25rem;
}

.sources-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 550px;
    max-height: 70vh;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sources-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.sources-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.sources-popup-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.sources-popup-title svg {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.sources-popup-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.sources-popup-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.sources-popup-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.source-item {
    display: block;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
    color: inherit;
}

.source-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.source-item-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.375rem;
}

.source-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--accent-gradient);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 50%;
    flex-shrink: 0;
}

.source-title {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.source-item-header svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.source-item:hover .source-item-header svg {
    opacity: 1;
    color: var(--accent-primary);
}

.source-snippet {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0 0 0.5rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.source-url {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.source-url::before {
    content: '🔗';
    font-size: 0.65rem;
}

/* Backdrop for sources popup */
.sources-popup::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

/* ========================================
   VISION / IMAGE ANALYSIS
======================================== */

/* Vision button active state */
#vision-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(236, 72, 153, 0.25));
    border-color: #8b5cf6;
    color: #a78bfa;
}

#vision-btn.active svg {
    animation: pulse-vision 1.5s ease-in-out infinite;
}

@keyframes pulse-vision {

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

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Image Preview above input */
.image-preview {
    max-width: 800px;
    margin: 0 auto 0.75rem;
    animation: slideIn 0.2s ease;
}

.image-preview-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    position: relative;
}

.image-preview-content img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid rgba(139, 92, 246, 0.4);
}

.image-preview-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.image-preview-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-preview-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: #a78bfa;
    font-weight: 500;
}

.image-preview-label svg {
    width: 14px;
    height: 14px;
}

.image-preview-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.image-preview-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
}

/* Vision badge in message header */
.vision-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    padding: 0.25rem 0.6rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.15));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #a78bfa;
}

.vision-badge svg {
    width: 12px;
    height: 12px;
}

/* User image attachment in message */
.user-image-attachment {
    margin-bottom: 0.75rem;
}

.user-image-attachment img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    object-fit: cover;
}

.user-image-attachment img:hover {
    border-color: var(--accent-primary);
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Vision loading animation */
.vision-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.vision-icon-pulse {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.2));
    border-radius: 50%;
    animation: vision-pulse 1.5s ease-in-out infinite;
}

.vision-icon-pulse svg {
    width: 18px;
    height: 18px;
    color: #a78bfa;
}

@keyframes vision-pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px 5px rgba(139, 92, 246, 0.2);
    }
}

.vision-loading span {
    font-size: 0.9rem;
    color: var(--text-secondary);
    animation: fadeInOut 1.5s ease-in-out infinite;
}

@keyframes fadeInOut {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* ============================================
   IMAGE DRAG & DROP / PASTE STYLES
   ============================================ */

/* Input Container needs relative positioning for overlay */
.input-container {
    position: relative;
}

/* Dropzone overlay - shown when dragging over */
.dropzone-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(99, 102, 241, 0.4);
    backdrop-filter: blur(8px);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    border: 4px dashed var(--accent-primary);
    margin: 1.5rem;
    border-radius: 24px;
    pointer-events: none;
    transition: all 0.3s ease;
}

.dropzone-overlay svg {
    width: 48px;
    height: 48px;
    color: #ffffff;
    animation: bounce 0.6s ease infinite alternate;
}

.dropzone-overlay span {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
}

.app.drag-over .dropzone-overlay {
    display: flex;
}

.app.drag-over {
    cursor: copy;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-8px);
    }
}

/* Attached image preview */
.attached-image-preview {
    position: relative;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.attached-image-preview img {
    max-height: 80px;
    max-width: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid rgba(99, 102, 241, 0.3);
}

.remove-attached-image {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.remove-attached-image:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.remove-attached-image svg {
    width: 14px;
    height: 14px;
    color: #ffffff;
}

/* Has attached image state */
.input-container.has-image {
    flex-wrap: wrap;
}

.input-container.has-image .attached-image-preview {
    flex: 0 0 100%;
    order: -1;
}