/* ====== InsightFlow AI — App Page Styles ====== */

/* ====== Main Layout ====== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 5.5rem 1.5rem 2rem;
    min-height: 100vh;
}

/* ====== Config Panel ====== */
.config-panel {
    animation: fadeInUp 0.6s ease;
}

.config-panel h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.config-panel .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* ====== Sample Cards ====== */
.samples-section {
    margin-bottom: 2rem;
}

.samples-section h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-2);
    margin-bottom: 1rem;
}

.sample-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.sample-card {
    padding: 1.25rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.sample-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sample-card:hover::before { opacity: 1; }

.sample-card:hover {
    transform: translateY(-3px);
    border-color: rgba(108, 92, 231, 0.3);
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.1);
}

.sample-card.selected {
    border-color: var(--accent-3);
    box-shadow: 0 0 20px rgba(0, 206, 201, 0.15);
}

.sample-card .icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.sample-card .title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.sample-card .desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.sample-card .badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(0, 206, 201, 0.1);
    color: var(--accent-3);
    border: 1px solid rgba(0, 206, 201, 0.2);
}

/* ====== Divider ====== */
.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

/* ====== Upload Zone ====== */
.upload-zone {
    padding: 2.5rem;
    border: 2px dashed rgba(108, 92, 231, 0.25);
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
}

.upload-zone:hover {
    border-color: rgba(108, 92, 231, 0.5);
    background: rgba(108, 92, 231, 0.03);
}

.upload-zone.drag-over {
    border-color: var(--accent-3);
    background: rgba(0, 206, 201, 0.05);
    animation: pulse-border 1s ease infinite;
}

.upload-zone.uploaded {
    border-color: var(--success);
    border-style: solid;
    background: rgba(0, 184, 148, 0.05);
}

.upload-zone .icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.upload-zone .text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.upload-zone .text strong {
    color: var(--accent-2);
}

.upload-zone .formats {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.upload-zone input[type="file"] { display: none; }

/* Upload success state */
.upload-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.upload-info .file-icon {
    font-size: 1.5rem;
}

.upload-info .details {
    text-align: left;
}

.upload-info .filename {
    font-weight: 600;
    font-size: 0.9rem;
}

.upload-info .chunks {
    font-size: 0.75rem;
    color: var(--accent-3);
}

/* ====== Provider Selection ====== */
.config-section {
    margin-bottom: 1.5rem;
}

.config-section label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.provider-options {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.provider-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.provider-option:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.provider-option.active {
    border-color: var(--accent-1);
    background: rgba(108, 92, 231, 0.1);
    color: var(--text-primary);
}

.provider-option input { display: none; }

/* ====== Model Dropdown ====== */
.model-select {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.model-select:focus {
    outline: none;
    border-color: var(--accent-1);
}

/* ====== API Key Input ====== */
.api-key-input {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s ease;
}

.api-key-input:focus {
    outline: none;
    border-color: var(--accent-1);
}

.api-key-input::placeholder {
    color: var(--text-muted);
}

.config-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.config-hint.success {
    color: var(--success);
}

/* ====== Start Chat Button ====== */
.start-chat-btn {
    width: 100%;
    padding: 0.85rem;
    font-size: 0.95rem;
    margin-top: 1.5rem;
}

/* ====== Status Messages ====== */
.status-message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    margin-top: 1rem;
    display: none;
}

.status-message.show { display: block; }

.status-message.error {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.status-message.success {
    background: rgba(0, 184, 148, 0.1);
    border: 1px solid rgba(0, 184, 148, 0.2);
    color: #00b894;
}

.status-message.loading {
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(108, 92, 231, 0.2);
    color: var(--accent-2);
}

/* ====== Loading Spinner ====== */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent-3);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
    .app-container { padding: 5rem 1rem 2rem; }
    .sample-cards { grid-template-columns: 1fr; }
    .provider-options { flex-direction: column; }
    .upload-zone { padding: 1.5rem; }
}


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

.chat-panel {
    animation: fadeInUp 0.4s ease;
}

.chat-header {
    position: sticky;
    top: 4.5rem;
    z-index: 10;
    background: rgba(18, 18, 26, 0.9) !important;
    backdrop-filter: blur(12px);
}

.chat-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(108, 92, 231, 0.3) transparent;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.3);
    border-radius: 3px;
}

/* ─── Message Bubbles ─── */
.message {
    animation: fadeInUp 0.3s ease;
}

.message-user .bubble {
    display: inline-block;
    max-width: 80%;
    padding: 0.7rem 1rem;
    border-radius: 12px 12px 2px 12px;
    background: rgba(108, 92, 231, 0.12);
    border: 1px solid rgba(108, 92, 231, 0.2);
    font-size: 0.85rem;
    line-height: 1.6;
    text-align: left;
    word-wrap: break-word;
}

.message-ai .bubble {
    display: inline-block;
    max-width: 85%;
    padding: 0.7rem 1rem;
    border-radius: 12px 12px 12px 2px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    line-height: 1.7;
    word-wrap: break-word;
}

.message-error .bubble {
    display: inline-block;
    max-width: 85%;
    padding: 0.7rem 1rem;
    border-radius: 12px 12px 12px 2px;
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.2);
    font-size: 0.85rem;
    color: #e74c3c;
}

/* ─── Typewriter Cursor ─── */
.typewriter-cursor::after {
    content: '▊';
    display: inline-block;
    color: var(--accent-3);
    animation: blink-cursor 0.8s step-end infinite;
    margin-left: 2px;
    font-size: 0.8em;
}

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

/* ─── Source Chunks ─── */
.chunks-toggle {
    background: none;
    border: none;
    color: var(--accent-2);
    font-size: 0.72rem;
    cursor: pointer;
    font-family: inherit;
    padding: 0.25rem 0;
    transition: color 0.2s ease;
}

.chunks-toggle:hover {
    color: var(--accent-3);
}

.chunk-item {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.3rem;
    border-radius: var(--radius-sm);
    background: rgba(108, 92, 231, 0.04);
    border: 1px solid rgba(108, 92, 231, 0.08);
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.5;
    transition: background 0.2s ease;
}

.chunk-item:hover {
    background: rgba(108, 92, 231, 0.08);
}

/* ─── Chat Input Bar ─── */
.chat-input-bar {
    position: sticky;
    bottom: 0;
    background: rgba(18, 18, 26, 0.95) !important;
    backdrop-filter: blur(12px);
}

.chat-input-bar textarea {
    transition: border-color 0.2s ease;
}

.chat-input-bar textarea:focus {
    outline: none;
    border-color: var(--accent-1);
}

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

/* Send button animation */
.chat-input-bar .btn-primary:active:not(:disabled) {
    transform: scale(0.95);
}

/* ─── Chat Action Buttons ─── */
.chat-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chat-actions .btn {
    font-size: 0.72rem;
    padding: 0.35rem 0.7rem;
}

/* ─── Welcome Message ─── */
.ai-welcome {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    animation: fadeInUp 0.5s ease;
}

.ai-welcome .welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.7;
}

.ai-welcome .welcome-text {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.ai-welcome .welcome-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ─── Session Expired State ─── */
.session-expired {
    text-align: center;
    padding: 2rem;
    background: rgba(253, 203, 110, 0.05);
    border: 1px solid rgba(253, 203, 110, 0.15);
    border-radius: var(--radius-md);
    margin: 1rem 0;
}

.session-expired .icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.session-expired .text {
    font-size: 0.85rem;
    color: var(--warning);
    margin-bottom: 0.75rem;
}

/* ─── Model Pill (in chat header) ─── */
.model-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    background: rgba(0, 206, 201, 0.08);
    color: var(--accent-3);
    border: 1px solid rgba(0, 206, 201, 0.15);
}

/* ─── Smooth Panel Transition ─── */
.config-panel, .chat-panel {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ─── Accessibility ─── */
.chat-input-bar textarea:focus-visible,
.btn:focus-visible,
.sample-card:focus-visible,
.provider-option:focus-visible {
    outline: 2px solid var(--accent-3);
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
