/*
Plugin: ردیف دسته بندی (Category Row)
File: category-row.css - این فایل باید کنار فایل افزونه (radife-daste-bandi.php) در یک پوشه باشد
Version: 2.2
*/

/* پایه‌ی .section-header (قبلاً از استایل سایت به ارث می‌رسید؛ حالا مستقل و scope شده) */
.category-row-container .section-header {
    color: #2c3e50;
    padding: 12px 15px;
    margin-bottom: 0;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px 6px 0 0;
    border-bottom: none;
}

/* :where() باعث می‌شود اولویت (specificity) این قاعده صفر باشد و روی padding کلاس‌های قالب (مثل .homepage-logo-item) غلبه نکند */
:where(.category-row-container) * {
    padding: 0;
    box-sizing: border-box;
}

.category-row-container {
    max-width: 1400px;
    margin: 20px auto;
    direction: rtl;
}

.section-header-wrapper {
    background: #ffffffa1;
    border-radius: 20px;
    padding: 0px 10px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 4px 12px rgba(31, 38, 135, 0.08);
    margin-top: 60px;
}

.category-row-container .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 0;
}

.section-title {
    font-size: 18px;
    background: linear-gradient(to bottom, #1e3c72, #2a5298);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    flex-shrink: 0;
    position: relative;
    padding-right: 15px;
}

.section-title:before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: linear-gradient(to bottom, #1e3c72, #2a5298);
    border-radius: 2px;
}

.desktop-tabs {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: flex-start;
}

.category-tab {
    background: #fff;
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 4px 12px rgba(31, 38, 135, 0.08);
    padding: 6px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #495057;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 599;
}

.category-tab:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.category-tab.active {
    background: #3498db;
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

.post-new-badge {
    position: absolute;
    bottom: 5px;
    left: 15px;
    background: #e53935eb;
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    z-index: 10;
}

.view-all-btn {
    background: #3498db;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    padding: 6px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
    height: 32px;
}

.view-all-btn:hover {
    background: #2980b9;
}

.mobile-tabs-dropdown {
    display: none;
    position: relative;
    flex: 0 1 auto;
    min-width: 0;
}

.mobile-tabs-toggle {
    background: #fff;
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 4px 12px rgba(31, 38, 135, 0.08);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 32px;
}

.mobile-tabs-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: white;
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 4px 12px rgba(31, 38, 135, 0.08);
    border-radius: 14px;
    padding: 8px 0;
    margin-top: 5px;
    z-index: 1000;
}

.mobile-tabs-menu.active {
    display: block;
}

.mobile-tab {
    background: transparent;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #495057;
    text-align: right;
    width: 100%;
    transition: background 0.2s;
    white-space: nowrap;
}

.mobile-tab:hover {
    background: #f8f9fa;
}

.mobile-tab.active {
    color: #3498db;
    font-weight: 500;
}

.posts-container {
    position: relative;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

@media only screen and (max-width: 1200px) and (min-width: 769px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

.post-card {
    background: #ffffffa1;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 4px 12px rgba(31, 38, 135, 0.08);
    display: block;
    width: 100%;
    height: auto;
}

.post-card:hover {
    border-color: #3498db;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.post-image-wrapper {
    padding: 8px 8px 0 8px;
    overflow: hidden;
    border-radius: 20px;
    position: relative;
}

.category-row-container:not([data-source-type="rss"]) .post-image-wrapper {
    aspect-ratio: 16/9;
    height: auto;
}

.category-row-container[data-source-type="rss"] .post-image-wrapper {
    padding: 8px 8px 0 8px;
    overflow: hidden;
    border-radius: 20px;
    width: 100%;
    aspect-ratio: 2.5;
    height: auto;
    flex-shrink: 0;
}

.post-image-link img {
    width: 100%;
    display: block;
    border-radius: 20px;
}

.category-row-container:not([data-source-type="rss"]) .post-image-link img {
    height: 100%;
    object-fit: cover;
}

.category-row-container[data-source-type="rss"] .post-image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 20px;
    background: #f8f9fa;
}

.post-content {
    padding: 14px;
    display: flex;
    flex-direction: column;
    height: auto;
}

.post-title {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    color: #000;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    height: auto;
}

.category-row-container[data-source-type="rss"] .post-title {
    min-height: 38px;
}

.post-title a {
    color: #2c3e50;
    text-decoration: none;
    font-weight: 500;
    display: initial;
}

.post-meta {
    color: #666;
    font-size: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.category-row-container[data-source-type="rss"] .post-meta {
    font-size: 11px;
}

.category-row-container[data-source-type="rss"] .post-author {
    display: block;
}

.post-date {
    color: #000;
    display: flex;
    align-items: center;
    gap: 4px;
}

.post-stats {
    display: flex;
    gap: 10px;
}

.post-stat {
    display: flex;
    align-items: center;
    gap: 3px;
    color: #000;
}

.post-stat:last-child {
    display: flex;
}

.icon-calendar {
    display: inline-block;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V10h14v10zM9 14H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm-8 4H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2z'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    vertical-align: middle;
}

.icon-eye {
    display: inline-block;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    vertical-align: middle;
}

.icon-comment {
    display: inline-block;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M21.99 4c0-1.1-.89-2-1.99-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14l4 4-.01-18zM18 14H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    vertical-align: middle;
}

.carousel-nav {
    display: flex;
    align-items: center;
    gap: 5px;
}

.carousel-nav button {
    background: white;
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 4px 12px rgba(31, 38, 135, 0.08);
    width: 32px;
    height: 32px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: #555;
    pointer-events: auto;
    position: relative;
}

.carousel-nav .prev-btn:before {
    content: '→';
    font-weight: bold;
}

.carousel-nav .next-btn:before {
    content: '←';
    font-weight: bold;
}

.carousel-nav button:hover:not(:disabled) {
    background: #3498db;
    color: white;
}

.carousel-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

@media only screen and (max-width: 768px) {
    .category-row-container {
        max-width: 100%;
        margin: 15px auto;
    }

    .posts-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding: 15px 10px !important;
    }

    .post-card {
        width: 100% !important;
        min-width: auto !important;
        height: auto !important;
        margin: 0 !important;
    }

    .section-header-wrapper {
        padding: 12px 15px;
    }

    .category-row-container .section-header {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .header-left {
        gap: 8px;
    }

    .section-title {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .desktop-tabs {
        display: none !important;
    }

    .mobile-tabs-dropdown {
        display: block;
        min-width: 110px;
    }

    .mobile-tabs-toggle {
        padding: 5px 10px;
        font-size: 12px;
        height: 30px;
    }

    .view-all-btn {
        padding: 5px 10px;
        font-size: 12px;
        height: 30px;
    }

    .post-title {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .post-meta {
        font-size: 11px;
        padding-top: 8px;
    }

    .post-content {
        padding: 10px;
    }

    .category-row-container[data-source-type="rss"] .post-image-link img {
        max-height: 110px !important;
    }

    .category-row-container[data-source-type="rss"] .post-author {
        display: none !important;
    }

    .category-row-container:not([data-source-type="rss"]) .post-stat:last-child {
        display: none !important;
    }

    .arrow-down {
        width: 7px;
        height: 7px;
    }

    .desktop-text {
        display: none;
    }

    .mobile-text {
        display: inline;
    }
}

@media only screen and (max-width: 399px) {
    .posts-grid {
        gap: 8px !important;
        padding: 10px 5px !important;
    }

    .section-title {
        font-size: 14px;
    }

    .mobile-tabs-dropdown {
        min-width: 90px;
    }

    .mobile-tabs-toggle {
        padding: 4px 8px;
        font-size: 11px;
        height: 28px;
    }

    .view-all-btn {
        padding: 4px 8px;
        font-size: 11px;
        height: 28px;
    }

    .post-title {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }

    .post-meta {
        font-size: 10px;
        padding-top: 6px;
    }

    .post-content {
        padding: 8px;
    }

    .post-image-wrapper {
        padding: 5px 5px 0 5px;
    }
}

.skeleton-card {
    background: #ffffffab;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 4px 12px rgba(31, 38, 135, 0.08);
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
}

.category-row-container:not([data-source-type="rss"]) .skeleton-image-wrapper {
    padding: 8px 8px 0 8px;
    overflow: hidden;
    border-radius: 20px;
    width: 100%;
    aspect-ratio: 16/9;
    flex-shrink: 0;
}

.category-row-container:not([data-source-type="rss"]) .skeleton-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 20px;
    animation: loading 1.5s infinite;
}

.category-row-container[data-source-type="rss"] .skeleton-image-wrapper {
    padding: 8px 8px 0 8px;
    overflow: hidden;
    border-radius: 20px;
    width: 100%;
    aspect-ratio: 2.5;
    height: auto;
    flex-shrink: 0;
}

.category-row-container[data-source-type="rss"] .skeleton-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 20px;
    animation: loading 1.5s infinite;
}

.skeleton-content {
    padding: 14px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 110px;
}

.skeleton-title {
    height: 14px;
    background: linear-gradient(90deg, #f5f5f5 25%, #e8e8e8 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    margin-bottom: 8px;
    border-radius: 4px;
    animation: loading 1.5s infinite;
}

.skeleton-title:first-child {
    width: 90%;
}

.skeleton-title:last-child {
    width: 70%;
    margin-bottom: 12px;
}

.skeleton-meta {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.skeleton-meta-left {
    width: 30%;
    height: 10px;
    background: linear-gradient(90deg, #f5f5f5 25%, #e8e8e8 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: loading 1.5s infinite;
}

.skeleton-meta-right {
    width: 40%;
    height: 10px;
    background: linear-gradient(90deg, #f5f5f5 25%, #e8e8e8 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: loading 1.5s infinite;
}

@media only screen and (max-width: 768px) {
    .skeleton-card {
        width: 100% !important;
        min-width: auto !important;
    }

    .skeleton-content {
        padding: 10px;
        min-height: 100px;
    }

    .skeleton-title {
        height: 12px;
        margin-bottom: 6px;
    }

    .skeleton-meta-left,
    .skeleton-meta-right {
        height: 8px;
    }

    .skeleton-meta {
        padding-top: 8px;
    }
}

@media only screen and (max-width: 399px) {
    .skeleton-content {
        padding: 8px;
        min-height: 90px;
    }

    .skeleton-title {
        height: 11px;
    }
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.arrow-down {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-left: 2px solid #495057;
    border-bottom: 2px solid #495057;
    transform: rotate(-45deg);
    transition: transform 0.3s;
    flex-shrink: 0;
}

.arrow-down.open {
    transform: rotate(135deg);
}

.desktop-text {
    display: inline;
}

.mobile-text {
    display: none;
}

body.page .section-header-wrapper {
    margin-top: 0px !important;
}