/*
 * ═══════════════════════════════════════════════════════
 * CATEGORIES INDEX PAGE — Extracted CSS
 * ✅ FIX: إزالة * { direction: rtl } من الـ <style> tag
 *         واستبدالها بـ [dir="rtl"] selectors آمنة
 * ✅ FIX: تصحيح sidebar translateX للـ RTL
 * ═══════════════════════════════════════════════════════
 */

/* ── CSS Variables ── */
:root {
    --cat-primary: #E8541A;
    --cat-accent:  #C94315;
    --cat-border:  #e0e0e0;
    --cat-hover:   #fff5f1;
}

/* ── Hero Section ── */
.hero-section {
    background: linear-gradient(135deg, #E8541A 0%, #C94315 100%);
    color: white;
    padding: 60px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
}

.hero-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255,255,255,0.08) 0%, transparent 50%);
    animation: bgMove 15s ease-in-out infinite;
}

@keyframes bgMove {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25%  { transform: translate(-20px, 20px) scale(1.05); }
    50%  { transform: translate(20px, -20px) scale(0.95); }
    75%  { transform: translate(-20px, -20px) scale(1.02); }
}

.floating-icons {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.floating-icon {
    position: absolute;
    font-size: 2rem;
    opacity: 0.15;
    animation: float 6s ease-in-out infinite;
}

.floating-icon:nth-child(1) { top: 10%; left: 10%; animation-delay: 0s; }
.floating-icon:nth-child(2) { top: 20%; right: 15%; animation-delay: 1s; }
.floating-icon:nth-child(3) { bottom: 15%; left: 15%; animation-delay: 2s; }
.floating-icon:nth-child(4) { bottom: 20%; right: 10%; animation-delay: 3s; }
.floating-icon:nth-child(5) { top: 50%; left: 5%; animation-delay: 1.5s; }
.floating-icon:nth-child(6) { top: 50%; right: 5%; animation-delay: 2.5s; }

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25%  { transform: translateY(-20px) rotate(5deg); }
    50%  { transform: translateY(-40px) rotate(-5deg); }
    75%  { transform: translateY(-20px) rotate(3deg); }
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: bold;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    animation: fadeInDown 0.8s ease-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hero-title .store-icon {
    font-size: 3rem;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}

.hero-subtitle {
    font-size: 1.3rem;
    margin-bottom: 35px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* ── Search Bar ── */
.hero-search {
    max-width: 800px;
    margin: 0 auto 35px;
    display: flex;
    background: white;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.hero-search input {
    flex: 1;
    padding: 18px 30px;
    border: none;
    font-size: 1.05rem;
    outline: none;
    direction: rtl;
    text-align: right;
}

.hero-search input::placeholder { color: #999; }

.hero-search .search-btn {
    padding: 18px 40px;
    background: linear-gradient(135deg, #E8541A 0%, #C94315 100%);
    color: white;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hero-search .search-btn:hover {
    background: linear-gradient(135deg, #C94315 0%, #A83610 100%);
    transform: scale(1.02);
}

/* ── Stats Cards ── */
.hero-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-card {
    background: rgba(0,0,0,0.20);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px 35px;
    min-width: 180px;
    border: 1px solid rgba(255,255,255,0.3);
    transition: all 0.3s;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.stat-card:hover {
    background: rgba(0,0,0,0.30);
    transform: translateY(-5px);
}

.stat-icon   { font-size: 2.2rem; margin-bottom: 8px; line-height: 1; display: block; }
.stat-number { font-size: 2.2rem; font-weight: bold; margin-bottom: 8px; color: #ffffff; }
.stat-label  { font-size: 0.95rem; color: rgba(255,255,255,0.9); }

/* ── Main Layout ── */
.categories-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    padding: 0 15px;
    margin-bottom: 60px;
}

/* ── Sidebar ── */
.sidebar {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.filter-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.filter-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-section {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--cat-border);
}

.filter-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.filter-section-title {
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
    font-size: 1.05rem;
}

.filter-option {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 8px;
}

.filter-option:hover { background: var(--cat-hover); }

.filter-option input[type="radio"],
.filter-option input[type="checkbox"] {
    margin-inline-start: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--cat-primary);
}

.filter-option-label {
    flex: 1;
    cursor: pointer;
    font-size: 0.95rem;
}

.filter-option-count {
    color: #999;
    font-size: 0.85rem;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 10px;
}

.btn-clear-filters {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: #f44336;
    border: 1px solid #f44336;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-clear-filters:hover {
    background: #f44336;
    color: white;
}

/* ── Categories Area ── */
.categories-area { min-height: 600px; }

.categories-header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.categories-info h1 {
    font-size: 1.8rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.categories-count { color: #666; font-size: 0.95rem; }

.categories-sort {
    display: flex;
    align-items: center;
    gap: 10px;
}

.categories-sort label {
    font-size: 0.95rem;
    color: #666;
    white-space: nowrap;
}

.categories-sort select {
    padding: 10px 15px;
    border: 1px solid var(--cat-border);
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    background: white;
    min-width: 200px;
    transition: border-color 0.3s;
}

.categories-sort select:focus {
    outline: none;
    border-color: var(--cat-primary);
}

/* ── Active Filters ── */
.active-filters {
    background: #f0f7ff;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.active-filter-tag {
    background: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.active-filter-tag button {
    background: none;
    border: none;
    color: #f44336;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
}

/* ── Categories Grid ── */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.category-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    position: relative;
}

.category-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.category-image-container {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #E8541A 0%, #C94315 100%);
}

.category-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.category-card:hover .category-image { transform: scale(1.1); }

.category-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,0.4));
    display: flex;
    align-items: flex-end;
    padding: 20px;
}

.category-badge {
    background: white;
    color: var(--cat-primary);
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.category-content {
    padding: 25px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.category-name {
    font-size: 1.4rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.category-description {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 15px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.category-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.category-count {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--cat-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.category-arrow {
    color: var(--cat-primary);
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

/* RTL-safe arrow animation */
[dir="rtl"] .category-card:hover .category-arrow { transform: translateX(-5px); }
[dir="ltr"] .category-card:hover .category-arrow { transform: translateX(5px); }

/* ── Sub-categories ── */
.subcategories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.subcategory-tag {
    background: #f0f7ff;
    color: var(--cat-primary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.subcategory-tag:hover {
    background: var(--cat-primary);
    color: white;
}

/* ── Empty State ── */
.no-categories {
    text-align: center;
    padding: 80px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.no-categories-icon { font-size: 5rem; margin-bottom: 20px; }
.no-categories h3 { font-size: 1.8rem; font-weight: bold; color: #333; margin-bottom: 10px; }
.no-categories p  { color: #666; font-size: 1.1rem; }

/* ── AdSense ── */
.adsense-sidebar {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.adsense-label {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 10px;
    text-transform: uppercase;
}

/* ── Mobile Filter Toggle ── */
.mobile-filter-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #E8541A;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .categories-layout { grid-template-columns: 1fr; }

    .sidebar {
        display: none;
        position: fixed;
        top: 0;
        /* ✅ FIX RTL: استخدام inset-inline-end بدل right لدعم RTL/LTR */
        inset-inline-end: 0;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        background: white;
        z-index: 1000;
        overflow-y: auto;
        padding: 20px;
        box-shadow: -4px 0 15px rgba(0,0,0,0.2);
        /* ✅ FIX: translateX(100%) كانت تتحرك جهة غلط في RTL */
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    /* RTL: السايدبار يجي من اليمين → translateX(100%) صح */
    /* LTR: السايدبار يجي من اليسار → translateX(-100%) */
    [dir="ltr"] .sidebar { transform: translateX(-100%); }

    .sidebar.active { display: block; transform: translateX(0); }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .sidebar-overlay.active { display: block; }

    .mobile-filter-toggle { display: block; }

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

@media (max-width: 768px) {
    .hero-title    { font-size: 2.5rem; }
    .hero-subtitle { font-size: 1.1rem; }

    .hero-search input     { padding: 15px 20px; font-size: 0.95rem; }
    .hero-search .search-btn { padding: 15px 25px; font-size: 1rem; }

    .stat-card   { min-width: 140px; padding: 15px 25px; }
    .stat-number { font-size: 1.8rem; }
    .stat-label  { font-size: 0.85rem; }

    .categories-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .categories-sort { width: 100%; }
    .categories-sort select { flex: 1; }
}

@media (max-width: 480px) {
    .categories-grid { grid-template-columns: 1fr; }
}
