/**
 * MJ AJAX Filter - Enhanced CSS
 * Version: 3.0.0
 */

/* Container */
#mj-filter-container {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#mj-filter-container.mj-loading {
    pointer-events: none;
}

/* Posts Container */
.mj-posts-container {
    position: relative;
    min-height: 400px;
    transition: all 0.3s ease;
}

.mj-posts-grid {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Loader Container */
.mj-loader-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 12px;
    backdrop-filter: blur(4px);
}

/* Loader Animations */
.mj-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: mj-spin 1s linear infinite;
}

.mj-loader-dots {
    display: inline-block;
    position: relative;
    width: 64px;
    height: 16px;
}

.mj-loader-dots div {
    position: absolute;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #007cba;
    animation: mj-dots 1.2s linear infinite;
}

.mj-loader-dots div:nth-child(1) {
    left: 8px;
    animation-delay: 0s;
}

.mj-loader-dots div:nth-child(2) {
    left: 26px;
    animation-delay: -0.4s;
}

.mj-loader-dots div:nth-child(3) {
    left: 44px;
    animation-delay: -0.8s;
}

.mj-loader-pulse {
    width: 40px;
    height: 40px;
    background-color: #007cba;
    border-radius: 100%;
    animation: mj-pulse 1.5s ease-in-out infinite;
}

.mj-loader-bars {
    display: inline-block;
    position: relative;
    width: 40px;
    height: 40px;
}

.mj-loader-bars div {
    display: inline-block;
    position: absolute;
    left: 4px;
    width: 6px;
    background: #007cba;
    animation: mj-bars 1.2s cubic-bezier(0, 0.5, 0.5, 1) infinite;
}

.mj-loader-bars div:nth-child(1) {
    left: 4px;
    animation-delay: -0.24s;
}

.mj-loader-bars div:nth-child(2) {
    left: 14px;
    animation-delay: -0.12s;
}

.mj-loader-bars div:nth-child(3) {
    left: 24px;
    animation-delay: 0;
}

.mj-loader-bars div:nth-child(4) {
    left: 34px;
    animation-delay: 0.12s;
}

.mj-loader-ripple {
    display: inline-block;
    position: relative;
    width: 40px;
    height: 40px;
}

.mj-loader-ripple div {
    position: absolute;
    border: 4px solid #007cba;
    opacity: 1;
    border-radius: 50%;
    animation: mj-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.mj-loader-ripple div:nth-child(2) {
    animation-delay: -0.5s;
}

.mj-loader-text {
    margin-top: 15px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Keyframes */
@keyframes mj-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes mj-dots {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes mj-pulse {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

@keyframes mj-bars {
    0% {
        top: 4px;
        height: 32px;
    }
    50%, 100% {
        top: 12px;
        height: 16px;
    }
}

@keyframes mj-ripple {
    0% {
        top: 18px;
        left: 18px;
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        top: 0px;
        left: 0px;
        width: 32px;
        height: 32px;
        opacity: 0;
    }
}

/* Layout Styles */
.mj-layout-grid .row {
    display: flex;
    flex-wrap: wrap;
    margin: -0.75rem;
}

.mj-layout-grid .row > div {
    padding: 0.75rem;
}

.mj-layout-list .card {
    flex-direction: row;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.mj-layout-list .card-img-top,
.mj-layout-list .list-img {
    width: 250px;
    height: 180px;
    object-fit: cover;
    flex-shrink: 0;
}

.mj-layout-list .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.mj-layout-list .card-footer {
    margin-top: auto;
}

/* Filter Tabs */
.mj-filter-tabs {
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 2rem;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.mj-filter-tabs::-webkit-scrollbar {
    height: 6px;
}

.mj-filter-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.mj-filter-tabs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.mj-filter-tabs .nav-item {
    display: inline-block;
}

.mj-filter-tabs .nav-link {
    color: #495057;
    border: 1px solid transparent;
    border-radius: 0.375rem 0.375rem 0 0;
    padding: 0.875rem 1.25rem;
    margin-bottom: -1px;
    margin-right: 0.25rem;
    background: transparent;
    transition: all 0.2s ease-in-out;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    font-weight: 500;
    cursor: pointer;
    border: none;
}

.mj-filter-tabs .nav-link:hover {
    color: #007cba;
    background-color: rgba(0, 123, 186, 0.1);
    transform: translateY(-2px);
}

.mj-filter-tabs .nav-link.active {
    color: #007cba;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-bottom-color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 186, 0.15);
}

.mj-filter-tabs .nav-link:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Tab Style Variations */
.tab-style-modern .nav-link {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    border-radius: 12px;
    margin: 0 0.5rem 0.5rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.tab-style-modern .nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.tab-style-modern .nav-link:hover::before {
    left: 100%;
}

.tab-style-modern .nav-link.active,
.tab-style-modern .nav-link:hover {
    background: linear-gradient(135deg, #007cba 0%, #0056b3 100%);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 123, 186, 0.4);
}

.tab-style-classic .nav-link {
    background: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-right: 0.5rem;
    font-weight: 600;
}

.tab-style-classic .nav-link:hover {
    border-color: #007cba;
    background: rgba(0, 123, 186, 0.05);
}

.tab-style-classic .nav-link.active {
    background: #007cba;
    border-color: #007cba;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 123, 186, 0.3);
}

.tab-style-pills .nav-link {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 25px;
    margin-right: 0.75rem;
    padding: 0.75rem 1.5rem;
}

.tab-style-pills .nav-link:hover {
    background: rgba(0, 123, 186, 0.1);
    border-color: #007cba;
    transform: scale(1.05);
}

.tab-style-pills .nav-link.active {
    background: #007cba;
    border-color: #007cba;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 123, 186, 0.3);
}

/* Badge Styles */
.mj-filter-tabs .badge {
    background-color: rgba(0, 0, 0, 0.15);
    color: inherit;
    font-size: 0.75em;
    font-weight: 600;
    padding: 0.25em 0.6em;
    border-radius: 12px;
    min-width: 18px;
    text-align: center;
}

.mj-filter-tabs .nav-link.active .badge {
    background-color: rgba(255, 255, 255, 0.25);
    color: white;
}

/* Layout Switcher */
.mj-layout-switcher .btn {
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.mj-layout-btn {
    position: relative;
    overflow: hidden;
}

.mj-layout-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.3s;
}

.mj-layout-btn:hover:before {
    left: 100%;
}

.mj-layout-btn.active {
    background-color: #007cba;
    border-color: #007cba;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 123, 186, 0.3);
    transform: translateY(-1px);
}

/* Search Input */
#mj-search-input {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: #fff;
}

#mj-search-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 186, 0.25);
    outline: none;
}

/* Dropdown Filter */
#mj-category-filter {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: #fff;
}

#mj-category-filter:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 186, 0.25);
    outline: none;
}

/* Reset Button */
#mj-reset-filters {
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

#mj-reset-filters:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Pagination */
#mj-pagination {
    margin-top: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.mj-page-btn {
    min-width: 44px;
    height: 44px;
    border: 2px solid #dee2e6;
    background: white;
    color: #007cba;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.mj-page-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 123, 186, 0.1), transparent);
    transition: left 0.3s;
}

.mj-page-btn:hover:before {
    left: 100%;
}

.mj-page-btn:hover {
    background: #f8f9fa;
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 186, 0.2);
}

.mj-page-btn.active {
    background: #007cba;
    border-color: #007cba;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 186, 0.4);
}

.mj-page-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Pagination Styles */
.pagination-circle .mj-page-btn {
    border-radius: 50%;
    width: 44px;
    height: 44px;
}

.pagination-square .mj-page-btn {
    border-radius: 4px;
}

.pagination-rounded .mj-page-btn {
    border-radius: 12px;
}

/* Cards */
.card {
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    background: #fff;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 123, 186, 0.2);
}

.card-img-top {
    height: 220px;
    object-fit: cover;
    transition: transform 0.4s ease;
    cursor: pointer;
}

.card:hover .card-img-top {
    transform: scale(1.08);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.card-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.card-title a:hover {
    color: #007cba;
}

.card-text {
    line-height: 1.6;
    color: #666;
    margin-bottom: 1rem;
}

.mj-post-meta {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f0f0f0;
    font-size: 0.875rem;
}

.card-footer {
    background: rgba(248, 249, 250, 0.8);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem 1.5rem;
}

.mj-read-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mj-read-more:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.3s;
}

.mj-read-more:hover:before {
    left: 100%;
}

.mj-read-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 186, 0.3);
}

/* Category Badge */
.mj-category-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: linear-gradient(135deg, #007cba 0%, #0056b3 100%);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 123, 186, 0.4);
    backdrop-filter: blur(8px);
}

/* No Posts Message */
#mj-no-posts {
    text-align: center;
    padding: 4rem 2rem;
    margin: 3rem 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #dee2e6;
}

#mj-no-posts h5 {
    color: #6c757d;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

#mj-no-posts p {
    color: #6c757d;
    font-size: 1rem;
}

/* Error Messages */
.mj-error-alert {
    border-radius: 12px;
    margin-bottom: 2rem;
    border: none;
    box-shadow: 0 4px 20px rgba(220, 53, 69, 0.2);
    animation: slideInDown 0.4s ease;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -100%, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.mj-retry-btn {
    border-radius: 6px;
    font-size: 0.875rem;
    padding: 0.4rem 0.8rem;
    font-weight: 500;
}

/* Focus Styles for Accessibility */
.mj-filter-tabs .nav-link:focus,
.mj-layout-btn:focus,
.mj-page-btn:focus,
#mj-search-input:focus,
#mj-category-filter:focus,
#mj-reset-filters:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Loading State */
.mj-posts-grid[style*="opacity: 0.5"] {
    pointer-events: none;
    filter: blur(1px);
}

/* Smooth Transitions */
* {
    transition: color 0.2s ease-in-out, 
                background-color 0.2s ease-in-out, 
                border-color 0.2s ease-in-out, 
                box-shadow 0.2s ease-in-out,
                transform 0.2s ease-in-out;
}

/* Responsive Design */
@media (max-width: 992px) {
    .mj-layout-list .card-img-top,
    .mj-layout-list .list-img {
        width: 200px;
        height: 150px;
    }
    
    .card-img-top {
        height: 200px;
    }
    
    .mj-filter-tabs .nav-link {
        padding: 0.75rem 1rem;
        margin-right: 0.25rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .mj-layout-list .card {
        flex-direction: column;
    }
    
    .mj-layout-list .card-img-top,
    .mj-layout-list .list-img {
        width: 100%;
        height: 200px;
    }
    
    .mj-filter-tabs {
        margin-bottom: 1.5rem;
    }
    
    .mj-filter-tabs .nav-link {
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
        padding: 0.6rem 0.9rem;
    }
    
    .tab-style-modern .nav-link,
    .tab-style-classic .nav-link,
    .tab-style-pills .nav-link {
        margin-right: 0.25rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    .card-img-top {
        height: 180px;
    }
    
    #mj-pagination {
        margin-top: 2rem;
    }
    
    .mj-page-btn {
        min-width: 40px;
        height: 40px;
        font-size: 0.875rem;
    }
    
    .mj-category-badge {
        top: 10px;
        left: 10px;
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    .card-img-top {
        height: 160px;
    }
    
    .mj-loader-container {
        padding: 2rem 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-footer {
        padding: 0.75rem 1rem;
    }
    
    .mj-filter-tabs .nav-link {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    
    #mj-no-posts {
        padding: 3rem 1.5rem;
    }
    
    #mj-no-posts h5 {
        font-size: 1.25rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translate3d(-30px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }
    
    .mj-filter-tabs .nav-link {
        border: 2px solid #000;
    }
    
    .mj-page-btn {
        border: 2px solid #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .card:hover {
        transform: none;
    }
    
    .mj-read-more:hover {
        transform: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    #mj-filter-container {
        color: #e9ecef;
    }
    
    .card {
        background: #2d3748;
        border-color: #4a5568;
        color: #e9ecef;
    }
    
    .card-title a {
        color: #e9ecef;
    }
    
    .card-title a:hover {
        color: #63b3ed;
    }
    
    .card-text {
        color: #cbd5e0;
    }
    
    
    .mj-loader-container {
        background: rgba(45, 55, 72, 0.95);
    }
    
    #mj-search-input,
    #mj-category-filter {
        border-color: #4a5568;
        color: #4a5568;
    }
    
    .mj-filter-tabs .nav-link {
        color: #cbd5e0;
        background: #2d3748;
    }
    
    .mj-filter-tabs .nav-link.active {
        background: #63b3ed;
        color: #1a202c;
    }
    
    .mj-page-btn {
        background: #2d3748;
        border-color: #4a5568;
        color: #63b3ed;
    }
    
    .mj-page-btn.active {
        background: #63b3ed;
        color: #1a202c;
    }
    
    #mj-no-posts {
        background: #2d3748;
        border-color: #4a5568;
        color: #cbd5e0;
    }
}

/* Print Styles */
@media print {
    #mj-filter-container .mj-filter-tabs,
    #mj-filter-container .mj-layout-switcher,
    #mj-filter-container #mj-search-input,
    #mj-filter-container #mj-category-filter,
    #mj-filter-container #mj-reset-filters,
    #mj-filter-container #mj-pagination {
        display: none !important;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .card:hover {
        transform: none;
    }
    
    .mj-read-more {
        display: none;
    }
}

/* Utility Classes */
.mj-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mj-hide {
    display: none !important;
}

.mj-show {
    display: block !important;
}

.mj-fade {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.mj-fade.mj-show {
    opacity: 1;
}