/* Scoped styles - only apply within the novelty container */
.novelty-container * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.novelty-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    line-height: 1.6 !important;
    color: #333 !important;
    background-color: #f8fafc !important;
    padding: 20px;
    border-radius: 8px;
    /* Break out of content constraints but stay reasonable */
    width: calc(100% + 6rem) !important;
    margin-left: -3rem !important;
    margin-right: -3rem !important;
}

.novelty-container .container {
    max-width: 1400px !important; /* Generous max-width for wide screens */
    margin: 0 auto !important;
    padding: 20px !important;
    width: 100% !important;
}

/* Header */
.novelty-container header {
    text-align: center !important;
    margin-bottom: 40px !important;
    padding: 40px 0 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
}

.novelty-container header h1 {
    font-size: 2.5rem !important;
    font-weight: 700 !important;
    margin-bottom: 10px !important;
    color: white !important;
}

.novelty-container .subtitle {
    font-size: 1.1rem !important;
    opacity: 0.9 !important;
    font-weight: 300 !important;
}

/* Form styles */
.novelty-container .input-section {
    background: white !important;
    padding: 30px !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    margin-bottom: 30px !important;
}

.novelty-container .form-group {
    margin-bottom: 25px;
}

.novelty-container label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
    font-size: 0.95rem;
}

.novelty-container textarea, .novelty-container input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.novelty-container textarea {
    resize: vertical;
    min-height: 120px;
}

.novelty-container textarea:focus, .novelty-container input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.novelty-container .form-help {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 5px;
}

/* Button styles */
.novelty-container .submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    padding: 14px 32px !important;
    border-radius: 8px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
    position: relative !important;
    min-width: 160px !important;
}

.novelty-container .submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.novelty-container .submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.novelty-container .btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Spinner animation */
.novelty-container .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Results section */
.novelty-container .results-section {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.novelty-container .novelty-score-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin-bottom: 30px;
    border-left: 4px solid #10b981;
}

.novelty-container .novelty-score-card h2 {
    color: #374151;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.novelty-container .score-value {
    font-size: 3rem;
    font-weight: 700;
    color: #10b981;
    margin-bottom: 10px;
}

.novelty-container .score-description {
    color: #6b7280;
    font-size: 0.9rem;
}

/* Neighbors section */
.novelty-container .neighbors-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.novelty-container .neighbors-section h2 {
    color: #374151;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.novelty-container .neighbors-description {
    color: #6b7280;
    margin-bottom: 25px;
    font-size: 0.95rem;
}

/* Table styles */
.novelty-container .table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.novelty-container table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.novelty-container th {
    background: #f9fafb;
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    position: relative;
}

.novelty-container th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.novelty-container th.sortable:hover {
    background: #f3f4f6;
}

.novelty-container .sort-indicator {
    margin-left: 8px;
    opacity: 0.5;
}

.novelty-container .sort-indicator::after {
    content: '↕';
}

.novelty-container th.sort-asc .sort-indicator::after {
    content: '↑';
    opacity: 1;
}

.novelty-container th.sort-desc .sort-indicator::after {
    content: '↓';
    opacity: 1;
}

.novelty-container td {
    padding: 16px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}

.novelty-container tr:hover {
    background: #f9fafb;
}

.novelty-container .distance-cell {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    color: #6366f1;
    font-weight: 500;
}

.novelty-container .title-cell {
    max-width: 400px;
}

.novelty-container .title-link {
    color: #1f2937;
    text-decoration: none;
    display: block;
    transition: color 0.2s;
}

.novelty-container .title-link:hover {
    color: #667eea;
    text-decoration: underline;
}

.novelty-container .authors-cell {
    color: #374151;
    font-size: 0.9rem;
    max-width: 250px;
    word-wrap: break-word;
    line-height: 1.4;
}

.novelty-container .date-cell {
    color: #6b7280;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Error section */
.novelty-container .error-section {
    animation: fadeIn 0.5s ease-in;
}

.novelty-container .error-card {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.novelty-container .error-card h3 {
    color: #dc2626;
    margin-bottom: 10px;
}

.novelty-container .error-card p {
    color: #7f1d1d;
    margin-bottom: 15px;
}

.novelty-container .retry-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.novelty-container .retry-btn:hover {
    background: #dc2626;
}

/* Responsive design */
@media (max-width: 768px) {
    .novelty-container .container {
        padding: 15px;
    }

    .novelty-container header h1 {
        font-size: 2rem;
    }

    .novelty-container .input-section, .novelty-container .novelty-score-card, .novelty-container .neighbors-section {
        padding: 20px;
    }

    .novelty-container .score-value {
        font-size: 2.5rem;
    }

    .novelty-container th, .novelty-container td {
        padding: 12px 8px;
    }

    .novelty-container .title-cell {
        max-width: 250px;
    }

    .novelty-container .authors-cell {
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .novelty-container header {
        padding: 30px 20px;
    }

    .novelty-container header h1 {
        font-size: 1.8rem;
    }

    .novelty-container .subtitle {
        font-size: 1rem;
    }

    .novelty-container .input-section, .novelty-container .novelty-score-card, .novelty-container .neighbors-section {
        padding: 15px;
    }

    .novelty-container .submit-btn {
        width: 100%;
        padding: 16px;
    }

    .novelty-container th, .novelty-container td {
        padding: 10px 6px;
        font-size: 0.9rem;
    }

    .novelty-container .authors-cell {
        max-width: 150px;
        font-size: 0.85rem;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .novelty-container * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.novelty-container button:focus-visible,
.novelty-container input:focus-visible,
.novelty-container textarea:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}