* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==================== متغیرهای تم ==================== */
:root {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #555555;
    --text-muted: #888888;
    --border-color: #eef2f6;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.1);
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --tag-bg: #f0f2f5;
    --input-bg: #f0f2f5;
    --footer-bg: #1a1a2e;
    --footer-text: #aaaaaa;
}

[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e2e;
    --bg-card: #1e1e2e;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --border-color: #2a2a3e;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.3);
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --tag-bg: #2a2a3e;
    --input-bg: #2a2a3e;
    --footer-bg: #0a0a15;
    --footer-text: #888888;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    direction: rtl;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ==================== هدر اصلی ==================== */
.main-header {
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background 0.3s ease;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

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

.logo-mark {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-radius: 8px;
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.logo-text span {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.search-area {
    flex: 1;
    max-width: 350px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input-bg);
    border-radius: 40px;
    padding: 10px 18px;
    transition: all 0.3s;
}

.search-input-wrapper:focus-within {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.search-input-wrapper svg {
    stroke: var(--text-muted);
    flex-shrink: 0;
}

.search-input-wrapper input {
    background: none;
    border: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    color: var(--text-primary);
}

.search-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.header-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--gradient-start);
}

/* ==================== آیکون سبد خرید ==================== */
.cart-icon-wrapper {
    position: relative;
    cursor: pointer;
    background: var(--tag-bg);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.cart-icon-wrapper:hover {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
}

.cart-icon-wrapper:hover svg {
    stroke: white;
}

.cart-icon-wrapper svg {
    stroke: var(--text-primary);
    transition: stroke 0.3s ease;
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f5576c;
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== دکمه تغییر تم ==================== */
.theme-toggle {
    background: var(--tag-bg);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.theme-toggle:hover {
    transform: rotate(15deg);
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
}

.theme-toggle svg {
    stroke: currentColor;
}

.login-btn {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    padding: 8px 20px;
    border-radius: 30px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-primary);
}

/* ==================== منوی موبایل ==================== */
.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 320px;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 200;
    transition: right 0.3s ease;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav-header .logo {
    font-size: 20px;
    font-weight: 800;
}

.close-mobile {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 15px;
}

.mobile-nav-links a {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 16px;
    padding: 10px;
    border-radius: 12px;
    transition: background 0.2s;
}

.mobile-nav-links a:hover,
.mobile-nav-links a.active {
    background: var(--tag-bg);
    color: var(--gradient-start);
}

.mobile-login-btn {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white !important;
    text-align: center;
    margin-top: 10px;
}

/* ==================== دسته‌بندی ==================== */
.categories-section {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.categories-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    padding: 0 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.category-pill {
    background: var(--tag-bg);
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    color: var(--text-secondary);
}

.category-pill:hover,
.category-pill.active {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
}

/* ==================== تگ‌ها ==================== */
.tags-section {
    background: var(--bg-secondary);
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
}

.tags-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.tags-title {
    font-size: 13px;
    color: var(--text-muted);
}

.tags-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tag {
    background: var(--tag-bg);
    border: none;
    padding: 6px 16px;
    border-radius: 25px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.tag:hover,
.tag.active {
    background: var(--gradient-start);
    color: white;
}

/* ==================== پیام‌های هشدار ==================== */
.alert {
    max-width: 1200px;
    margin: 20px auto;
    padding: 15px 20px;
    border-radius: 12px;
    text-align: center;
    font-size: 14px;
}

.alert-success {
    background: rgba(40, 167, 69, 0.15);
    border: 1px solid #28a745;
    color: #28a745;
}

.alert-error {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid #dc3545;
    color: #dc3545;
}

/* ==================== محتوای اصلی ==================== */
.main-content {
    padding: 40px 0 60px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

.section-title {
    text-align: center;
    margin-bottom: 40px;
}

.section-title h2 {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--gradient-start));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    margin-bottom: 10px;
}

.section-title p {
    color: var(--text-muted);
    font-size: 15px;
}

/* ==================== گرید سورس‌ها ==================== */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 28px;
}

/* ==================== کارت سورس ==================== */
.source-card {
    background: var(--bg-card);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.source-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.card-image {
    position: relative;
    height: 200px;
    background: linear-gradient(135deg, var(--tag-bg), var(--border-color));
    cursor: pointer;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.source-card:hover .card-image img {
    transform: scale(1.05);
}

.image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tag-bg);
}

.image-placeholder svg {
    stroke: var(--text-muted);
}

.card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

.card-body {
    padding: 18px;
    flex: 1;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
    line-height: 1.4;
}

.card-category {
    display: inline-block;
    background: var(--tag-bg);
    padding: 3px 12px;
    border-radius: 15px;
    font-size: 11px;
    color: var(--gradient-start);
    margin-bottom: 12px;
}

.card-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 12px;
}

.card-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.card-tag {
    background: var(--tag-bg);
    padding: 3px 12px;
    border-radius: 15px;
    font-size: 10px;
    color: var(--text-secondary);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 18px;
    border-top: 1px solid var(--border-color);
}

.price {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.price-amount {
    font-size: 18px;
    font-weight: 800;
    color: var(--gradient-start);
}

.price-unit {
    font-size: 11px;
    color: var(--text-muted);
}

.price-free {
    color: #28a745;
    font-weight: 700;
}

/* ==================== دکمه افزودن به سبد ==================== */
.add-to-cart-btn {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border: none;
    padding: 8px 16px;
    border-radius: 30px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.add-to-cart-btn:hover {
    transform: scale(0.97);
}

/* ==================== مودال سبد خرید ==================== */
.cart-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 400;
    display: none;
    align-items: center;
    justify-content: center;
}

.cart-modal.active {
    display: flex;
}

.cart-modal-content {
    background: var(--bg-secondary);
    border-radius: 28px;
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
}

.cart-modal-header h3 {
    color: var(--text-primary);
}

.cart-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}

.cart-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-item-info strong {
    font-size: 14px;
    color: var(--text-primary);
}

.cart-item-info span {
    font-size: 12px;
    color: var(--gradient-start);
    font-weight: 600;
}

.cart-remove {
    background: rgba(245, 87, 108, 0.15);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    color: #f5576c;
    transition: all 0.2s;
}

.cart-remove:hover {
    background: #f5576c;
    color: white;
}

.cart-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.cart-modal-footer {
    padding: 18px 22px;
    border-top: 1px solid var(--border-color);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.cart-total strong {
    font-size: 22px;
    color: var(--gradient-start);
}

.checkout-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border: none;
    border-radius: 30px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

/* ==================== مودال جزئیات سورس ==================== */
.detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
}

.detail-modal.active {
    display: flex;
}

.detail-modal-content {
    background: var(--bg-secondary);
    border-radius: 28px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    direction: rtl;
}

.detail-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

.detail-modal-header h3 {
    color: var(--text-primary);
}

.detail-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}

.detail-modal-body {
    padding: 22px;
    text-align: center;
}

.detail-image {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
}

.detail-image img {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    object-fit: cover;
}

.detail-image-placeholder {
    width: 100%;
    height: 100%;
    background: var(--tag-bg);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-title {
    font-size: 22px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.detail-category {
    color: var(--gradient-start);
    font-size: 13px;
    margin-bottom: 20px;
}

.detail-description {
    background: var(--tag-bg);
    padding: 16px;
    border-radius: 16px;
    text-align: right;
    line-height: 1.65;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.detail-tags-section {
    margin-bottom: 20px;
}

.detail-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.detail-tag {
    background: var(--tag-bg);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.detail-demo-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--gradient-start);
    padding: 10px 24px;
    border-radius: 40px;
    color: var(--gradient-start);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 20px;
    transition: all 0.2s;
}

.detail-demo-link:hover {
    background: var(--gradient-start);
    color: white;
}

.detail-price {
    background: var(--tag-bg);
    padding: 14px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.detail-price strong {
    font-size: 20px;
    color: var(--gradient-start);
}

.detail-buy {
    width: 100%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border: none;
    padding: 14px;
    border-radius: 40px;
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.detail-buy:hover {
    transform: scale(0.98);
}

/* ==================== فوتر ==================== */
.main-footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 50px 0 20px;
    transition: background 0.3s ease;
}

.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

.footer-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-logo {
    font-size: 22px;
    font-weight: 800;
    color: white;
    margin-bottom: 15px;
}

.footer-logo span {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.footer-col p {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.footer-contact {
    color: var(--gradient-start);
}

.footer-col h4 {
    color: white;
    font-size: 16px;
    margin-bottom: 18px;
}

.footer-col ul {
    list-style: none;
}

.footer-col ul li {
    margin-bottom: 10px;
}

.footer-col ul li a {
    color: var(--footer-text);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
}

.footer-col ul li a:hover {
    color: var(--gradient-start);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    grid-column: 1 / -1;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
}

/* ==================== ریسپانسیو ==================== */
@media (max-width: 992px) {
    .header-links {
        display: none;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .search-area {
        order: 3;
        width: 100%;
        max-width: none;
    }
    
    .sources-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .header-inner {
        padding: 12px 16px;
    }
    
    .container {
        padding: 0 16px;
    }
    
    .section-title h2 {
        font-size: 26px;
    }
    
    .sources-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-columns {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
    
    .cart-modal-content {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .footer-columns {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .card-footer {
        flex-direction: column;
        gap: 12px;
    }
    
    .add-to-cart-btn {
        width: 100%;
        justify-content: center;
    }
    
    .price {
        justify-content: center;
    }
    
    .categories-wrapper {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
    }
    
    .detail-modal-content {
        width: 95%;
    }
}