/* DeepResearch Core CSS Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Outfit:wght@400;500;600;700&display=swap');

:root {
    --bg-dark: #0b0f19;
    --card-bg: rgba(22, 28, 45, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-glow: 0 0 20px rgba(99, 102, 241, 0.25);
    
    --indigo-glow: rgba(99, 102, 241, 0.15);
    --purple-glow: rgba(168, 85, 247, 0.15);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, var(--indigo-glow) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, var(--purple-glow) 0%, transparent 40%);
    background-attachment: fixed;
}

/* Glassmorphism Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Container Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background: rgba(15, 23, 42, 0.4);
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 24px;
    flex-shrink: 0;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--accent-glow);
}

.brand-logo svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.brand-title {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.history-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-header {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.history-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.history-item {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-item-content {
    flex-grow: 1;
    min-width: 0;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.history-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
}

.history-query {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-date {
    font-size: 11px;
    color: var(--text-secondary);
}

.history-pdf-btn {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    border-radius: 8px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.history-pdf-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: #818cf8;
    color: white;
}


/* Main Workspace Styling */
.main-workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 32px;
    overflow-y: auto;
}

.search-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    backdrop-filter: blur(20px);
    margin-bottom: 32px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    transition: var(--transition-smooth);
}

.search-title {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.search-input-wrapper {
    display: flex;
    gap: 12px;
}

.search-input {
    flex-grow: 1;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    color: white;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: var(--transition-smooth);
}

.search-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.research-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0 28px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--accent-glow);
    transition: var(--transition-smooth);
}

.research-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.4);
}

.research-btn:active {
    transform: translateY(0);
}

.research-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Overlay and Animations */
.loading-container {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    margin-bottom: 32px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.05);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-title {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.loading-status {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

/* Report Display Area (Markdown visualizer) */
.report-display-card {
    background: transparent;
    border: none;
    padding: 20px 0;
    min-height: 400px;
    display: none;
}

.report-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 24px;
    backdrop-filter: blur(12px);
}

.report-toolbar-title {
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 12px;
}

.pdf-download-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--accent-glow);
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.pdf-download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.35);
}


/* Markdown Rendering Typography Customizations */
.markdown-body {
    line-height: 1.625;
    font-size: 15px;
    color: #e5e7eb;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    color: white;
    margin-top: 28px;
    margin-bottom: 14px;
}

.markdown-body h1 {
    font-size: 26px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.markdown-body h2 {
    font-size: 20px;
    margin-top: 32px;
}

.markdown-body h3 {
    font-size: 16px;
}

.markdown-body p {
    margin-bottom: 16px;
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

.markdown-body strong {
    color: white;
    font-weight: 600;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 16px;
    padding-left: 20px;
}

.markdown-body li {
    margin-bottom: 8px;
}

.markdown-body a {
    color: #818cf8;
    text-decoration: none;
    border-bottom: 1px dashed rgba(129, 140, 248, 0.4);
    transition: var(--transition-smooth);
}

.markdown-body a:hover {
    color: #a5b4fc;
    border-bottom-color: #a5b4fc;
}

.markdown-body blockquote {
    border-left: 4px solid #6366f1;
    background: rgba(99, 102, 241, 0.05);
    padding: 16px 20px;
    margin-bottom: 16px;
    border-radius: 0 8px 8px 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

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

.markdown-body th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
}

.markdown-body code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 6px;
    border-radius: 4px;
    color: #f472b6;
}

.markdown-body pre {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: #e5e7eb;
}

/* Empty State / Welcome Screen Styling */
.empty-state {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

.welcome-hero {
    margin-bottom: 40px;
}

.welcome-icon {
    display: inline-flex;
    padding: 16px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 50%;
    margin-bottom: 20px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.05);
}

.welcome-hero svg {
    width: 48px;
    height: 48px;
    stroke: #818cf8;
    margin: 0;
}

.welcome-hero h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: white;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-subtitle {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 680px;
    margin: 0 auto;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    margin-bottom: 44px;
}

.feature-item {
    background: rgba(22, 28, 45, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px 20px;
    text-align: left;
    transition: var(--transition-smooth);
}

.feature-item:hover {
    background: rgba(22, 28, 45, 0.7);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-3px);
}

.feature-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    padding: 4px 8px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.feature-item h4 {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    color: white;
    margin-bottom: 8px;
    font-weight: 600;
}

.feature-item p {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Suggestions / Clickable Chips */
.suggestions-container {
    width: 100%;
    text-align: left;
}

.suggestions-container h4 {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    font-weight: 600;
    text-align: center;
}

.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.suggestion-chip {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 18px;
    color: #e5e7eb;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.suggestion-chip:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
    color: white;
    transform: translateY(-1px);
}

/* Responsive / Mobile Design Queries */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        width: 100%;
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 350px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 20px 16px;
        flex-shrink: 0;
        order: 2; /* Put historical insights beneath workspace/search on mobile */
    }

    .brand-section {
        margin-bottom: 20px;
    }

    .history-section {
        max-height: 250px;
    }

    .main-workspace {
        width: 100%;
        height: auto;
        padding: 16px;
        order: 1;
        overflow-y: visible;
    }

    .search-card {
        padding: 16px;
        margin-bottom: 20px;
    }

    .search-input-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .search-input {
        width: 100%;
        padding: 12px;
        font-size: 13px;
    }

    .research-btn {
        width: 100%;
        padding: 14px;
        justify-content: center;
    }

    .empty-state {
        margin: 20px auto;
        padding: 0 10px;
    }

    .welcome-hero h2 {
        font-size: 22px;
    }

    .welcome-subtitle {
        font-size: 13px;
    }

    .suggestion-chip {
        padding: 8px 14px;
        font-size: 12px;
    }

    /* Report Display Adjustments */
    .markdown-body {
        font-size: 14px;
    }

    .markdown-body h1 {
        font-size: 20px;
    }

    .markdown-body h2 {
        font-size: 18px;
    }

    .markdown-body pre {
        padding: 12px;
    }
}
