/* Variables CSS */
:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 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: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,%3Csvg width="100" height="100" xmlns="http://www.w3.org/2000/svg"%3E%3Cdefs%3E%3Cpattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"%3E%3Cpath d="M 20 0 L 0 0 0 20" fill="none" stroke="white" stroke-width="0.5" opacity="0.1"/%3E%3C/pattern%3E%3C/defs%3E%3Crect width="100" height="100" fill="url(%23grid)" /%3E%3C/svg%3E');
    opacity: 0.3;
}

.header__top {
    padding: 1.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
}

.header__top .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header__logo {
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.header__text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.header__title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.5px;
}

.header__tagline {
    font-size: 0.875rem;
    opacity: 0.85;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header__meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.header__badge {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s;
}

.header__badge:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.header__bottom {
    padding: 1.25rem 0;
    background: rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

.header__subtitle {
    font-size: 1rem;
    margin: 0;
    opacity: 0.95;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    text-align: center;
}

.header__subtitle-icon {
    font-size: 1.25rem;
}

/* Main */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 250px);
}

/* Search Section */
.search-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.search-box {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-input {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: all 0.3s;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-btn {
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.search-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn__icon {
    font-size: 1.3rem;
}

/* Sources Section */
.sources-section {
    border-top: 2px solid var(--border-color);
    padding-top: 2rem;
}

.sources-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.source-category {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
}

.category-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.source-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.source-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.source-checkbox:hover {
    background: var(--bg-tertiary);
}

.source-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.source-checkbox span {
    font-size: 0.95rem;
}

.source-checkbox small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.sources-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn--primary {
    background: var(--primary-color);
    color: white;
}

.btn--primary:hover {
    background: #1d4ed8;
}

.btn--secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn--secondary:hover {
    background: var(--secondary-color);
    color: white;
}

.btn--danger {
    background: var(--danger-color);
    color: white;
}

.btn--danger:hover {
    background: #dc2626;
}

/* Results Section */
.results-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-title {
    font-size: 1.8rem;
    color: var(--text-primary);
}

.results-title span {
    color: var(--primary-color);
    font-weight: 700;
}

.results-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.sort-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    cursor: pointer;
    background: white;
    outline: none;
}

.sort-select:focus {
    border-color: var(--primary-color);
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem 0;
}

.loading__spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Results Container */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal__content {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.modal__header h3 {
    font-size: 1.5rem;
}

.modal__close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.modal__close:hover {
    color: var(--text-primary);
}

.modal__body {
    padding: 1.5rem;
}

.modal__info {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.api-config {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.api-config__item label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.api-config__item input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    outline: none;
}

.api-config__item input:focus {
    border-color: var(--primary-color);
}

.modal__actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Footer */
.footer {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    padding: 3rem 0 1.5rem 0;
    margin-top: 4rem;
    border-top: 4px solid #3b82f6;
    position: relative;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
}

.footer__content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer__section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: #3b82f6;
}

.footer__desc {
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.8;
    margin: 0;
}

.footer__subtitle {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: #60a5fa;
}

.footer__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer__list li {
    font-size: 0.875rem;
    opacity: 0.8;
    padding-left: 1.25rem;
    position: relative;
}

.footer__list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #3b82f6;
    font-weight: bold;
}

.footer__bottom {
    text-align: center;
    padding-top: 1.5rem;
}

.footer__copyright {
    font-size: 0.875rem;
    margin: 0;
    opacity: 0.7;
}

.footer__version {
    display: inline-block;
    background: rgba(59, 130, 246, 0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    color: #60a5fa;
}

/* Responsive */
@media (max-width: 768px) {
    .header__top .container {
        flex-direction: column;
        text-align: center;
    }
    
    .header__brand {
        flex-direction: column;
        text-align: center;
    }
    
    .header__title {
        font-size: 1.5rem;
    }
    
    .header__meta {
        justify-content: center;
    }
    
    .header__subtitle {
        font-size: 0.9rem;
        padding: 0 1rem;
    }

    .search-box {
        flex-direction: column;
    }

    .sources-grid {
        grid-template-columns: 1fr;
    }

    .source-list {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .footer__content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}
