/**
 * Category Page Styles
 * @package Kora_Plus_Pro
 */

.category-page {
    padding: 40px 0;
}

/* === عنوان القسم === */
.category-header {
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    padding: 40px;
    border-radius: 15px;
    border-right: 6px solid var(--primary, #00A859);
    box-shadow: 0 5px 25px rgba(0,0,0,0.08);
    margin-bottom: 40px;
}

.category-title-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
}

.category-title {
    font-size: 28px;
    font-weight: 900;
    color: #1a1a1a;
    margin: 0;
}

.category-count {
    background: var(--primary, #00A859);
    color: #fff;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 700;
}

.category-description {
    color: #666;
    font-size: 16px;
    line-height: 1.8;
}

.category-description p {
    margin: 0;
}

/* === الأقسام ذات الصلة === */
.related-categories {
    margin-bottom: 35px;
}

.related-title {
    font-size: 22px;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--primary, #00A859);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.3s;
}

.category-item:hover,
.category-item.active {
    background: var(--primary, #00A859);
    border-color: var(--primary, #00A859);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,168,89,0.3);
}

.category-item .cat-name {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
}

.category-item:hover .cat-name,
.category-item.active .cat-name {
    color: #fff;
}

.category-item .cat-count {
    background: #f8f9fa;
    color: #666;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 700;
}

.category-item:hover .cat-count,
.category-item.active .cat-count {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* === المقالات === */
.category-posts {
    display: grid;
    gap: 25px;
    margin-bottom: 40px;
}

.category-posts.posts-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

.category-posts.posts-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.category-posts.posts-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

.category-post-item {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: all 0.3s;
    position: relative;
}

.category-post-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,168,89,0.15);
}

/* صورة المقال */
.post-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: rgba(230, 230, 230, 0.3);
    border-radius: 10px 10px 0 0;
}

.post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.category-post-item:hover .post-thumb img {
    transform: none;
}

.post-cat {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary, #00A859);
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(0,168,89,0.6);
    z-index: 5;
}

.post-cat a {
    color: #fff;
    text-decoration: none;
}

.post-date-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(26, 26, 26, 0.9);
    color: #fff;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    backdrop-filter: blur(10px);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 5px;
}

.post-date-badge::before {
    content: '🕒';
    font-size: 14px;
}

/* محتوى المقال */
.post-content-wrap {
    padding: 20px;
    background: #fff;
}

.post-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.6;
    margin: 0 0 10px;
    min-height: 48px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-title a {
    color: #1a1a1a;
    text-decoration: none;
    transition: color 0.3s;
}

.post-title a:hover {
    color: var(--primary, #00A859);
}

.post-meta-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
    font-size: 12px;
    color: #999;
}

.post-meta-info svg {
    width: 14px;
    height: 14px;
    color: var(--primary, #00A859);
}

.post-excerpt {
    color: #666;
    font-size: 14px;
    line-height: 1.7;
    margin-top: 12px;
}

.post-meta-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #f8f9fa;
    font-size: 13px;
    color: #999;
    font-weight: 600;
}

/* === الأنماط المختلفة === */

/* Style 2 - مع مقتطف */
.category-posts.style2 .post-thumb {
    height: 220px;
}

.category-posts.style2 .post-title {
    font-size: 17px;
}

/* Style 3 - مع معلومات إضافية */
.category-posts.style3 .post-thumb {
    height: 200px;
}

.category-posts.style3 .post-title {
    font-size: 16px;
}

.category-posts.style3 .post-content-wrap {
    padding: 18px;
}

/* === الترقيم التقليدي === */
.pagination-wrapper {
    margin: 40px 0;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.08);
}

.pagination-wrapper .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 10px;
    flex-wrap: wrap;
}

.pagination-wrapper .page-numbers li {
    display: inline-block;
    margin: 0;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    height: 50px;
    padding: 0 18px;
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    border: 3px solid #e9ecef;
    border-radius: 10px;
    color: #666;
    font-weight: 800;
    font-size: 16px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    cursor: pointer;
}

.pagination .page-numbers:hover {
    background: linear-gradient(135deg, var(--primary, #00A859), #00c46e);
    border-color: var(--primary, #00A859);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,168,89,0.3);
}

.pagination .page-numbers.current {
    background: linear-gradient(135deg, var(--primary, #00A859), #00c46e);
    border-color: var(--primary, #00A859);
    color: #fff;
    box-shadow: 0 5px 15px rgba(0,168,89,0.4);
}

.pagination .prev,
.pagination .next {
    font-size: 22px;
    min-width: 60px;
    background: linear-gradient(135deg, #1a1a1a, #2c2c2c);
    border-color: #1a1a1a;
    color: #fff;
}

.pagination .prev:hover,
.pagination .next:hover {
    background: linear-gradient(135deg, var(--accent, #ff6b00), #ff8533);
    border-color: var(--accent, #ff6b00);
}

.pagination .dots {
    min-width: 40px;
    cursor: default;
    pointer-events: none;
    opacity: 0.5;
}

@media (max-width: 576px) {
    .pagination .page-numbers {
        min-width: 45px;
        height: 45px;
        font-size: 14px;
    }
    
    .pagination .prev,
    .pagination .next {
        min-width: 55px;
    }
}

/* === زر تحميل المزيد - نسخة محدثة === */
.load-more-wrapper {
    margin: 40px 0;
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.08);
}

.load-more-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 18px 45px;
    background: linear-gradient(135deg, var(--primary, #00A859), #00c46e);
    border: none;
    border-radius: 50px;
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 0 8px 25px rgba(0,168,89,0.4);
    overflow: hidden;
}

.load-more-btn svg {
    flex-shrink: 0;
}

.load-more-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.load-more-btn:hover::before {
    width: 300px;
    height: 300px;
}

.load-more-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0,168,89,0.5);
}

.load-more-btn:active {
    transform: translateY(0);
}

.load-more-btn:disabled {
    background: linear-gradient(135deg, #95a5a6, #b0bec5);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.8;
}

.load-more-btn:disabled:hover {
    transform: none;
}

/* Loading Animation */
.btn-loading {
    display: inline-flex;
    gap: 5px;
    margin-left: 8px;
}

.btn-loading span {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: loading-bounce 1.4s infinite ease-in-out both;
}

.btn-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.btn-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* === Infinite Scroll - نسخة محدثة === */
.infinite-scroll-trigger {
    height: 1px;
    visibility: hidden;
}

.infinite-scroll-loader {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary, #00A859);
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: 15px;
    margin: 30px 0;
}

.loader-spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0,168,89,0.2);
    border-top-color: var(--primary, #00A859);
    border-radius: 50%;
    animation: spinner-rotate 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}

.scroll-end {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 25px;
    background: linear-gradient(135deg, #e9ecef, #f8f9fa);
    border-radius: 12px;
    color: #666;
    font-weight: 600;
}

.scroll-end svg {
    color: var(--primary, #00A859);
}

/* === لا توجد مقالات === */
.no-posts {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 15px;
}

.no-posts p {
    font-size: 18px;
    color: #999;
    margin: 0;
}

/* === Responsive === */
@media (max-width: 992px) {
    .category-posts.posts-row-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .category-header {
        padding: 25px;
    }
    
    .category-title-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .category-title {
        font-size: 26px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-posts.posts-row-3,
    .category-posts.posts-row-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .post-thumb {
        height: 180px;
    }
}

@media (max-width: 576px) {
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .category-posts.posts-row-2,
    .category-posts.posts-row-3,
    .category-posts.posts-row-4 {
        grid-template-columns: 1fr;
    }
    
    .post-thumb {
        height: 220px;
    }
}

/* === Dark Mode === */
body.dark-mode .category-post-item {
    background: #1e1e1e;
    border-color: #333;
}

body.dark-mode .post-content-wrap {
    background: #1e1e1e;
}

body.dark-mode .post-title a {
    color: #e0e0e0;
}

body.dark-mode .post-title a:hover {
    color: var(--primary, #00A859);
}

body.dark-mode .post-meta-info {
    border-color: #333;
    color: #888;
}

body.dark-mode .post-date-badge {
    background: rgba(255,255,255,0.1);
}

/* ========================================
   تخطيطات الموبايل - Mobile Layouts
   ======================================== */
@media (max-width: 768px) {
    /* ========================================
       الإعداد الافتراضي: عمودين (2 مقالات في الصف)
       Default: Two Columns Layout for Categories
       ======================================== */
    .category-posts,
    body.category .category-posts,
    body.archive .category-posts,
    body.search .category-posts,
    body.tax .category-posts {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    /* ========================================
       استثناء: الصفحة الرئيسية تبقى عمود واحد
       Exception: Home page stays single column
       ======================================== */
    body.home .category-posts,
    body.home .posts-grid,
    body.front-page .category-posts,
    body.front-page .posts-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    /* Reset default styles for mobile */
    .category-post-item {
        min-height: unset;
    }
    
    .post-thumb {
        aspect-ratio: 16 / 9;
        overflow: hidden;
        position: relative;
    }
    
    .post-thumb img {
        display: block;
    }
    
    /* Style 1: Full Width */
    body.mobile-layout-style1 .category-posts {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    body.mobile-layout-style1 .category-post-item {
        display: flex;
        flex-direction: column;
        background: #fff;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border: 1px solid #e0e0e0;
    }
    
    body.mobile-layout-style1 .post-thumb {
        width: 100%;
        height: auto;
        min-height: 200px;
        max-height: 250px;
        aspect-ratio: 16 / 9;
        background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
    }
    
    body.mobile-layout-style1 .post-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    body.mobile-layout-style1 .post-date-badge {
        position: absolute;
        top: 10px;
        left: 10px;
        background: rgba(0,0,0,0.9);
        color: #fff;
        padding: 8px 15px;
        border-radius: 8px;
        font-size: 12px;
        font-weight: 700;
        z-index: 5;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    
    body.mobile-layout-style1 .post-content-wrap {
        padding: 15px 20px;
        background: #fff;
    }
    
    body.mobile-layout-style1 .post-title {
        font-size: 17px;
        line-height: 1.6;
        margin-bottom: 0;
        font-weight: 700;
        color: #1a1a1a;
    }
    
    body.mobile-layout-style1 .post-cat {
        top: 10px;
        right: 10px;
        font-size: 11px;
        padding: 6px 12px;
    }
    
    /* Style 2: Horizontal (Image + Title Side by Side) */
    body.mobile-layout-style2 .category-posts {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    body.mobile-layout-style2 .category-post-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch;
        min-height: 120px;
        background: #fff;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border: 1px solid #e0e0e0;
    }
    
    body.mobile-layout-style2 .post-thumb {
        width: 140px !important;
        height: 120px !important;
        min-height: 120px;
        max-height: 120px;
        flex-shrink: 0;
        border-radius: 12px 0 0 12px !important;
        background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
        position: relative;
        overflow: hidden;
    }
    
    body.mobile-layout-style2 .post-thumb img {
        border-radius: 12px 0 0 12px !important;
        width: 100%;
        height: 100%;
        object-fit: cover !important;
    }
    
    body.mobile-layout-style2 .post-content-wrap {
        flex: 1;
        padding: 15px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        background: #fff;
    }
    
    body.mobile-layout-style2 .post-title {
        font-size: 15px !important;
        line-height: 1.5 !important;
        margin: 0 0 auto;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-weight: 700;
        color: #1a1a1a;
        flex: 1;
    }
    
    body.mobile-layout-style2 .post-date-badge {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        background: transparent !important;
        color: #999;
        padding: 0;
        font-size: 12px;
        font-weight: 600;
        margin-top: 8px;
        display: block;
        box-shadow: none;
    }
    
    body.mobile-layout-style2 .post-date-badge::before {
        content: '';
        display: none;
    }
    
    body.mobile-layout-style2 .post-cat {
        display: none !important;
    }
    
    /* Style 3: Two Columns */
    body.mobile-layout-style3 .category-posts {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
    
    body.mobile-layout-style3 .category-post-item {
        display: flex !important;
        flex-direction: column !important;
        background: #fff;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border: 1px solid #e0e0e0;
    }
    
    body.mobile-layout-style3 .post-thumb {
        width: 100% !important;
        height: 140px !important;
        min-height: 140px;
        max-height: 140px;
        aspect-ratio: 16 / 9;
        background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
        position: relative;
        overflow: hidden;
    }
    
    body.mobile-layout-style3 .post-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover !important;
    }
    
    body.mobile-layout-style3 .post-date-badge {
        position: absolute;
        top: 8px;
        left: 8px;
        background: rgba(0,0,0,0.9);
        color: #fff;
        padding: 5px 10px;
        border-radius: 6px;
        font-size: 10px;
        font-weight: 700;
        z-index: 5;
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    }
    
    body.mobile-layout-style3 .post-content-wrap {
        padding: 12px;
        background: #fff;
    }
    
    body.mobile-layout-style3 .post-title {
        font-size: 13px !important;
        line-height: 1.5 !important;
        margin-bottom: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-weight: 700;
        color: #1a1a1a;
        min-height: 40px;
    }
    
    body.mobile-layout-style3 .post-cat {
        font-size: 9px;
        padding: 4px 8px;
        top: 8px;
        right: 8px;
    }
}

