/* CSS Variables */
:root {
    --primary-color: #1a5276;
    --primary-dark: #0e3d5a;
    --secondary-color: #2e86ab;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #c0392b;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --text-color: #333333;
    --text-light: #666666;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --radius: 8px;
    --radius-sm: 4px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 40px 0;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.header .subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Info Section */
.info-section {
    margin: 30px 0;
}

.info-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.info-card h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.info-card p {
    margin-bottom: 10px;
    color: var(--text-light);
}

.info-card p:last-child {
    margin-bottom: 0;
}

/* Search Section */
.search-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 82, 118, 0.1);
}

.clear-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 5px;
    display: none;
}

.clear-btn.visible {
    display: block;
}

.clear-btn:hover {
    color: var(--danger-color);
}

/* Filters */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

.filter-group select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background-color: var(--white);
    cursor: pointer;
    transition: border-color 0.3s;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Legend Section */
.legend-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.legend-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    background: var(--light-bg);
    border-radius: var(--radius-sm);
}

.legend-item p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge.low-risk {
    background-color: #d4edda;
    color: #155724;
}

.badge.under-advice {
    background-color: #fff3cd;
    color: #856404;
}

.badge.prescribed {
    background-color: #f8d7da;
    color: #721c24;
}

.badge.included {
    background-color: #d1ecf1;
    color: #0c5460;
}

.badge.conditional {
    background-color: #e2e3e5;
    color: #383d41;
}

.badge.excluded {
    background-color: #f5c6cb;
    color: #721c24;
}

/* Results Section */
.results-section {
    margin-bottom: 40px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.results-header h2 {
    color: var(--primary-color);
    font-size: 1.4rem;
}

.result-count {
    background: var(--primary-color);
    color: var(--white);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

/* Result Card */
.result-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--primary-color);
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.result-card.excluded {
    border-left-color: var(--danger-color);
    opacity: 0.85;
}

.result-card.conditional {
    border-left-color: var(--warning-color);
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 10px;
}

.result-card h3 {
    font-size: 1.1rem;
    color: var(--text-color);
    margin: 0;
    flex: 1;
}

.result-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.result-card-category {
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-weight: 500;
}

.result-card-description {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.result-card-details {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 12px;
}

.result-card-details p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 6px;
}

.result-card-details strong {
    color: var(--text-color);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.no-results h3 {
    color: var(--text-color);
    margin-bottom: 10px;
}

.no-results p {
    color: var(--text-light);
}

/* Footer */
.footer {
    background: var(--primary-dark);
    color: var(--white);
    padding: 30px 0;
    margin-top: 40px;
}

.footer p {
    font-size: 0.9rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.footer p:last-child {
    margin-bottom: 0;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 30px 0;
    }

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

    .header .subtitle {
        font-size: 1rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .legend-items {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .search-box input {
        padding: 12px 45px 12px 15px;
        font-size: 1rem;
    }

    .result-card-header {
        flex-direction: column;
    }

    .result-card-badges {
        order: -1;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus styles for accessibility */
a:focus,
button:focus,
input:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .header {
        background: none;
        color: var(--text-color);
    }

    .search-section,
    .legend-section {
        display: none;
    }

    .result-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}
