/* =====================================================
   Profile Page - Full Stylesheet
   - RTL/LTR Logical Properties
   - CSS Variables (var(--...))
   - Responsive & Accessible
   ===================================================== */

/* ===== Profile Header ===== */
.profile-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    /* [CHANGED] از clamp به جای مقادیر ثابت برای padding */
    padding: clamp(30px, 6vw, 60px) clamp(20px, 4vw, 40px);
    border-radius: var(--radius-lg);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* [CHANGED] حذف left/right ثابت، استفاده از inset-inline */
.profile-header::before {
    content: '';
    position: absolute;
    inset: 0; /* [CHANGED] جایگزین top/right/bottom/left: 0 */
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" opacity="0.1"><rect x="10" y="10" width="80" height="80" fill="none" stroke="white" stroke-width="2"/><circle cx="50" cy="50" r="20" fill="none" stroke="white" stroke-width="2"/></svg>') repeat;
    /* [CHANGED] نام انیمیشن اختصاصی برای جلوگیری از تداخل */
    animation: profileRotate 40s linear infinite;
    pointer-events: none; /* [NEW] جلوگیری از بلوک کردن کلیک */
}

/* [CHANGED] نام اختصاصی برای انیمیشن rotate */
@keyframes profileRotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.profile-content {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

.avatar-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    flex-shrink: 0;
}

.avatar-wrapper img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: profileFadeInDown 0.8s ease both;
    /* [NEW] font-family به ارث رسیده */
    font-family: inherit;
}

/* [CHANGED] از inset-inline-end/bottom به جای right/bottom */
.verified-badge {
    position: absolute;
    bottom: 5px;
    /* [CHANGED] inset-inline-end برای RTL/LTR هوشمند */
    inset-inline-end: 5px;
    width: 34px;
    height: 34px;
    /* [CHANGED] از var(--primary) به جای هاردکد #3b82f6 */
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* [CHANGED] از var(--white) به جای white */
    border: 3px solid var(--white);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
    /* [NEW] انتقال نرم برای hover احتمالی */
    transition: transform 0.2s ease;
}

.verified-badge:hover {
    transform: scale(1.1); /* [NEW] */
}

.verified-badge svg {
    width: 18px;
    height: 18px;
}

.profile-info {
    flex: 1;
    animation: profileFadeInUp 0.8s ease 0.2s both;
    /* [NEW] حداقل عرض برای جلوگیری از له شدن */
    min-width: 200px;
}

.profile-info h1 {
    font-size: clamp(1.6rem, 3vw, 2.2rem); /* [CHANGED] clamp */
    font-weight: 700;
    margin-bottom: 5px;
    font-family: inherit; /* [NEW] */
    line-height: 1.3;
}

.profile-username {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 15px;
    /* [NEW] dir-independent برای نمایش یوزرنیم */
    direction: ltr;
    text-align: start; /* [CHANGED] */
}

/* ===== Stats ===== */
.stats {
    display: flex;
    gap: 30px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.15);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px); /* [NEW] Safari */
    min-width: 100px;
    transition: transform 0.3s ease, background 0.3s ease; /* [CHANGED] */
}

.stat-item:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.25); /* [CHANGED] کمی بیشتر */
}

.stat-item strong {
    font-size: clamp(1.4rem, 2.5vw, 1.8rem); /* [CHANGED] clamp */
    font-weight: 800;
    display: block;
    line-height: 1.2;
}

.stat-item span {
    font-size: 0.9rem;
    opacity: 0.9;
}

.stat-link {
    color: var(--white); /* [CHANGED] */
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease; /* [CHANGED] */
}

.stat-link:hover {
    text-decoration: underline;
    opacity: 1;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
    animation: profileFadeInUp 0.8s ease 0.3s both;
}

/* [NOTE] کلاس .btn اصلی سایت حفظ شده،
   کلاس‌های اختصاصی برای جلوگیری از override */
.profile-btn {
    padding: 12px 30px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 1rem;
    font-family: inherit; /* [NEW] */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: none;
    text-decoration: none;
    display: inline-flex; /* [CHANGED] inline-flex برای آیکون */
    align-items: center;
    gap: 8px; /* [NEW] فاصله آیکون و متن */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    white-space: nowrap; /* [NEW] */
}

.profile-btn-follow {
    background: var(--white);
    color: var(--primary);
}

.profile-btn-follow:hover {
    background: var(--primary-light);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.3);
    color: var(--primary);
}

.profile-btn-unfollow {
    /* [CHANGED] از متغیر CSS به جای هاردکد */
    background: var(--gray-light, #9ca3af);
    color: var(--white);
}

.profile-btn-unfollow:hover {
    background: var(--gray, #6b7280);
    transform: translateY(-3px);
    color: var(--white);
}

.profile-btn-message {
    background: var(--white);
    color: var(--primary);
}

.profile-btn-message:hover {
    background: var(--primary-light);
    transform: translateY(-3px);
    color: var(--primary);
}

/* [CHANGED] از var(--secondary) به جای هاردکد */
.profile-btn-contact {
    background: var(--secondary);
    color: var(--white);
}

.profile-btn-contact:hover {
    /* [CHANGED] از var(--secondary-dark) اگر موجود باشد */
    background: var(--secondary-dark, #0e9f6e);
    transform: translateY(-3px);
    color: var(--white);
}

.profile-btn-edit {
    background: var(--white);
    color: var(--primary);
}

.profile-btn-edit:hover {
    background: var(--primary-light);
    transform: translateY(-3px);
    color: var(--primary);
}

/* ===== Bio Section ===== */
.bio-section {
    background: var(--white); /* [CHANGED] */
    border-radius: var(--radius-lg);
    padding: clamp(20px, 3vw, 30px); /* [CHANGED] clamp */
    margin: 30px 0;
    box-shadow: var(--shadow-sm);
}

.bio-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--dark);
    border-bottom: 3px solid var(--primary-light);
    padding-bottom: 10px;
    position: relative;
    font-family: inherit; /* [NEW] */
}

/* [CHANGED] از inset-inline-end به جای right (RTL/LTR هوشمند) */
.bio-section h2::after {
    content: '';
    position: absolute;
    bottom: -3px;
    inset-inline-end: 0; /* [CHANGED] */
    width: 80px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

.bio-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--gray);
    font-family: inherit; /* [NEW] */
}

.category-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 15px;
    font-family: inherit; /* [NEW] */
}

/* =====================================================
   استایل‌های سیستم تبلیغات (بنر و کارت‌ها)
   ===================================================== */
.ad-banner {
    /* [CHANGED] از var(--warning-light) یا fallback */
    background: linear-gradient(135deg,
        var(--warning-light, #fffbeb) 0%,
        var(--warning-lighter, #fef3c7) 100%
    );
    /* [CHANGED] از var(--warning-border) یا fallback */
    border: 1px solid var(--warning-border, #fde68a);
    border-radius: var(--radius-lg);
    padding: 20px 25px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    flex-wrap: wrap;
}

/* [CHANGED] از inset-inline-end به جای right */
.ad-badge {
    position: absolute;
    top: 0;
    inset-inline-end: 25px; /* [CHANGED] RTL/LTR هوشمند */
    background: var(--warning);
    color: var(--white);
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 700; /* [CHANGED] bold → 700 */
    border-radius: 0 0 8px 8px;
    font-family: inherit; /* [NEW] */
}

.ad-content {
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1;
}

.ad-icon {
    font-size: 2.5rem;
    line-height: 1; /* [NEW] */
}

.ad-text h4 {
    /* [CHANGED] از var(--warning-dark) یا fallback */
    color: var(--warning-dark, #92400e);
    margin-bottom: 5px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: inherit; /* [NEW] */
}

.ad-text p {
    /* [CHANGED] از var یا fallback */
    color: var(--warning-text, #b45309);
    font-size: 0.95rem;
    margin: 0;
}

.ad-button {
    background: var(--warning);
    color: var(--white);
    padding: 10px 24px;
    border-radius: var(--radius-full);
    text-decoration: none;
    font-weight: 600;
    font-family: inherit; /* [NEW] */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* [CHANGED] */
    z-index: 1;
    white-space: nowrap;
    display: inline-flex; /* [NEW] */
    align-items: center;
}

.ad-button:hover {
    background: var(--warning-dark, #d97706);
    transform: translateY(-2px);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.3);
}

/* ریبون کارت تبلیغاتی */
/* [CHANGED] از inset-inline-end به جای right */
.ad-ribbon {
    position: absolute;
    top: 15px;
    /* [CHANGED] RTL: inset-inline-end، برای چرخش صحیح */
    inset-inline-end: -35px; /* [CHANGED] */
    color: var(--white);
    padding: 5px 40px;
    font-size: 0.8rem;
    font-weight: 700;
    /* [CHANGED] rotate بر اساس جهت متن */
    transform: rotate(45deg);
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    text-align: center;
    font-family: inherit;
}

/* [NOTE] در RTL زاویه ریبون باید معکوس شود */
[dir="rtl"] .ad-ribbon {
    transform: rotate(-45deg); /* [NEW] */
    inset-inline-end: -35px;
    inset-inline-start: auto;
}

/* استایل پلن‌های مختلف */
/* [CHANGED] از var(--primary) به جای هاردکد #3b82f6 */
.ad-ladder {
    border: 2px solid var(--primary) !important;
    box-shadow: 0 0 15px rgba(var(--primary-rgb, 59, 130, 246), 0.15) !important;
}
.ad-ladder .ad-ribbon { background: var(--primary); }

/* [CHANGED] از var(--secondary) به جای هاردکد */
.ad-clicks {
    border: 2px solid var(--secondary) !important;
    box-shadow: 0 0 15px rgba(var(--secondary-rgb, 16, 185, 129), 0.15) !important;
}
.ad-clicks .ad-ribbon { background: var(--secondary); }

/* [CHANGED] از var(--warning) به جای هاردکد */
.ad-vip {
    border: 2px solid var(--warning) !important;
    box-shadow: 0 0 20px rgba(var(--warning-rgb, 245, 158, 11), 0.25) !important;
    position: relative;
}

.ad-vip::before {
    content: '';
    position: absolute;
    inset: 0; /* [CHANGED] */
    box-shadow: inset 0 0 20px rgba(var(--warning-rgb, 245, 158, 11), 0.1);
    pointer-events: none;
    z-index: 1;
}

.ad-vip .ad-ribbon { background: var(--warning); }

/* ===== Products Grid ===== */
.products-section {
    background: var(--white); /* [CHANGED] */
    border-radius: var(--radius-lg);
    padding: clamp(20px, 3vw, 30px); /* [CHANGED] clamp */
    margin: 30px 0;
    box-shadow: var(--shadow-sm);
}

.products-section h2 {
    font-size: clamp(1.4rem, 2.5vw, 1.8rem); /* [CHANGED] clamp */
    font-weight: 700;
    margin-bottom: 30px;
    color: var(--dark);
    border-bottom: 3px solid var(--primary-light);
    padding-bottom: 10px;
    position: relative;
    font-family: inherit; /* [NEW] */
}

/* [CHANGED] از inset-inline-end به جای right */
.products-section h2::after {
    content: '';
    position: absolute;
    bottom: -3px;
    inset-inline-end: 0; /* [CHANGED] RTL/LTR هوشمند */
    width: 80px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.product-card {
    background: var(--white); /* [CHANGED] */
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid var(--border);
    position: relative;
    /* [NEW] برای انیمیشن ورود */
    animation: productFadeIn 0.4s ease both;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.product-image-wrapper {
    position: relative;
    height: 220px;
    overflow: hidden;
    background: var(--light, #f8fafc); /* [NEW] background fallback */
}

.product-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    font-family: inherit; /* [NEW] */
}

.product-card:hover .product-image-wrapper img {
    transform: scale(1.1);
}

/* [NOTE] .product-badge از مکالمه قبلی حفظ شده */
.product-badge {
    position: absolute;
    top: 10px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-family: inherit; /* [NEW] */
}

/* [CHANGED] از inset-inline-start به جای left */
.badge-banned {
    inset-inline-start: 10px; /* [CHANGED] RTL/LTR هوشمند */
    background: var(--danger);
    color: var(--white);
}

/* [CHANGED] از inset-inline-end به جای right */
.badge-sale {
    inset-inline-end: 10px; /* [CHANGED] RTL/LTR هوشمند */
    background: var(--danger);
    color: var(--white);
    /* [CHANGED] نام انیمیشن اختصاصی */
    animation: pulseBadge 2s infinite;
}

/* [CHANGED] نام اختصاصی برای pulse */
@keyframes pulseBadge {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* [NEW] انیمیشن ورود کارت محصول */
@keyframes productFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-info {
    padding: 15px;
}

.product-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--dark);
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-family: inherit; /* [NEW] */
}

.product-stats {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    /* [CHANGED] از var(--light) یا fallback */
    background: var(--light, #f8fafc);
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--gray);
}

.stat-icon {
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-icon img {
    width: 18px;
    height: 18px;
    opacity: 0.6;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}

.empty-state img {
    width: 120px;
    opacity: 0.5;
    margin-bottom: 20px;
    font-family: inherit; /* [NEW] */
}

/* ===== Warning Message ===== */
/* [CHANGED] استفاده از متغیرهای CSS برای رنگ‌ها */
.warning-message {
    background: var(--warning-light, #fff3cd);
    color: var(--warning-dark, #856404);
    padding: 15px 20px;
    margin: 20px auto;
    max-width: 1200px;
    border-radius: var(--radius-md);
    border: 1px solid var(--warning-border, #ffeeba);
    text-align: center;
    font-weight: 500;
    font-family: inherit; /* [NEW] */
}

/* [CHANGED] از var(--primary) یا fallback */
.warning-message a {
    color: var(--primary, #004085);
    font-weight: 700;
    text-decoration: underline;
}

/* ===== Animations ===== */
/* [CHANGED] نام‌های اختصاصی برای جلوگیری از تداخل */
@keyframes profileFadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes profileFadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .profile-header {
        padding: 30px 15px; /* [CHANGED] */
    }

    .profile-content {
        flex-direction: column;
        text-align: center;
        align-items: center; /* [NEW] */
    }

    /* [NEW] در موبایل، یوزرنیم وسط */
    .profile-username {
        text-align: center;
    }

    .profile-info h1 {
        font-size: 1.6rem; /* [CHANGED] */
    }

    .stats {
        justify-content: center;
        gap: 15px;
    }

    .stat-item {
        padding: 8px 15px;
        min-width: 80px;
    }

    .stat-item strong {
        font-size: 1.4rem;
    }

    .action-buttons {
        justify-content: center;
    }

    .products-grid {
        /* [CHANGED] در موبایل دو ستون به جای یک ستون */
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px; /* [CHANGED] */
    }

    .product-image-wrapper {
        height: 160px; /* [CHANGED] کوچکتر در موبایل */
    }

    .bio-section,
    .products-section {
        padding: 20px;
    }

    .ad-banner {
        flex-direction: column;
        text-align: center;
        padding: 20px 15px; /* [CHANGED] */
    }

    .ad-content {
        flex-direction: column;
        gap: 10px;
    }

    /* [NEW] در موبایل ریبون مخفی */
    .ad-ribbon {
        display: none;
    }
}

@media (max-width: 768px) {
    .container {
        padding-inline: 8px;
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .product-card {
        width: 100%;
    }

    .product-image-wrapper {
        height: 120px;
    }

    /* عنوان محصول */
    .product-title {
        font-size: 0.75rem;
        height: 2.6em;
        padding: 0 5px;
        margin-bottom: 5px;
    }

   
    .product-info {
        padding: 8px;
    }

    .product-stats {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

.product-price {
    font-weight: 700;
    color: var(--danger);
    font-size: 1.1rem;
    margin-top: 8px;
}

.price-old {
    color: var(--gray);
    font-weight: normal;
    font-size: 0.9rem;
    margin-right: 8px;
}

@media (max-width: 768px) {
    .product-price {
        font-size: 0.75rem;
        margin-top: 4px;
    }

    .price-old {
        font-size: 0.7rem;
    }
}

/* =====================================================
   Dark Mode Styles for Profile Page
   ===================================================== */

/* تغییر رنگ پس‌زمینه سکشن‌های اصلی (بیوگرافی و محصولات) */
[data-theme="dark"] .bio-section,
[data-theme="dark"] .products-section,
[data-theme="dark"] .product-card {
    background: #1e1e1e;
    border-color: #333333;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* تغییر رنگ تیترها و متن‌ها */
[data-theme="dark"] .bio-section h2,
[data-theme="dark"] .products-section h2,
[data-theme="dark"] .product-title {
    color: #f1f5f9;
}

[data-theme="dark"] .bio-content {
    color: #cbd5e1;
}

/* دکمه‌های پروفایل که پس‌زمینه سفید داشتند */
[data-theme="dark"] .profile-btn-follow,
[data-theme="dark"] .profile-btn-message,
[data-theme="dark"] .profile-btn-edit {
    background: #2d3748;
    color: #e2e8f0;
}

[data-theme="dark"] .profile-btn-follow:hover,
[data-theme="dark"] .profile-btn-message:hover,
[data-theme="dark"] .profile-btn-edit:hover {
    background: var(--primary);
    color: #ffffff;
}

/* بج دسته‌بندی */
[data-theme="dark"] .category-badge {
    background: rgba(var(--primary-rgb, 59, 130, 246), 0.2);
    color: #93c5fd;
}

/* استایل‌های کارت محصول در دارک مود */
[data-theme="dark"] .product-stats {
    background: #2d3748;
    border-top-color: #4a5568;
    color: #e2e8f0;
}

[data-theme="dark"] .product-image-wrapper {
    background: #2d3748;
}

/* بنرهای تبلیغاتی در حالت تاریک */
[data-theme="dark"] .ad-banner {
    background: linear-gradient(135deg, #422a04 0%, #2b1c03 100%);
    border-color: #78350f;
}

[data-theme="dark"] .ad-text h4 {
    color: #fde68a;
}

[data-theme="dark"] .ad-text p {
    color: #d1d5db;
}

/* پیام هشدار (Warning Message) */
[data-theme="dark"] .warning-message {
    background: #422a04;
    color: #fde68a;
    border-color: #78350f;
}

[data-theme="dark"] .warning-message a {
    color: #fcd34d;
}

/* کم رنگ کردن آیکن‌های داخل کارت‌ها برای حالت تاریک (در صورت نیاز) */
[data-theme="dark"] .stat-icon img {
    filter: brightness(0) invert(1) opacity(0.8);
}
