:root {
    --bg-color: #fdfdfd;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --accent-color: #111827;
    --accent-hover: #374151;
    --border-color: #e5e7eb;
    --success-color: #059669;
    --success-bg: #ecfdf5;
    
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
header {
    text-align: left;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.5rem;
}

.logo-icon {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
}

/* Search Styles */
.search-container {
    margin-bottom: 2.5rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
}

#search-input {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#search-input:focus {
    border-color: #9ca3af;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.2);
}

#search-input::placeholder {
    color: #9ca3af;
}

.filter-select {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 10px 32px 10px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    transition: border-color 0.15s ease;
}

.filter-select:focus {
    border-color: #9ca3af;
}

#search-btn {
    background: var(--accent-color);
    color: white;
    border: 1px solid var(--accent-color);
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
}

#search-btn:hover {
    background: var(--accent-hover);
}

.search-icon {
    display: none; /* Hide icon for cleaner look */
}

/* Loading State */
#loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.hidden {
    display: none !important;
}

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

/* Results Styles */
#results-container {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Tighter gap */
}

.paper-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    transition: border-color 0.2s ease;
}

.paper-card:hover {
    border-color: #d1d5db;
}

.paper-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.paper-authors {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.paper-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.8rem;
}

.meta-tag {
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    border: 1px solid #e5e7eb;
}

.meta-oa {
    background: var(--success-bg);
    color: var(--success-color);
    border-color: #a7f3d0;
}

.meta-q1 { background: #dcfce7; color: #166534; border-color: #bbf7d0; font-weight: 500; }
.meta-q2 { background: #fef3c7; color: #92400e; border-color: #fde68a; font-weight: 500; }
.meta-q3 { background: #ffedd5; color: #9a3412; border-color: #fed7aa; font-weight: 500; }
.meta-q4 { background: #fee2e2; color: #991b1b; border-color: #fecaca; font-weight: 500; }
.meta-unranked { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.meta-scopus { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; font-weight: 500; }

.paper-actions {
    display: flex;
    gap: 8px;
}

.btn-primary, .btn-secondary {
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border: 1px solid var(--accent-color);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-unpaywall {
    background: var(--card-bg);
    color: #6b7280;
    border: 1px dashed #d1d5db;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
}

.btn-unpaywall:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
    color: var(--text-primary);
}

.btn-unpaywall:disabled,
.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.no-results {
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Pagination */
#pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#page-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Support / Donation Section */
.support-section {
    margin-top: 3rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    transition: border-color 0.3s ease;
}

.support-section:hover {
    border-color: #d1d5db;
}

.support-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.support-coffee {
    font-size: 1.6rem;
    animation: coffeeFloat 3s ease-in-out infinite;
    cursor: default;
    user-select: none;
    flex-shrink: 0;
}

.support-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    transition: opacity 0.4s ease;
}

.support-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.support-counter {
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0;
    text-align: center;
    min-height: 1rem;
}

.btn-support {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 16px;
    background: #fff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.btn-support:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

@keyframes coffeeFloat {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-5px) rotate(3deg); }
}

@keyframes supportPulse {
    0%, 100% { border-color: var(--border-color); }
    50% { border-color: #9ca3af; }
}

.support-pulse {
    animation: supportPulse 2s ease 3;
}

/* Footer */
footer {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
}

footer a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

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

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1.5rem 1rem;
    }
    
    .input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-select {
        margin-bottom: 0;
    }
}
