/* Perplexity Pro Style Chat Interface */
:root {
    --perplexity-primary: #2563eb;
    --perplexity-secondary: #64748b;
    --perplexity-bg: #ffffff;
    --perplexity-surface: #f8fafc;
    --perplexity-border: #e2e8f0;
    --perplexity-text: #1e293b;
    --perplexity-text-secondary: #64748b;
    --perplexity-radius: 12px;
    --perplexity-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --perplexity-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --perplexity-bg: #0f172a;
        --perplexity-surface: #1e293b;
        --perplexity-border: #334155;
        --perplexity-text: #f1f5f9;
        --perplexity-text-secondary: #94a3b8;
    }
}

/* Reset and base styles */
.perplexity-chat-section {
    min-height: 100vh;
    background: var(--perplexity-bg);
    color: var(--perplexity-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    position: relative;
    overflow-x: hidden;
}

.perplexity-container {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header with logo */
.perplexity-header {
    padding: 24px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.perplexity-logo {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 24px;
    font-weight: 600;
    color: var(--perplexity-text);
}

.logo-text {
    color: var(--perplexity-text);
}

.logo-pro {
    color: var(--perplexity-primary);
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
}

.logo-pro::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -8px;
    width: 6px;
    height: 6px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

/* Main content area */
.perplexity-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
    position: relative;
}

/* Welcome state */
.perplexity-welcome {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-title {
    font-size: 48px;
    font-weight: 700;
    margin: 0 0 16px 0;
    background: linear-gradient(135deg, var(--perplexity-text), var(--perplexity-text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.welcome-subtitle {
    font-size: 18px;
    color: var(--perplexity-text-secondary);
    margin: 0 0 48px 0;
    line-height: 1.5;
}

/* Chat messages area */
.perplexity-messages {
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    padding: 20px 0;
    flex: 1;
    overflow-y: auto;
}

.perplexity-message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding: 0 16px;
}

.message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-icon {
    width: 24px;
    height: 24px;
    background: var(--perplexity-primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-text {
    color: var(--perplexity-text);
    line-height: 1.6;
    margin-bottom: 8px;
}

.message-timestamp {
    color: var(--perplexity-text-secondary);
    font-size: 12px;
}

/* Input area */
.perplexity-input-area {
    position: sticky;
    bottom: 0;
    background: var(--perplexity-bg);
    padding: 24px 0 32px 0;
    border-top: 1px solid var(--perplexity-border);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.perplexity-form {
    width: 100%;
}

.perplexity-input-container {
    position: relative;
    background: var(--perplexity-surface);
    border: 1px solid var(--perplexity-border);
    border-radius: var(--perplexity-radius);
    box-shadow: var(--perplexity-shadow);
    transition: all 0.2s ease;
    overflow: hidden;
}

.perplexity-input-container:focus-within {
    border-color: var(--perplexity-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), var(--perplexity-shadow-lg);
}

.perplexity-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    padding: 16px 20px;
    font-size: 16px;
    color: var(--perplexity-text);
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    min-height: 24px;
    max-height: 200px;
    padding-right: 200px; /* Space for actions */
}

.perplexity-input::placeholder {
    color: var(--perplexity-text-secondary);
}

.perplexity-actions {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    align-items: center;
}

.perplexity-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--perplexity-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.perplexity-btn:hover {
    background: var(--perplexity-border);
    color: var(--perplexity-text);
}

.perplexity-btn:active {
    transform: scale(0.95);
}

.perplexity-btn-pro {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
}

.perplexity-btn-pro:hover {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Suggestion pills */
.perplexity-suggestions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    justify-content: center;
}

.suggestion-pill {
    background: var(--perplexity-surface);
    border: 1px solid var(--perplexity-border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    color: var(--perplexity-text);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.suggestion-pill:hover {
    background: var(--perplexity-primary);
    color: white;
    border-color: var(--perplexity-primary);
    transform: translateY(-1px);
    box-shadow: var(--perplexity-shadow);
}

/* Loading indicator */
.perplexity-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--perplexity-surface);
    border: 1px solid var(--perplexity-border);
    border-radius: var(--perplexity-radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--perplexity-shadow-lg);
    backdrop-filter: blur(10px);
    z-index: 1000;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .perplexity-container {
        padding: 0 16px;
    }
    
    .welcome-title {
        font-size: 36px;
    }
    
    .welcome-subtitle {
        font-size: 16px;
    }
    
    .perplexity-input {
        padding-right: 160px;
    }
    
    .perplexity-actions {
        gap: 2px;
    }
    
    .perplexity-btn {
        width: 28px;
        height: 28px;
    }
    
    .suggestion-pill {
        font-size: 13px;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .perplexity-header {
        padding: 16px 0;
    }
    
    .welcome-title {
        font-size: 28px;
    }
    
    .perplexity-input-area {
        padding: 16px 0 24px 0;
    }
    
    .perplexity-suggestions {
        gap: 6px;
    }
}

/* Smooth animations */
.perplexity-message {
    animation: fadeInUp 0.3s ease-out;
}

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

/* Focus states for accessibility */
.perplexity-input:focus,
.perplexity-btn:focus,
.suggestion-pill:focus {
    outline: 2px solid var(--perplexity-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .perplexity-input-container {
        border-width: 2px;
    }
    
    .suggestion-pill {
        border-width: 2px;
    }
}

/* Offer cards in chat messages */
.offers-container {
    margin-top: 16px;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.offer-card {
    background: var(--perplexity-surface);
    border: 1px solid var(--perplexity-border);
    border-radius: var(--perplexity-radius);
    padding: 16px;
    transition: all 0.2s ease;
    box-shadow: var(--perplexity-shadow);
}

.offer-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--perplexity-shadow-lg);
    border-color: var(--perplexity-primary);
}

.offer-content h4 {
    margin: 0 0 8px 0;
    color: var(--perplexity-text);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.offer-content p {
    margin: 0 0 12px 0;
    color: var(--perplexity-text-secondary);
    font-size: 14px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.offer-commission,
.offer-category {
    display: inline-block;
    background: var(--perplexity-primary);
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    margin-right: 8px;
    margin-bottom: 8px;
}

.offer-category {
    background: var(--perplexity-text-secondary);
}

.offer-actions {
    margin-top: 12px;
}

.offer-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--perplexity-primary);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.offer-link:hover {
    background: var(--perplexity-secondary);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2);
}

/* Message type specific styles */
.user-message .avatar-icon {
    background: var(--perplexity-text-secondary);
}

.assistant-message .avatar-icon {
    background: var(--perplexity-primary);
}

/* Empty state for messages */
.perplexity-messages:empty::before {
    content: '';
    display: block;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    color: var(--perplexity-text-secondary);
    font-style: italic;
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--perplexity-text-secondary);
    border-radius: 50%;
    animation: typingDots 1.5s infinite;
}

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

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

@keyframes typingDots {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}
