/**
 * PDF Chat Styles
 * 
 * Styles for the "Chat with PDF" feature including:
 * - Consent dialog
 * - Progress indicator
 * - Error dialog
 * - Chat mode UI in iframe
 */

/* ============================================================
   CSS Variables for consistent theming
   ============================================================ */
:root {
    --pdf-chat-primary: #4F46E5;
    --pdf-chat-primary-hover: #4338CA;
    --pdf-chat-success: #10B981;
    --pdf-chat-warning: #F59E0B;
    --pdf-chat-error: #EF4444;
    --pdf-chat-bg: #FFFFFF;
    --pdf-chat-bg-overlay: rgba(0, 0, 0, 0.5);
    --pdf-chat-text: #1F2937;
    --pdf-chat-text-secondary: #6B7280;
    --pdf-chat-border: #E5E7EB;
    --pdf-chat-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --pdf-chat-radius: 12px;
    --pdf-chat-transition: 0.2s ease;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --pdf-chat-bg: #1F2937;
        --pdf-chat-text: #F9FAFB;
        --pdf-chat-text-secondary: #9CA3AF;
        --pdf-chat-border: #374151;
        --pdf-chat-bg-overlay: rgba(0, 0, 0, 0.7);
    }
}

/* ============================================================
   Overlay base styles
   ============================================================ */
.pdf-chat-consent-overlay,
.pdf-chat-progress-overlay,
.pdf-chat-error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--pdf-chat-bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--pdf-chat-transition), visibility var(--pdf-chat-transition);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pdf-chat-consent-overlay.visible,
.pdf-chat-progress-overlay.visible,
.pdf-chat-error-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================================
   Consent Dialog
   ============================================================ */
.pdf-chat-consent-dialog {
    background: var(--pdf-chat-bg);
    border-radius: var(--pdf-chat-radius);
    box-shadow: var(--pdf-chat-shadow);
    max-width: 420px;
    width: 90%;
    padding: 24px;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--pdf-chat-transition);
}

.pdf-chat-consent-overlay.visible .pdf-chat-consent-dialog {
    transform: scale(1) translateY(0);
}

.pdf-chat-consent-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.pdf-chat-consent-header .pdf-chat-icon {
    font-size: 28px;
    line-height: 1;
}

.pdf-chat-consent-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--pdf-chat-text);
}

.pdf-chat-consent-body {
    color: var(--pdf-chat-text);
}

.pdf-chat-consent-body p {
    margin: 0 0 16px 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--pdf-chat-text-secondary);
}

.pdf-chat-consent-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.pdf-chat-consent-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--pdf-chat-text);
}

.pdf-chat-consent-list .check-icon {
    color: var(--pdf-chat-success);
    font-weight: bold;
    font-size: 16px;
}

.pdf-chat-document-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(79, 70, 229, 0.1);
    border-radius: 8px;
    margin-bottom: 20px;
}

.pdf-chat-document-info .pdf-icon {
    font-size: 20px;
}

.pdf-chat-document-info .pdf-name {
    font-weight: 500;
    color: var(--pdf-chat-text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-chat-document-info .pdf-pages {
    color: var(--pdf-chat-text-secondary);
    font-size: 13px;
}

.pdf-chat-consent-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ============================================================
   Buttons
   ============================================================ */
.pdf-chat-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--pdf-chat-transition);
}

.pdf-chat-btn:focus {
    outline: 2px solid var(--pdf-chat-primary);
    outline-offset: 2px;
}

.pdf-chat-btn-cancel {
    background: transparent;
    color: var(--pdf-chat-text-secondary);
    border: 1px solid var(--pdf-chat-border);
}

.pdf-chat-btn-cancel:hover {
    background: var(--pdf-chat-border);
    color: var(--pdf-chat-text);
}

.pdf-chat-btn-start,
.pdf-chat-btn-ok {
    background: var(--pdf-chat-primary);
    color: white;
}

.pdf-chat-btn-start:hover,
.pdf-chat-btn-ok:hover {
    background: var(--pdf-chat-primary-hover);
}

/* ============================================================
   Progress Dialog
   ============================================================ */
.pdf-chat-progress-dialog {
    background: var(--pdf-chat-bg);
    border-radius: var(--pdf-chat-radius);
    box-shadow: var(--pdf-chat-shadow);
    padding: 32px 40px;
    text-align: center;
    min-width: 300px;
    transform: scale(0.95);
    transition: transform var(--pdf-chat-transition);
}

.pdf-chat-progress-overlay.visible .pdf-chat-progress-dialog {
    transform: scale(1);
}

.pdf-chat-progress-icon {
    font-size: 48px;
    margin-bottom: 20px;
    animation: pdf-chat-pulse 2s ease-in-out infinite;
}

@keyframes pdf-chat-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pdf-chat-progress-bar-container {
    margin-bottom: 16px;
}

.pdf-chat-progress-bar {
    height: 8px;
    background: var(--pdf-chat-border);
    border-radius: 4px;
    overflow: hidden;
}

.pdf-chat-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pdf-chat-primary) 0%, #818CF8 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.pdf-chat-progress-text {
    font-size: 14px;
    color: var(--pdf-chat-text-secondary);
}

/* ============================================================
   Error Dialog
   ============================================================ */
.pdf-chat-error-dialog {
    background: var(--pdf-chat-bg);
    border-radius: var(--pdf-chat-radius);
    box-shadow: var(--pdf-chat-shadow);
    padding: 24px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    transform: scale(0.95);
    transition: transform var(--pdf-chat-transition);
}

.pdf-chat-error-overlay.visible .pdf-chat-error-dialog {
    transform: scale(1);
}

.pdf-chat-error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.pdf-chat-error-message {
    font-size: 14px;
    color: var(--pdf-chat-text);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ============================================================
   Chat Mode Indicator (in chatbot iframe)
   ============================================================ */
.pdf-chat-mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
}

.pdf-chat-mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 14px;
}

.pdf-chat-mode-indicator .icon {
    font-size: 18px;
}

.pdf-chat-exit-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background var(--pdf-chat-transition);
}

.pdf-chat-exit-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================
   Source Citations in responses
   ============================================================ */
.pdf-chat-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--pdf-chat-border);
}

.pdf-chat-sources-label {
    font-size: 11px;
    color: var(--pdf-chat-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.pdf-chat-source-tag {
    display: inline-block;
    background: rgba(79, 70, 229, 0.1);
    color: var(--pdf-chat-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-right: 6px;
    margin-bottom: 4px;
}

/* ============================================================
   Typing indicator
   ============================================================ */
.pdf-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.pdf-chat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--pdf-chat-primary);
    border-radius: 50%;
    animation: pdf-chat-typing-bounce 1.4s ease-in-out infinite;
}

.pdf-chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.pdf-chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pdf-chat-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* ============================================================
   Low confidence warning
   ============================================================ */
.pdf-chat-low-confidence {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--pdf-chat-warning);
}

.pdf-chat-low-confidence .icon {
    font-size: 14px;
}

/* ============================================================
   Responsive adjustments
   ============================================================ */
@media (max-width: 480px) {
    .pdf-chat-consent-dialog,
    .pdf-chat-progress-dialog,
    .pdf-chat-error-dialog {
        padding: 20px;
        margin: 16px;
    }
    
    .pdf-chat-consent-actions {
        flex-direction: column;
    }
    
    .pdf-chat-btn {
        width: 100%;
        text-align: center;
    }
    
    .pdf-chat-consent-header h3 {
        font-size: 18px;
    }
}
