/* File: assets/css/public.css */
/* Description: Frontend styles for research database display */

.research-database-search {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Search Form Styles */
.search-container {
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    align-items: start;
}

.search-field input,
.search-field select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background-color: white;
    white-space: normal;
    min-width: 200px;
    max-width: 100%;
    height: auto;
    min-height: 45px;
    text-overflow: ellipsis;
    overflow: visible;
}

.search-field select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.search-button {
    background-color: #3497ca !important;
    color: white !important;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.search-button:hover {
    background-color: #2980b9 !important;
}

/* Database Grid Styles */
.database-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.database-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition:
        transform 0.3s ease,
        box-shadow 0.3s ease;
}

.database-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.database-image-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.database-image-link:hover .database-image {
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.database-image-link:hover .text-fallback {
    background: linear-gradient(45deg, #ebebeb, #f8f8f8);
}

.database-image {
    height: 150px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #eee;
}

.database-image img {
    max-width: 100%;
    height: auto;
    max-height: 130px;
    object-fit: contain;
    padding: 10px;
}

.research-database-search .database-card .database-image .text-fallback {
    padding: 15px;
    text-align: center;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    background: linear-gradient(45deg, #f5f5f5, #ffffff);
}

.database-content {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.research-database-search .database-card .database-content h2 {
    margin: 0 0 10px 0;
    line-height: 1.3;
}

.database-excerpt {
    color: #666;
    flex-grow: 1;
    margin-bottom: 15px;
}

.database-links {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.research-database-search .database-card .database-links a {
    padding: 8px 12px;
    border-radius: 4px;
    text-decoration: none;
    text-align: center;
    flex: 1;
    transition:
        background-color 0.3s ease,
        transform 0.3s ease;
}

/* Ensure styles take precedence */
.research-database-search .database-card .access-button {
    color: white !important;
}

.research-database-search .database-card .access-button:hover {
    transform: translateY(-2px);
}

.research-database-search .database-card .info-button {
    color: #333;
    border: 1px solid #ddd;
}

.research-database-search .database-card .info-button:hover {
    transform: translateY(-2px);
}

/* Pagination Styles */
.pagination {
    margin-top: 30px;
    text-align: center;
}

.pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
}

.pagination .page-numbers.current {
    background-color: #3497ca;
    color: white;
    border-color: #3497ca;
}

.pagination .page-numbers:hover:not(.current) {
    background-color: #f5f5f5;
    border-color: #3497ca;
}

/* Loading State */
.database-results {
    position: relative;
    min-height: 200px;
}

.database-results.loading {
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.database-results.loading::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: #3497ca;
    animation: loading-bar 1s infinite linear;
    z-index: 1000;
}

@keyframes loading-bar {
    0% {
        width: 0;
    }
    20% {
        width: 20%;
    }
    40% {
        width: 40%;
    }
    60% {
        width: 60%;
    }
    80% {
        width: 80%;
    }
    100% {
        width: 100%;
    }
}

/* Remove the spinning wheel animation */
.database-results.loading::after {
    display: none;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .search-fields {
        grid-template-columns: 1fr;
    }

    .search-field select {
        width: 100%;
        min-width: unset;
    }

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

    .database-image {
        height: 160px;
    }
}

/* Accessibility Improvements */
.search-button:focus,
.database-links a:focus {
    outline: 2px solid #3497ca;
    outline-offset: 2px;
}

.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}
