/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Navbar */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-logo:hover {
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Search Form */
.search-form {
    max-width: 700px;
    margin: 0 auto;
}

.search-form.compact {
    margin-bottom: 1.5rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    background: var(--surface);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.search-input {
    flex: 1;
    padding: 1rem 1.25rem;
    border: none;
    font-size: 1rem;
    outline: none;
    background: transparent;
}

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

.search-button {
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.search-button:hover {
    background: var(--primary-dark);
}

/* Large Search Box with Textarea */
.search-box-large {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.search-textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color 0.2s;
}

.search-textarea:focus {
    border-color: var(--primary-color);
}

.search-textarea::placeholder {
    color: var(--text-secondary);
}

.search-box-large .search-button {
    align-self: flex-end;
    padding: 0.875rem 2rem;
}

.search-hint {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Compact Search Box for Results Page */
.search-box-compact {
    display: flex;
    gap: 0.5rem;
    background: var(--surface);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.search-textarea-compact {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    outline: none;
    background: transparent;
    min-height: 40px;
}

/* Extracted Keywords */
.extracted-keywords {
    margin: 1rem 0;
    padding: 1rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius-md);
}

.keywords-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
}

.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.keyword-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.keyword-more {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--secondary-color);
    color: white;
    border-radius: 9999px;
    font-size: 0.8rem;
}

/* Error Message */
.error-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    color: var(--error-color);
}

/* Advanced Options */
.advanced-options {
    margin-top: 1.5rem;
    text-align: left;
}

.advanced-options summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.5rem 0;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.option-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.option-group input[type="text"],
.option-group input[type="number"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
}

/* Features Section */
.features {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.features h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

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

.feature-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    text-align: center;
}

.feature-icon {
    width: 3rem;
    height: 3rem;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0 auto 1rem;
}

.feature-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Results Page */
.results-header {
    margin-bottom: 2rem;
}

.results-meta {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.results-meta strong {
    color: var(--text-primary);
}

.filters-applied {
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    display: inline-block;
}

/* Authors List */
.authors-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.author-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
    transition: box-shadow 0.2s;
}

.author-card:hover {
    box-shadow: var(--shadow-md);
}

.author-rank {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.author-info {
    flex: 1;
}

.author-name {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.author-name a {
    color: var(--text-primary);
}

.author-name a:hover {
    color: var(--primary-color);
}

.author-affiliations {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.author-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.author-homepage {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--primary-color);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.no-results h2 {
    margin-bottom: 0.5rem;
}

.no-results p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    font-weight: 500;
}

.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

/* Back Link */
.back-link {
    margin-top: 2rem;
    text-align: center;
}

.back-link a {
    color: var(--text-secondary);
}

/* About Page */
.about-page {
    max-width: 800px;
    margin: 0 auto;
}

.about-page h1 {
    font-size: 2rem;
    margin-bottom: 2rem;
}

.about-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.about-section:last-child {
    border-bottom: none;
}

.about-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.about-section p,
.about-section li {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.about-section ul,
.about-section ol {
    padding-left: 1.5rem;
}

.about-section code {
    background: #f1f5f9;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.about-section pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1rem 0;
}

.about-section pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer-brand {
    font-weight: 600;
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 640px) {
    .hero h1 {
        font-size: 1.75rem;
    }

    .search-box {
        flex-direction: column;
    }

    .search-button {
        width: 100%;
    }

    .author-card {
        flex-direction: column;
        text-align: center;
    }

    .author-rank {
        margin: 0 auto;
    }

    .author-stats {
        justify-content: center;
    }

    .footer-container {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}
