/* ============================================================================
   Ask Excelerate Chat (Beta) - Styles
   ============================================================================ */

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --error-color: #ef4444;
    --user-bubble-bg: linear-gradient(135deg, #667eea, #764ba2);
    --assistant-bubble-bg: #f3f4f6;
    --border-color: #e5e7eb;
}

/* ============================================================================
   Layout
   ============================================================================ */

body {
    background: #f8fafc;
    margin: 0;
    min-height: 100vh;
    padding-bottom: 220px; /* Space for fixed input area */
}

.main-container {
    width: 80%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ============================================================================
   Page Header
   ============================================================================ */

.page-header {
    text-align: center;
    padding: 1.5rem 1rem 1rem;
    position: relative;
}

.beta-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 0.5rem 0;
    background: linear-gradient(135deg, #667eea, #764ba2);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-description {
    font-size: 1rem;
    color: #6b7280;
    margin: 0;
}

/* ============================================================================
   Query Limit Status
   ============================================================================ */

.query-limit-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-top: 1rem;
}

.query-limit-status.limit-info {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.query-limit-status.limit-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.query-limit-status.limit-reached {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.query-limit-status i {
    font-size: 0.9rem;
}

/* ============================================================================
   Access Denied Overlay
   ============================================================================ */

.access-denied-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.access-denied-modal {
    text-align: center;
    padding: 3rem;
    max-width: 400px;
}

.access-denied-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.access-denied-icon i {
    font-size: 2rem;
    color: white;
}

.access-denied-modal h2 {
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.access-denied-modal p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* ============================================================================
   Chat Container
   ============================================================================ */

.chat-wrapper {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.chat-messages-container {
    padding: 1.5rem;
    min-height: 300px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ============================================================================
   Welcome Screen
   ============================================================================ */

.chat-welcome {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.welcome-icon i {
    font-size: 2rem;
    color: white;
}

.chat-welcome h3 {
    color: #1f2937;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.chat-welcome p {
    max-width: 500px;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.suggestion-label {
    color: #9ca3af;
    font-size: 0.875rem;
    margin-right: 0.5rem;
}

.suggestion-chip {
    background: #f3f4f6;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-chip:hover {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: transparent;
    transform: translateY(-1px);
}

/* ============================================================================
   Chat Messages
   ============================================================================ */

.chat-message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.assistant-message {
    align-self: flex-start;
}

.error-message {
    align-self: center;
    max-width: 90%;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.assistant-message .message-avatar {
    background: #e5e7eb;
    color: #374151;
}

.error-message .message-avatar,
.error-avatar {
    background: #fef2f2;
    color: var(--error-color);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-message .message-content {
    align-items: flex-end;
}

.message-text {
    padding: 0.875rem 1.125rem;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.user-message .message-text {
    background: var(--user-bubble-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message .message-text {
    background: var(--assistant-bubble-bg);
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.error-message .message-text {
    background: #fef2f2;
    color: var(--error-color);
    border: 1px solid #fecaca;
}

/* Message text formatting */
.assistant-message .message-text h1,
.assistant-message .message-text h2,
.assistant-message .message-text h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.assistant-message .message-text h1:first-child,
.assistant-message .message-text h2:first-child,
.assistant-message .message-text h3:first-child {
    margin-top: 0;
}

.assistant-message .message-text p {
    margin: 0 0 0.75rem 0;
}

.assistant-message .message-text p:last-child {
    margin-bottom: 0;
}

.assistant-message .message-text ul,
.assistant-message .message-text ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.assistant-message .message-text li {
    margin: 0.25rem 0;
}

.assistant-message .message-text code {
    background: #e5e7eb;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.875em;
    font-family: 'Consolas', 'Monaco', monospace;
}

.assistant-message .message-text pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.assistant-message .message-text pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Message image */
.message-image {
    max-width: 500px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    background: #f9fafb;
}

.message-image img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
}

/* Provider badge */
.provider-badge {
    font-size: 0.7rem;
    color: #9ca3af;
    padding: 0.25rem 0.5rem;
    background: #f9fafb;
    border-radius: 4px;
    align-self: flex-start;
}

/* ============================================================================
   Typing Indicator
   ============================================================================ */

.typing-indicator-container .message-content {
    min-width: 60px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem;
    background: var(--assistant-bubble-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* ============================================================================
   Input Area
   ============================================================================ */

.chat-input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #fafafa;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 100;
}

.chat-input-area .input-row,
.chat-input-area .input-actions,
.chat-input-area .image-paste-hint {
    width: 80%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.input-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.image-upload-mini {
    position: relative;
}

.btn-image-upload {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: white;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-image-upload:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-image-upload.has-image {
    border-color: var(--success-color);
    color: var(--success-color);
}

/* Image paste hint banner */
.image-paste-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border: 2px dashed rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.image-paste-hint:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12), rgba(118, 75, 162, 0.12));
}

.image-paste-hint.drag-over {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    transform: scale(1.01);
}

.image-paste-hint-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
    color: white;
    font-size: 1.1rem;
}

.image-paste-hint-text {
    display: flex;
    flex-direction: column;
}

.image-paste-hint-text strong {
    color: #374151;
    font-size: 0.95rem;
}

.image-paste-hint-text span {
    color: #6b7280;
    font-size: 0.8rem;
}

.image-paste-hint-shortcuts {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.shortcut-key {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.75rem;
    color: #6b7280;
    font-family: 'Consolas', 'Monaco', monospace;
}

.shortcut-key kbd {
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.7rem;
}

.image-preview-mini {
    position: absolute;
    bottom: 55px;
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 350px;
    z-index: 100;
}

.image-preview-mini img {
    max-width: 300px;
    max-height: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.btn-remove-image {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--error-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.input-wrapper {
    flex: 1;
}

.input-wrapper textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    max-height: 150px;
    line-height: 1.5;
}

.input-wrapper textarea:focus {
    border-color: var(--primary-color);
}

.input-wrapper textarea:disabled {
    background: #f3f4f6;
    color: #9ca3af;
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-send:disabled {
    background: #e5e7eb;
    cursor: not-allowed;
}

/* Input actions row */
.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding: 0 0.25rem;
}

.btn-new-chat {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: white;
    color: #6b7280;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-new-chat:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.chat-info {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
    body {
        padding-bottom: 260px; /* More space for stacked mobile input */
    }

    .main-container {
        width: 95%;
        padding: 0 0.5rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .chat-messages-container {
        padding: 1rem;
    }

    .chat-message {
        max-width: 95%;
    }

    .chat-input-area {
        padding: 0.75rem 1rem 1rem;
    }

    .chat-input-area .input-row,
    .chat-input-area .input-actions,
    .chat-input-area .image-paste-hint {
        width: 95%;
    }

    .image-paste-hint {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .image-paste-hint-shortcuts {
        margin-left: 0;
        margin-top: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .input-wrapper textarea {
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
    }

    .btn-send,
    .btn-image-upload {
        width: 40px;
        height: 40px;
    }

    .welcome-icon {
        width: 60px;
        height: 60px;
    }

    .welcome-icon i {
        font-size: 1.5rem;
    }

    .chat-welcome h3 {
        font-size: 1.25rem;
    }

    .suggestion-chip {
        font-size: 0.8rem;
        padding: 0.375rem 0.75rem;
    }

    .message-image {
        max-width: 100%;
    }

    .message-image img {
        max-height: 300px;
    }

    .image-preview-mini {
        max-width: calc(100vw - 4rem);
        left: 0;
        right: 0;
    }

    .image-preview-mini img {
        max-width: 100%;
        max-height: 150px;
    }
}

@media (max-width: 480px) {
    .page-header {
        padding: 1rem 0.5rem;
    }

    .page-description {
        font-size: 0.9rem;
    }

    .chat-welcome {
        padding: 2rem 0.5rem;
    }

    .input-actions {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .btn-new-chat {
        width: 100%;
        justify-content: center;
    }

    .chat-info {
        text-align: center;
    }
}

/* ============================================================================
   Footer Adjustment for Fixed Input
   ============================================================================ */

/* Hide footer on chat page since we have fixed input at bottom */
.chat-input-area ~ footer,
body:has(.chat-input-area) footer {
    display: none;
}
