/* Modern CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* Modern Header */
.title-image {
    display: block;
    margin: 0 auto 2.5rem auto;
    max-width: 20%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
}

/* Enhanced Search Container */
.search-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-hint {
    text-align: center;
    color: white;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    font-style: italic;
    background: #005E2F;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    /* border-left: 4px solid rgb(102, 234, 146); */
    position: relative;
    display: block;
}

.search-hint.hidden {
    display: none;
}

.search-hint-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.search-hint-close:hover {
    background: rgba(102, 234, 146, 0.2);
    color: rgb(102, 234, 146);
}

/* Modern Form Elements */
#search-input {
    flex: 1;
    min-width: 250px;
    padding: 1rem 1.5rem;
    border: 2px solid rgb(33, 135, 28);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#search-input:focus {
    outline: none;
    border-color: rgb(102, 234, 146);
    box-shadow: 0 0 0 3px rgba(9, 78, 36, 0.1);
    transform: translateY(-2px);
}

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

#sort-select {
    padding: 1rem 1.5rem;
    border: 2px solid rgb(33, 135, 28);
    border-radius: 12px;
    font-size: 1rem;
    background-color: white;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-width: 150px;
    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='currentColor' 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 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

#sort-select:focus {
    outline: none;
    border-color: rgb(102, 234, 146);
    box-shadow: 0 0 0 3px rgba(102, 234, 146, 0.1);
    transform: translateY(-2px);
}

#sort-select:hover {
    border-color: rgb(102, 234, 146);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#search-button {
    padding: 1rem 2rem;
    background: linear-gradient(to bottom right, rgb(102, 234, 146), rgb(9, 78, 36));
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 234, 146, 0.3);
    white-space: nowrap;
}

#search-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 234, 146, 0.4);
}

#search-button:active {
    transform: translateY(-1px);
}

/* Modern Results Styling */
.result-item {
    background: white;
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #f3f4f6;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, rgb(33, 135, 28), rgb(33, 135, 28));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.result-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.result-item:hover::before {
    transform: scaleX(1);
}

.result-title {
    font-weight: 700;
    cursor: pointer;
    color: #1f2937;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
    line-height: 1.3;
}

.result-title:hover {
    color: rgb(9, 78, 36);
}

.result-authors {
    font-style: italic;
    font-size: 0.7rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.result-bibcode {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.7rem;
    color: #374151;
    cursor: pointer;
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-radius: 6px;
    display: inline-block;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.result-bibcode::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 234, 146, 0.1), transparent);
    transition: left 0.5s ease;
}

.result-bibcode:hover {
    /* background: linear-gradient(135deg, #eff6ff, #dbeafe); */
    border-color: rgb(102, 234, 146);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 234, 146, 0.15);
}

.result-bibcode:hover::before {
    left: 100%;
}

.result-bibcode::after {
    content: "📋";
    position: absolute;
    right: -25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    opacity: 0;
    transition: all 0.3s ease;
}

.result-bibcode:hover::after {
    opacity: 1;
    right: 10px;
}

/* Modern Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}

.action-button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    overflow: hidden;
}

.action-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.action-button:hover::before {
    left: 100%;
}

.bibtex-button {
    background: linear-gradient(135deg, #0CC46A, #0BB55F);
    color: white;
    box-shadow: 0 4px 12px rgba(12, 196, 106, 0.3);
}

.bibtex-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(12, 196, 106, 0.4);
}

.doi-button {
    background: linear-gradient(135deg, #00C9D3, #00B8C1);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 201, 211, 0.3);
}

.doi-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 201, 211, 0.4);
}

.arxiv-button {
    background: linear-gradient(135deg, #9F7AEA, #B794F4);
    color: white;
    box-shadow: 0 4px 12px rgba(159, 122, 234, 0.3);
}

.arxiv-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(159, 122, 234, 0.4);
}

.ads-button {
    background: linear-gradient(135deg, #E8F3F5, #D1E8EC);
    color: #2D3748;
    box-shadow: 0 4px 12px rgba(232, 243, 245, 0.3);
}

.ads-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(232, 243, 245, 0.4);
}

/* Modern Modal Design */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    margin: 3% auto;
    padding: 2rem;
    border: none;
    width: 95%;
    max-width: 800px;
    border-radius: 20px;
    position: relative;
    min-height: 400px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: #9ca3af;
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f3f4f6;
}

.close-button:hover {
    color: rgb(102, 234, 146);
    background: rgba(102, 234, 146, 0.2);
    transform: rotate(90deg);
}

/* Enhanced Copy Button */
#copy-bibtex-button {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#copy-bibtex-button::before {
    content: "📋";
}

#copy-bibtex-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

#copy-bibtex-button:active {
    transform: translateY(0);
}

#copy-bibtex-button.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

#copy-bibtex-button.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* Modern Status Container */
#status-container {
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    background: rgb(0, 94, 47);
    border: 1px solid;
    border-color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    color: white;
    min-height: 0;
    transition: all 0.3s ease;
}

#status-container:empty {
    display: none;
}

/* Enhanced Spinner */
.spinner {
    border: 3px solid #f3f4f6;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border-top-color: rgb(9, 78, 36);
    animation: spin 1s ease infinite;
    display: none;
    margin: 2rem auto;
}

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

/* Modern Notification System */
.notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 350px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.notification.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.notification.info {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

/* Enhanced Content Areas */
#abstract-content {
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    max-width: 100%;
    overflow-x: auto;
    color: #374151;
}

#bibtex-content {
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    max-width: 100%;
    overflow-x: auto;
    color: #374151;
    position: relative;
}

/* Modern Load More Button */
#next-page-button {
    display: block;
    margin: 2rem auto;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

#next-page-button:hover {
    background: linear-gradient(135deg, #4b5563, #374151);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(107, 114, 128, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 1rem;
        padding: 1.5rem;
        border-radius: 16px;
    }
    
    .title-image {
        max-width: 60%;
        max-height: 80px;
    }
    
    .search-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    #search-input,
    #sort-select,
    #search-button {
        width: 100%;
    }
    
    #sort-select {
        color: black;
        background-color: white;
    }
    
    #sort-select option {
        color: black;
        background-color: white;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 1.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-button {
        width: 100%;
        justify-content: center;
    }
    
    .notification {
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
    
    .result-item {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .result-title {
        font-size: 0.95rem;
    }
    
    .result-authors {
        font-size: 0.65rem;
    }
    
    .action-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .result-bibcode {
        font-size: 0.65rem;
        padding: 0.3rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 0.5rem;
        padding: 1rem;
    }
    
    .title-image {
        max-width: 80%;
        max-height: 60px;
    }
    
    .modal-content {
        margin: 2% auto;
        padding: 1rem;
    }
    
    #copy-bibtex-button {
        position: relative;
        bottom: auto;
        right: auto;
        margin-top: 1rem;
        width: 100%;
        justify-content: center;
    }
    
    .result-item {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .result-title {
        font-size: 0.9rem;
    }
    
    .result-authors {
        font-size: 0.6rem;
    }
    
    .action-button {
        padding: 0.35rem 0.7rem;
        font-size: 0.7rem;
    }
    
    .result-bibcode {
        font-size: 0.6rem;
        padding: 0.25rem 0.4rem;
    }
    
    #search-input,
    #sort-select {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }
    
    #search-button {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .search-hint {
        font-size: 0.8rem;
        padding: 0.6rem 0.8rem;
    }
    
    #status-container {
        font-size: 0.75rem;
        padding: 0.8rem 1.2rem;
    }
}