/* Basic Layout Styles */
body {
    font-family: Arial, sans-serif;
    margin: 0; 
    padding: 0;
    background: #f8fafc;
    color: #222;
}

header {
    background: #CCCCCC;
    color: #993333;
    padding: 2rem 1rem 1rem 1rem;
    text-align: center;
    border-bottom: none;
    position: relative;
}

.header-bar-img {
    display: block;
    width: 100%;
    height: 18px;
    object-fit: cover;
    margin: 0;
    padding: 0;
}

main {
    max-width: 900px;
    margin: 2rem auto;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Navigation Styles */
.main-nav {
    background: #993333;
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.nav-links a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.nav-links a:hover,
.nav-links a:focus {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Footer Styles */
.site-footer {
    background: #f8f9fa;
    padding: 2rem 1rem;
    text-align: center;
    border-top: 1px solid #e9ecef;
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.footer-social a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-social a:hover,
.footer-social a:focus {
    color: #993333;
}

.footer-social img {
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

.footer-social-text {
    font-size: 0.9rem;
}

.footer-copy {
    color: #666;
    font-size: 0.9rem;
}

/* Filter Styles */
#filters {
    margin: 2rem 0;
}

.gallery-container {
    position: relative;
    margin: 2rem 0;
    padding: 0 3rem;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #993333;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.gallery-nav:hover {
    background: #7a2929;
}

.gallery-nav.prev {
    left: 0;
}

.gallery-nav.next {
    right: 0;
}

.gallery-nav:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.gallery-nav:disabled:hover {
    background: #ccc;
}

#filters h3 {
    color: #993333;
    margin-bottom: 1rem;
    text-align: center;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #993333;
    background: white;
    color: #993333;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: #993333;
    color: white;
}

.filter-btn.active {
    background: #993333;
    color: white;
}

/* Gallery Styles */
.gallery-grid {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem 0;
    scroll-behavior: smooth;
}

.gallery-grid::-webkit-scrollbar {
    height: 8px;
}

.gallery-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.gallery-grid::-webkit-scrollbar-thumb {
    background: #993333;
    border-radius: 4px;
}

.gallery-grid::-webkit-scrollbar-thumb:hover {
    background: #7a2929;
}

.gallery-item {
    flex: 0 0 auto;
    width: 220px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.gallery-item a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.gallery-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.item-overlay {
    display: none;
}

.item-overlay h3 {
    margin: 0 0 0.5rem 0;
    color: #993333;
    font-size: 1rem;
}

.item-overlay p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

/* Fancybox Caption Styles */
.fancybox__caption {
    text-align: center;
    color: #333;
    font-size: 1.1em;
    font-weight: 500;
}

/* Disease Information Table Styles */
#data-table {
    margin: 2rem 0;
    padding: 0 1rem;
}

#data-table h2 {
    color: #993333;
    text-align: center;
    margin-bottom: 1.5rem;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: white;
}

.disease-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-family: 'Arial', sans-serif;
}

.disease-table thead {
    background: linear-gradient(135deg, #993333, #b34444);
    color: white;
}

.disease-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 1.1em;
    border-bottom: 2px solid #7a2929;
}

.disease-table td {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: top;
}

.disease-table tbody tr:hover {
    background-color: #f8f8f8;
    transition: background-color 0.2s ease;
}

.disease-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.disease-table tbody tr:nth-child(even):hover {
    background-color: #f0f0f0;
}

.disease-name {
    font-weight: 600;
    color: #333;
    font-size: 1.05em;
}

.disease-link {
    color: #993333;
    text-decoration: none;
    font-weight: 500;
    word-break: break-word;
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    line-height: 1.4;
}

.disease-link:hover {
    color: #b34444;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.disease-link:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Table column width controls */
.disease-table th:nth-child(1),
.disease-table td:nth-child(1) {
    width: 25%;
    min-width: 150px;
}

.disease-table th:nth-child(2),
.disease-table td:nth-child(2) {
    width: 50%;
    min-width: 200px;
    max-width: 400px;
}

.disease-table th:nth-child(3),
.disease-table td:nth-child(3) {
    width: 25%;
    min-width: 150px;
}

/* Category Description Styles */
.category-description {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    border-left: 4px solid #007bff;
    border-radius: 4px;
    font-style: italic;
    color: #495057;
    line-height: 1.6;
}

.category-description p {
    margin: 0;
}

/* Search Styles */
#search-section {
    margin: 2rem 0;
    padding: 0 1rem;
}

#search-section h3 {
    color: #993333;
    margin-bottom: 1rem;
    text-align: center;
}

.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

#disease-search,
#resource-search,
#business-search {
    width: 100%;
    max-width: 500px;
    padding: 1rem 1.5rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

#disease-search:focus,
#resource-search:focus,
#business-search:focus {
    outline: none;
    border-color: #993333;
    box-shadow: 0 0 0 3px rgba(153, 51, 51, 0.1);
}

#disease-search::placeholder,
#resource-search::placeholder,
#business-search::placeholder {
    color: #999;
    font-style: italic;
}

/* Search Clear Button */
.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: none;
    z-index: 10;
}

.search-clear:hover {
    background-color: #f0f0f0;
    color: #666;
}

.search-clear:active {
    background-color: #e0e0e0;
    color: #333;
}

.search-clear.show {
    display: block;
}

/* Adjust search input padding to make room for clear button */
#disease-search,
#resource-search,
#business-search {
    padding-right: 2.5rem;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    pointer-events: auto; /* Ensure click events work */
    margin-top: 2px; /* Add some space between input and results */
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item.selected {
    background-color: #993333;
    color: white;
}

.search-result-item .disease-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.search-result-item .disease-category {
    font-size: 0.9rem;
    color: #666;
}

.search-result-item.selected .disease-category {
    color: #f0f0f0;
}

/* Highlight search term in results */
.search-highlight {
    background-color: #fff3cd;
    font-weight: bold;
}

.search-result-item.selected .search-highlight {
    background-color: #e6b800;
    color: #000;
}

/* Filter Select Styles */
.filter-select-container {
    display: none;
    margin-bottom: 2rem;
}

.filter-select {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    border: 2px solid #993333;
    border-radius: 6px;
    background: white;
    color: #993333;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-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='%23993333' 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: 1rem;
    padding-right: 2.5rem;
}

.filter-select:focus {
    outline: none;
    border-color: #7a2929;
    box-shadow: 0 0 0 3px rgba(153, 51, 51, 0.1);
}

.filter-select option {
    padding: 0.5rem;
    background: white;
    color: #333;
}

/* Enhanced Filter Select Styles */
.filter-select-container {
    display: none;
    margin-bottom: 2rem;
    text-align: center;
}

.filter-select {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    border: 2px solid #993333;
    border-radius: 6px;
    background: white;
    color: #993333;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-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='%23993333' 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: 1rem;
    padding-right: 2.5rem;
    transition: all 0.2s ease;
}

.filter-select:hover {
    border-color: #7a2929;
    background-color: #f9f9f9;
}

.filter-select:focus {
    outline: none;
    border-color: #7a2929;
    box-shadow: 0 0 0 3px rgba(153, 51, 51, 0.1);
    background-color: white;
}

.filter-select option {
    padding: 0.5rem;
    background: white;
    color: #333;
    font-size: 0.95rem;
}

.filter-select option:hover {
    background-color: #f0f0f0;
}

/* Mobile styles */
@media (max-width: 768px) {
    .filter-buttons {
        display: none; /* Hide buttons on mobile */
    }
    
    .filter-select-container {
        display: block; /* Show dropdown on mobile */
    }
    
    .filter-select {
        font-size: 0.95rem;
        padding: 0.7rem 1rem;
        padding-right: 2.5rem;
        border-radius: 8px;
    }
    
    /* Ensure proper touch target size */
    .filter-select {
        min-height: 44px; /* iOS recommended touch target */
    }
}

@media (max-width: 480px) {
    .filter-select {
        font-size: 0.9rem;
        padding: 0.6rem 0.9rem;
        padding-right: 2.5rem;
        max-width: 280px;
        border-radius: 6px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .filter-select {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .filter-select {
        transition: none;
    }
}

/* Responsive Styles */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        gap: 0;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #993333;
        padding: 1rem;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links li {
        margin: 0;
    }

    .nav-links a {
        display: block;
        padding: 0.75rem 1rem;
    }

    .nav-toggle {
        display: block;
    }

    .footer-social {
        flex-direction: column;
        gap: 1rem;
    }

    .footer-social a {
        justify-content: center;
    }

    .filter-buttons {
        display: none; /* Hide buttons on mobile */
    }

    .filter-select-container {
        display: block; /* Show dropdown on mobile */
    }
    
    .filter-select {
        font-size: 0.95rem;
        padding: 0.7rem 1rem;
        padding-right: 2.5rem;
    }

    .filter-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .gallery-grid {
        gap: 0.5rem;
    }

    .gallery-item {
        width: 170px;
    }

    .gallery-item img {
        height: 200px;
    }

    .item-overlay {
        display: none;
    }

    .gallery-container {
        padding: 0 2rem;
    }

    .gallery-nav {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }

    .gallery-nav.prev {
        left: 0.5rem;
    }

    .gallery-nav.next {
        right: 0.5rem;
    }

    .disease-table {
        font-size: 0.9em;
    }
    
    .disease-table th,
    .disease-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .disease-name {
        font-size: 1em;
    }
    
    .disease-link {
        font-size: 0.9em;
        white-space: normal;
        word-break: break-word;
    }

    .category-description {
        margin: 1rem 0;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        gap: 0.25rem;
    }

    .gallery-item {
        width: 140px;
    }

    .gallery-item img {
        height: 160px;
    }

    .item-overlay {
        display: none;
    }

    .gallery-container {
        padding: 0 1.5rem;
    }

    .gallery-nav {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }

    .gallery-nav.prev {
        left: 0.25rem;
    }

    .gallery-nav.next {
        right: 0.25rem;
    }

    #data-table {
        padding: 0 0.5rem;
    }
    
    .disease-table {
        font-size: 0.85em;
    }
    
    .disease-table th,
    .disease-table td {
        padding: 0.5rem 0.25rem;
    }
    
    .disease-name {
        font-size: 0.95em;
    }
    
    .disease-link {
        font-size: 0.85em;
    }

    .filter-select {
        font-size: 0.9rem;
        padding: 0.6rem 0.9rem;
        padding-right: 2.5rem;
        max-width: 280px;
    }
}