/**
 * Stereo-seq Publications Filter - Frontend Styles
 * Clean, professional styling for the publication filter interface
 */

/* Main container */
.stereoseq-filter-container {
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.4;
    background: #fff;
}

/* Filter section */
.stereoseq-filters {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 25px;
    border: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stereoseq-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.stereoseq-filters-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #495057;
    margin: 0;
}

.stereoseq-reset-filters {
    background: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s ease;
}

.stereoseq-reset-filters:hover {
    background: #5a6268;
}

.stereoseq-reset-filters:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

/* Search bar */
.stereoseq-search-container {
    margin-bottom: 15px;
}

.stereoseq-search-input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.stereoseq-search-input:focus {
    outline: none;
    border-color: #2c5aa0;
    box-shadow: 0 0 0 2px rgba(44, 90, 160, 0.1);
}

.stereoseq-search-input::placeholder {
    color: #6c757d;
}

/* Filter form */
.stereoseq-filter-form {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 20px !important;
    width: 100% !important;
    align-items: start !important;
    overflow: hidden !important;
}

/* Touch-friendly improvements for mobile devices */
@media (pointer: coarse) and (max-width: 768px) {
    .filter-tag {
        min-height: 40px;
        padding: 8px 14px;
        font-size: 12px;
        white-space: normal !important;
        max-width: 200px;
        word-break: auto-phrase;
    }
    
    .stereoseq-reset-filters {
        min-height: 44px;
        padding: 10px 16px;
    }
    
    .show-more-label {
        min-height: 44px;
        padding: 12px 20px;
    }
    
    .pagination-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 8px 12px;
    }
}

/* Responsive layout for smaller screens */
@media (max-width: 1024px) {
    .stereoseq-filter-form {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 16px !important;
        align-items: start !important;
        overflow: hidden !important;
    }
}

@media (max-width: 768px) {
    .stereoseq-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
        align-items: start !important;
        overflow: hidden !important;
    }
}

@media (max-width: 600px) {
    .stereoseq-filter-form {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 16px !important;
        align-items: start !important;
        overflow: hidden !important;
    }
    
    .filter-category {
        gap: 10px;
    }
    
    .filter-category-label {
        font-size: 13px;
        font-weight: 700;
    }
}

.filter-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: start;
    min-width: 0;
    overflow: hidden;
}

.filter-category-label {
    font-weight: 500;
    font-size: 12px;
    color: #656d76;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 2px;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-tag {
    background: white;
    border: 1px solid #d0d7de;
    border-radius: 14px;
    padding: 6px 12px;
    font-size: 12px !important;
    color: #1f2328;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    white-space: normal !important;
    min-height: 32px;
    max-width: 200px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    line-height: 1.3;
    word-break: auto-phrase;
    overflow-wrap: break-word;
}

.filter-tag:hover {
    background: #f6f8fa;
    border-color: #8c959f;
}

.filter-tag.active {
    background: #0969da;
    color: white;
    border-color: #0969da;
}

.filter-tag .count {
    color: #656d76;
    margin-left: 4px;
    font-size: 10px;
}

.filter-tag.active .count {
    color: rgba(255, 255, 255, 0.8);
}

/* Disabled filter tags (when count is 0) */
.filter-tag.disabled {
    background: #f8f9fa;
    color: #adb5bd;
    border-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

.filter-tag.disabled:hover {
    background: #f8f9fa;
    border-color: #e9ecef;
    color: #adb5bd;
}

.filter-tag.disabled .count {
    color: #adb5bd;
}

/* Hidden filter tags */
.filter-tag-hidden {
    display: none !important;
}

/* CSS Accordion Show More */
.stereoseq-show-more-container {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

/* Hide the checkbox */
.show-more-checkbox {
    display: none;
}

/* Style the label as a button */
.show-more-label {
    display: inline-block;
    background: transparent;
    border: 1px solid #0969da;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    color: #0969da;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.show-more-label:hover {
    background: #0969da;
    color: white;
}

/* Text switching - show "Show more" by default, hide "Show less" */
.show-less-text {
    display: none;
}

/* When checkbox is checked, hide "Show more" and show "Show less" */
.show-more-checkbox:checked + .show-more-label .show-more-text {
    display: none;
}

.show-more-checkbox:checked + .show-more-label .show-less-text {
    display: inline;
}

/* Hidden filter tags - hide by default */
.filter-tag-hidden {
    display: none !important;
}

/* Show hidden tags when checkbox is checked */
.show-more-checkbox:checked ~ * .filter-tag-hidden,
.stereoseq-filters:has(.show-more-checkbox:checked) .filter-tag-hidden {
    display: inline-block !important;
}

/* Results section */
.stereoseq-results {
    position: relative;
}

.stereoseq-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 10px;
}

.stereoseq-results-count {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

.stereoseq-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
    z-index: 10;
    border-radius: 4px;
}

.stereoseq-loading.hidden {
    display: none;
}

/* Publication list */
.stereoseq-publications-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stereoseq-publication-item {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 24px;
    transition: box-shadow 0.2s ease;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 24px;
    cursor: pointer;
}

.stereoseq-publication-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.publication-content {
    display: flex;
    flex-direction: column;
}

.publication-header {
    margin-bottom: 4px;
}

.publication-journal-date {
    color: #656d76;
    font-size: 14px;
    margin-bottom: 8px;
}

.publication-journal {
    font-weight: 500;
}

.publication-authors {
    color: #656d76;
    font-size: 14px;
}

.publication-title {
    margin: 0px 10px 15px 0px !important;
    font-size: 20px;
    line-height: 1.3;
    font-weight: 400;
    color: #1f2328;
}

.publication-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.publication-title a:hover {
    color: #0969da;
}

.publication-links {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    align-items: center;
}

.publication-links-left {
    display: flex;
    gap: 24px;
    align-items: center;
}

.publication-links-right {
    text-align: right;
}

.publication-technique {
    color: #656d76;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

a.publication-technique:hover {
    color: #0969da;
    text-decoration: underline;
}

.publication-link {
    color: #0969da;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.dataset-link {
    color: #0969da;
    font-weight: 500;
}

/* Publication Modal */
.publication-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px 20px 0 20px;
    display: flex;
    justify-content: flex-end;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 0 30px 30px 30px;
}

.modal-publication-header {
    margin-bottom: 20px;
}

.modal-publication-journal-date {
    color: #656d76;
    font-size: 16px;
    margin-bottom: 12px;
}

.modal-publication-title {
    font-size: 24px;
    font-weight: 600;
    color: #1f2328;
    line-height: 1.3;
    margin: 0 0 20px 0;
}

.modal-title-link {
    color: #1f2328;
    text-decoration: none;
    transition: color 0.2s ease;
    display: inline-block;
}

.modal-title-link:hover {
    color: #0969da;
    text-decoration: none;
}

.external-link-icon {
    font-size: 18px;
    margin-left: 8px;
    opacity: 0.7;
    vertical-align: super;
    line-height: 1;
    display: inline-block;
    transition: opacity 0.2s ease;
}

.modal-title-link:hover .external-link-icon {
    opacity: 1;
}

.modal-publication-authors {
    color: #1f2328;
    font-size: 16px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.modal-publication-authors strong {
    color: #1f2328;
    font-weight: 600;
}

.modal-publication-abstract {
    margin-bottom: 30px;
}

.modal-publication-abstract strong {
    color: #1f2328;
    font-weight: 600;
    font-size: 16px;
    display: block;
    margin-bottom: 10px;
}

.modal-publication-abstract p {
    color: #1f2328;
    line-height: 1.6;
    margin: 0;
    font-size: 15px;
}

.modal-publication-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.modal-publication-links-left {
    display: flex;
    gap: 24px;
    align-items: center;
}

.modal-publication-links-right {
    text-align: right;
}

/* Responsive modal */
@media (max-width: 768px) {
    .publication-modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 0 20px 20px 20px;
    }
    
    .modal-publication-title {
        font-size: 20px;
    }
    
    .modal-publication-links {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .modal-publication-links-right {
        text-align: left;
    }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

.publication-link:hover {
    color: #0550ae;
    text-decoration: underline;
}

.publication-metadata {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-left: 20px;
    border-left: 1px solid #e1e5e9;
}

.metadata-group {
    display: flex;
    flex-direction: column;
}

.metadata-label {
    color: #656d76;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.metadata-value {
    color: #1f2328;
    font-size: 13px;
    font-weight: 500;
}

/* No results */
.stereoseq-no-results {
    text-align: center;
    padding: 30px 20px;
    color: #6c757d;
    font-size: 14px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

/* Pagination */
.stereoseq-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3px;
    margin-top: 20px;
    flex-wrap: wrap;
    padding: 15px 0;
}

.pagination-btn {
    background: white;
    border: 1px solid #dee2e6;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s ease;
    min-width: 35px;
    color: #495057;
}

.pagination-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.pagination-btn.current {
    background: #2c5aa0;
    color: white;
    border-color: #2c5aa0;
}

.pagination-btn:disabled {
    background: #f8f9fa;
    color: #adb5bd;
    cursor: not-allowed;
    border-color: #dee2e6;
}

.pagination-dots {
    padding: 6px 4px;
    color: #adb5bd;
    font-size: 13px;
}

/* Enhanced mobile responsiveness */
@media (max-width: 768px) {
    .stereoseq-filter-container {
        margin: 0 12px;
    }
    
    .stereoseq-filters {
        padding: 16px;
        margin-bottom: 20px;
    }
    
    .stereoseq-filters-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 12px;
        margin-bottom: 16px;
    }
    
    .stereoseq-filters-title {
        font-size: 1.2em;
    }
    
    .stereoseq-reset-filters {
        padding: 10px 16px;
        font-size: 14px;
        border-radius: 6px;
    }
    
    .stereoseq-search-input {
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 8px;
    }
    
    .filter-tags {
        gap: 10px;
        justify-content: flex-start;
    }
    
    .filter-tag {
        padding: 8px 14px;
        font-size: 12px;
        min-height: 40px;
        flex: 0 0 auto;
        border-radius: 18px;
        white-space: normal !important;
        max-width: 200px;
        word-break: auto-phrase;
    }
    
    .show-more-label {
        padding: 12px 20px;
        font-size: 15px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .stereoseq-results-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        margin-bottom: 20px;
    }
    
    .stereoseq-results-count {
        font-size: 15px;
        padding: 8px 0;
    }
    
    .stereoseq-publication-item {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px 16px;
        margin: 0 -4px;
    }
    
    .publication-header {
        margin-bottom: 10px;
    }
    
    .publication-journal-date {
        font-size: 15px;
        margin-bottom: 10px;
    }
    
    .publication-title {
        font-size: 18px;
        line-height: 1.4;
        margin-bottom: 14px;
    }
    
    .publication-links {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .publication-links-left {
        gap: 16px;
    }
    
    .publication-links-right {
        text-align: left;
        margin-top: 8px;
    }
    
    .publication-technique {
        font-size: 15px;
    }
    
    .publication-link {
        font-size: 15px;
    }
    
    .publication-metadata {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid #e1e5e9;
        padding-top: 20px;
        flex-direction: column;
        gap: 14px;
    }
    
    .metadata-group {
        min-width: auto;
        flex: none;
    }
    
    .metadata-label {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .metadata-value {
        font-size: 14px;
    }
    
    .stereoseq-pagination {
        gap: 4px;
        padding: 16px 0;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination-btn {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 40px;
        min-height: 44px;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    .stereoseq-filter-container {
        margin: 0 8px;
    }
    
    .stereoseq-filters {
        padding: 12px;
        margin-bottom: 16px;
    }
    
    .stereoseq-filters-header {
        gap: 10px;
        margin-bottom: 12px;
    }
    
    .stereoseq-filters-title {
        font-size: 1.1em;
    }
    
    .stereoseq-reset-filters {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .stereoseq-search-input {
        padding: 10px 14px;
        font-size: 16px;
    }
    
    .filter-category {
        gap: 8px;
    }
    
    .filter-category-label {
        font-size: 12px;
    }
    
    .filter-tags {
        gap: 8px;
    }
    
    .filter-tag {
        padding: 6px 12px;
        font-size: 12px;
        min-height: 36px;
        border-radius: 16px;
        white-space: normal !important;
        max-width: 200px;
        word-break: auto-phrase;
    }
    
    .show-more-label {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 40px;
    }
    
    .stereoseq-publication-item {
        padding: 16px 12px;
        margin: 0 -2px;
        gap: 16px;
    }
    
    .publication-journal-date {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .publication-title {
        font-size: 16px;
        line-height: 1.3;
        margin-bottom: 12px;
    }
    
    .publication-links {
        gap: 6px;
    }
    
    .publication-links-left {
        gap: 12px;
    }
    
    .publication-technique {
        font-size: 14px;
    }
    
    .publication-link {
        font-size: 14px;
    }
    
    .publication-metadata {
        padding-top: 16px;
        gap: 12px;
    }
    
    .metadata-label {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    .metadata-value {
        font-size: 13px;
    }
    
    .stereoseq-pagination {
        gap: 2px;
        padding: 12px 0;
    }
    
    .pagination-btn {
        padding: 6px 10px;
        font-size: 13px;
        min-width: 36px;
        min-height: 40px;
    }
}

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

/* Focus styles for keyboard navigation */
.stereoseq-reset-filters:focus,
.filter-group select:focus,
.view-details-link:focus,
.pagination-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .stereoseq-filters,
    .stereoseq-pagination {
        display: none;
    }
    
    .stereoseq-publication-item {
        break-inside: avoid;
        border: 1px solid #ddd;
        margin-bottom: 20px;
    }
}