/* Enhanced Publications Layout */
/* Fix for sticky positioning - override parent overflow hidden */
.cmd-publication-container,
.main,
.cmd-publication-container .main,
.cmd-publication-container .ban,
.cmd-publication-container .ban-table,
.cmd-publication-container .ban-table-row,
.cmd-publication-container .ban-table-cell {
    overflow: visible !important;
}

/* Ensure filter overlay can break out of container constraints */
.cmd-publication-container .filter-overlay,
.publications-page .filter-overlay,
.publications-main .filter-overlay,
.publications-layout .filter-overlay {
    position: fixed !important;
    z-index: 10001 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    /* Break out of any container positioning */
    transform: none !important;
    contain: none !important;
    isolation: auto !important;
}

/* Publications Page Structure */
.publications-page {
    min-height: 100vh;
    background: #fff;
}

.publications-header {
    background: #f8f9fa;
    padding: 140px 0 1rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.publications-header .container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.publications-header .title-h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 600;
    color: #333;
}

.publications-main {
    padding: 3rem 0;
}

.publications-main .container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.publications-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    /* Simple flex layout - no table complications */
}

/* Sidebar Styles */
.publications-sidebar {
    flex: 0 0 350px;
    position: sticky !important;
    position: -webkit-sticky !important;
    top: 110px !important; /* Back to reasonable spacing from top */
    height: fit-content;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Debug: Make sure no parent is interfering */
.publications-layout {
    display: flex !important;
    gap: 2rem;
    align-items: flex-start;
    overflow: visible !important;
    position: relative !important;
    /* Simple flex layout - no table complications */
}

.publications-content {
    flex: 1;
    min-width: 0;
}

/* Sidebar Styles */
.publications-sidebar {
    flex: 0 0 350px; /* Increased width from 300px to 350px */
    position: -webkit-sticky;
    position: sticky;
    top: 2rem;
    height: fit-content;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    /* Additional sticky fixes */
    backface-visibility: hidden;
}

/* Desktop Filter Sidebar */
.filter-sidebar {
    width: 100%;
    /* Ensure proper containment and no overflow issues */
    overflow: visible;
}

/* Mobile Search and Filter Bar Container */
.mobile-search-filter-bar {
    display: none; /* Hidden on desktop */
    flex-direction: row;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

/* Desktop Filter Sidebar - visible by default */

/* Mobile Filter Toggle Button */
.mobile-filter-toggle {
    display: none;
    flex: 0 0 auto;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0.75rem 1.5rem;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 123, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.mobile-filter-toggle:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
}

.mobile-filter-toggle .fa {
    margin-right: 0.5rem;
}

/* Mobile Search Bar */
.mobile-search-bar {
    display: none;
    flex: 1;
    position: relative;
}

.mobile-search-bar .search-box {
    position: relative;
    width: 100%;
}

.mobile-search-bar .search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 16px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.mobile-search-bar .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

/* Filter Overlay for Mobile */
.filter-overlay {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999 !important;
    backdrop-filter: blur(5px);
    /* Ensure it's not constrained by any parent */
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Break out of any positioning context */
    contain: none !important;
}

.filter-overlay.is-active {
    display: block !important;
}

.filter-overlay-content {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 90%;
    max-width: 400px;
    height: 100vh !important;
    background: white;
    padding: 2rem;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    /* Ensure proper containment */
    box-sizing: border-box;
}

.filter-overlay.is-active .filter-overlay-content {
    transform: translateX(0);
}

.filter-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.filter-overlay-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.filter-overlay-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.filter-overlay-close:hover {
    background-color: #f0f0f0;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* Additional mobile overlay positioning fixes */
@media (max-width: 768px) {
    .filter-overlay {
        /* Extra enforcement for mobile */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        z-index: 10000 !important;
        /* Break out of any container constraints */
        transform: none !important;
        clip: none !important;
        clip-path: none !important;
    }
    
    .filter-overlay-content {
        position: absolute !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        max-height: 100vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* Clear filters button styles */
.clear-filters-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.publications-content {
    flex: 1;
    min-width: 0;
}

/* Search Section */
.search-section {
    margin-bottom: 1.5rem; /* Reduced from 2rem to give more space */
}

.search-box {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    box-sizing: border-box; /* Ensure proper sizing */
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    pointer-events: none;
}

/* Filter Sections */
.filter-sections {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Reduced gap to fit better */
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.filter-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.filter-count {
    color: #666;
    font-size: 0.9rem;
    font-weight: normal;
}

.clear-filters-btn {
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
    padding: 0;
}

.clear-filters-btn:hover {
    color: #0056b3;
}

/* Filter Section */
.filter-section {
    margin-bottom: 1rem; /* Reduced from 1.5rem */
}

.filter-section-title {
    margin: 0 0 0.75rem 0 !important;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
}

.filter-list {
    display: flex;
    flex-direction: column;
    margin: auto;
    gap: 0.4rem; /* Slightly reduced gap */
}

.filter-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    width: 100%;
    padding: 0.25rem 0;
    transition: background-color 0.2s ease;
    border-radius: 4px;
}

.filter-item:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.filter-checkbox {
    margin-right: 0.5rem;
    accent-color: #007bff;
    flex-shrink: 0; /* Prevent checkbox from shrinking */
}

.filter-label {
    font-size: 0.9rem;
    line-height: 1.3;
    color: #555;
}

/* Results Header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.result-count {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

/* Loading States */
.proj-box.is-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem 2rem;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-weight: 500;
    color: #333;
    z-index: 10;
}

.loading-spinner::after {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.error-message {
    text-align: center;
    padding: 2rem;
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin: 1rem 0;
}

/* No Results */
.no-result {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.no-result h1 {
    font-size: 1.5rem;
    margin: 0;
    font-weight: 400;
}

/* Responsive Design */
@media (max-width: 768px) {
    .publications-layout {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Keep sidebar visible but adjust its styling */
    .publications-sidebar {
        width: 100%;
        position: static; /* Remove sticky positioning on mobile */
        flex: none; /* Remove fixed width on mobile */
        padding: 0; /* Remove padding on mobile */
        background: transparent; /* Remove background on mobile */
        box-shadow: none; /* Remove shadow on mobile */
    }
    
    /* Hide desktop filter sidebar on mobile */
    .filter-sidebar {
        display: none;
    }
    
    /* Show mobile search and filter bar */
    .mobile-search-filter-bar {
        display: flex;
    }
    
    .mobile-filter-toggle {
        display: flex;
        align-items: center;
    }
    
    .mobile-search-bar {
        display: flex;
    }
    
    .search-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .publications-layout {
        gap: 0.5rem;
    }
    
    .mobile-search-filter-bar {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .mobile-search-bar {
        flex: none;
        width: 100%;
    }
    
    .mobile-filter-toggle {
        flex: none;
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .filter-overlay-content {
        width: 100%;
        padding: 1rem;
    }
}

/* Legacy filter compatibility */
.legacy-filters {
    display: none !important;
}

/* Publications Grid Layout with proper gaps */
.proj-list {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
    gap: 30px !important;
    margin: 0 !important;
    padding: 0 !important;
}

.proj-item {
    padding: 0 !important;
    width: auto !important;
    list-style: none;
    display: block !important;
}

/* Publication items hover effects */
.cmd-publication {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cmd-publication:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Responsive grid adjustments */
@media (max-width: 1440px) {
    .proj-list {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
        gap: 20px !important;
    }
}

@media (max-width: 1024px) {
    .proj-list {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
        gap: 20px !important;
    }
}

@media (max-width: 640px) {
    .proj-list {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
}

/* Smooth transitions for filter changes */
.proj-list {
    transition: opacity 0.3s ease;
}

/* Pagination Styles */
.pagination-container {
    margin-top: 3rem;
    margin-bottom: 2rem;
}

.pagination-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.pagination {
    display: flex;
    justify-content: center;
}

.pagination-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.25rem;
    align-items: center;
}

.pagination-item {
    display: flex;
}

/* Enhanced Tag Info Styles - Clickable Tags */
.mintag-link {
    display: inline-flex;
    align-items: center;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    margin: 0.125rem;
    background: rgba(0, 123, 255, 0.1);
    border: 1px solid rgba(0, 123, 255, 0.2);
    cursor: pointer;
    user-select: none;
}

/* Clickable div styling instead of anchor */
.mintag-link[data-tag-url] {
    cursor: pointer;
}

.mintag-link:hover {
    background: rgba(0, 123, 255, 0.2);
    border-color: rgba(0, 123, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

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

.mintag-link:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 123, 255, 0.2);
}

/* Different colors for different tag types */
.mintag-link .is-theme {
    color: #007bff;
    font-weight: 500;
}

.mintag-link .is-type {
    color: #28a745;
    font-weight: 500;
}

/* Theme tags - blue color scheme */
.mintag-link:has(.is-theme),
.mintag-link.theme-tag {
    background: rgba(0, 123, 255, 0.1);
    border-color: rgba(0, 123, 255, 0.2);
}

.mintag-link:has(.is-theme):hover,
.mintag-link.theme-tag:hover {
    background: rgba(0, 123, 255, 0.2);
    border-color: rgba(0, 123, 255, 0.4);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* Type tags - green color scheme */
.mintag-link:has(.is-type),
.mintag-link.type-tag {
    background: rgba(40, 167, 69, 0.1);
    border-color: rgba(40, 167, 69, 0.2);
}

.mintag-link:has(.is-type):hover,
.mintag-link.type-tag:hover {
    background: rgba(40, 167, 69, 0.2);
    border-color: rgba(40, 167, 69, 0.4);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Icon styling within tags */
.mintag-link .fa {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.mintag-link:hover .fa {
    opacity: 1;
}

/* Mobile responsive tag styling */
@media (max-width: 768px) {
    .mintag-link {
        padding: 0.3rem 0.6rem;
        font-size: 0.9rem;
        margin: 0.1rem;
    }
    
    .mintag-link:hover {
        transform: none; /* Disable hover lift on mobile */
    }
}

/* Accessibility improvements */
.mintag-link:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .mintag-link {
        transition: none;
    }
    
    .mintag-link:hover {
        transform: none;
    }
}

.pagination-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    border: 1px solid #e0e0e0;
    background: white;
    color: #333;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    height: 44px;
    box-sizing: border-box;
}

.pagination-link:hover {
    background: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
}

.pagination-link.is-current {
    background: #007bff;
    border-color: #007bff;
    color: white;
    font-weight: 600;
    cursor: default;
}

.pagination-link.is-current:hover {
    transform: none;
}

.pagination-ellipsis {
    display: flex;
    align-items: center;
    padding: 0.75rem 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

.pagination-info {
    font-size: 0.85rem;
    color: #666;
    text-align: center;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-list {
        gap: 0.125rem;
    }
    
    .pagination-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-width: 40px;
        height: 40px;
    }
    
    .pagination-ellipsis {
        padding: 0.5rem 0.25rem;
    }
    
    .pagination-container {
        margin-top: 2rem;
        margin-bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .pagination-wrapper {
        gap: 0.75rem;
    }
    
    .pagination-link {
        padding: 0.5rem;
        font-size: 0.8rem;
        min-width: 36px;
        height: 36px;
    }
    
    /* Hide page numbers on very small screens, keep only prev/next */
    .pagination-item:not(:first-child):not(:last-child) {
        display: none;
    }
    
    .pagination-item:nth-child(2),
    .pagination-item:nth-last-child(2) {
        display: flex;
    }
}

.proj-box.is-loading .proj-list {
    opacity: 0.5;
}
