* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.search-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

#searchForm {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.search-input-group {
    display: flex;
    gap: 1rem;
}

.date-range-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.date-input {
    flex: 1;
    min-width: 200px;
}

.date-input label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.date-input input {
    width: 100%;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.date-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#searchQuery {
    flex: 1;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

#searchQuery:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#searchBtn {
    padding: 0.875rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#searchBtn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

#searchBtn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

.filters {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.filters label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.filters input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.advanced-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.advanced-filters select,
.advanced-filters input {
    padding: 0.625rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.3s ease;
}

.advanced-filters select:focus,
.advanced-filters input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.stats {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-total .stat-value {
    color: var(--success-color);
    font-size: 1.75rem;
}

.results-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.trial-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.trial-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.trial-card.source-clinicaltrials {
    border-left-color: #2563eb;
}

.trial-card.source-eudract {
    border-left-color: #f59e0b;
}

.trial-card.source-ctis {
    border-left-color: #10b981;
}

.trial-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.trial-id {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.trial-source {
    background: var(--bg-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-color);
}

.trial-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    line-height: 1.4;
}

.trial-condition {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.trial-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.status-recruiting {
    background: #dcfce7;
    color: #166534;
}

.status-completed {
    background: #dbeafe;
    color: #1e40af;
}

.status-active {
    background: #fef3c7;
    color: #92400e;
}

.status-suspended {
    background: #fee2e2;
    color: #991b1b;
}

.status-unknown {
    background: var(--bg-color);
    color: var(--text-light);
}

.trial-info {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.trial-info p {
    margin-bottom: 0.25rem;
}

.trial-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-link {
    flex: 1;
    padding: 0.5rem;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    border-left: 4px solid var(--danger-color);
}

.loader {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 3rem;
    background: var(--card-bg);
    border-radius: 12px;
    color: var(--text-light);
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

footer {
    text-align: center;
    padding: 2rem;
    color: white;
    opacity: 0.9;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .search-input-group {
        flex-direction: column;
    }

    .results-container {
        grid-template-columns: 1fr;
    }

    .stats {
        flex-direction: column;
    }
}
