:root {
    --primary: #ef394e;
    --primary-hover: #d7283c;
    --primary-light: #fff0f2;

    --accent-blue: #0288d1;
    --accent-blue-bg: #e1f5fe;

    --text-main: #23254e;
    --text-muted: #767790;
    --text-light: #9e9fb1;

    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --border-color: #e5e7eb;
    --border-light: #f0f0f1;

    --success-bg: #f0fdf4;
    --success-text: #166534;
    --success-border: #bbf7d0;

    --danger-bg: #fef2f2;
    --danger-text: #991b1b;
    --danger-border: #fecaca;

    --badge-gold-bg: #fef3c7;
    --badge-gold-text: #b45309;

    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    --card-shadow-hover: 0 12px 24px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    direction: rtl;
    scroll-behavior: smooth;
}

body,
button,
input,
select,
textarea {
    font-family: Tahoma, "Segoe UI", Arial, sans-serif;
}

body {
    min-height: 100vh;
    background: var(--bg-page);
    color: var(--text-main);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.container {
    width: min(100% - 32px, 1200px);
    margin: 0 auto;
}

/* Header */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 14px 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 800;
}

.brand-badge {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 900;
}

.header-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* General layout */

.main-content {
    min-height: calc(100vh - 150px);
    padding: 30px 0 60px;
}

.hero {
    padding: 20px 0 30px;
    text-align: center;
}

.hero h1 {
    margin-bottom: 8px;
    color: var(--text-main);
    font-size: 1.9rem;
    font-weight: 800;
}

.hero p,
.simple-info p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Forms */

.form-card,
.simple-info,
.empty-state,
.results-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.form-card {
    max-width: 540px;
    margin: 0 auto 30px;
    padding: 32px;
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    outline: none;
    background: #fff;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: 0.2s ease;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(239, 57, 78, 0.12);
}

.hint {
    display: block;
    margin-top: 6px;
    color: var(--text-light);
    font-size: 0.8rem;
}

.radio-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.radio-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    transition: 0.2s ease;
}

.radio-card input[type="radio"] {
    display: none;
}

.radio-card:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
}

.radio-card .card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.count-title {
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 700;
}

.badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge.free {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge.pro {
    background: var(--badge-gold-bg);
    color: var(--badge-gold-text);
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 18px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    transition: 0.2s ease;
}

.primary-button:hover {
    background: var(--primary-hover);
}

.inline-btn {
    width: auto;
    margin-top: 14px;
    padding: 10px 24px;
}

/* Results */

.results-page {
    width: 100%;
}

.results-header {
    margin-bottom: 24px;
}

.results-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 800;
}

.results-query {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.results-query span {
    color: var(--text-main);
    font-weight: 700;
}

.results-count {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn-back,
.back-link {
    display: inline-block;
    color: var(--accent-blue);
    font-weight: 700;
}

.btn-back {
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--accent-blue-bg);
    font-size: 0.9rem;
    transition: 0.2s ease;
}

.btn-back:hover {
    background: #b3e5fc;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
    gap: 20px;
}

.product-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--card-shadow);
    transition: 0.25s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: #cbd5e1;
    box-shadow: var(--card-shadow-hover);
}

.product-image-wrapper,
.product-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    padding: 12px;
    background: #fff;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-image-placeholder,
.image-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    color: var(--text-light);
    font-size: 0.85rem;
    text-align: center;
}

.product-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 16px;
}

.product-reason-box {
    padding: 8px 10px;
    border-right: 3px solid var(--accent-blue);
    border-radius: 0 8px 8px 0;
    background: #fbfcfe;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.product-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    width: 100%;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}


.price-wrapper {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.price-caption {
    flex: 0 0 auto;
    color: var(--text-light);
    font-size: 0.72rem;
}

.price-value {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
}

.price-amount {
    color: var(--text-main);
    font-size: 1.15rem;
    font-weight: 800;
    white-space: nowrap;
}

.price-currency {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.card-actions {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}

.card-actions .purchase-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    width: 100%; /* <--- تغییر به 100% */
    min-width: 0;
    min-height: 44px;
    padding: 8px 6px;
    border-radius: 10px;
    font-size: 0.95rem; /* کمی بزرگتر برای خوانایی */
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    transition: 0.2s ease;
}


.details-button {
    border: 1px solid #d6dce8;
    background: #eef1f7;
    color: #26345c;
}

.details-button:hover {
    background: #dfe5f0;
}

.purchase-button {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
}

.purchase-button:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.purchase-button.is-disabled,
.purchase-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    background: #94a3b8;
    border-color: #94a3b8;
}

/* Compare Checkbox */

.compare-checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
    padding: 10px 14px;
    border: 1.5px dashed #bfdbfe;
    border-radius: 12px;
    background: #f0f6ff;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease-in-out;
}

.compare-checkbox-wrapper:hover {
    border-color: #3b82f6;
    background: #e0eeff;
    transform: translateY(-1px);
}

.compare-checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: #2563eb;
}

.compare-checkbox-text {
    color: #1e40af;
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.compare-checkbox-wrapper:has(input:checked) {
    border: 1.5px solid #2563eb;
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

/* Compare floating bar */

.compare-bar {
    position: fixed;
    right: 16px;
    bottom: 20px;
    left: 16px;
    z-index: 1000;
    display: flex;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(15px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.compare-bar.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.compare-bar-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-width: 320px;
    padding: 12px 20px;
    border: 1px solid #dfe3ec;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(26, 35, 60, 0.18);
}

.compare-bar-count {
    color: var(--text-main);
    font-weight: 700;
}

.compare-button {
    min-height: 40px;
    padding: 0 20px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    background: #2563eb;
    color: #fff;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    transition: 0.2s ease;
}

.compare-button:hover {
    background: #1d4ed8;
}

.compare-message {
    position: absolute;
    top: calc(100% + 8px);
    right: 50%;
    min-width: 260px;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid #f3b5af;
    border-radius: 8px;
    background: #fff1f0;
    color: #b42318;
    text-align: center;
    visibility: hidden;
    opacity: 0;
    transform: translateX(50%);
    transition: 0.2s ease;
}

.compare-message.is-visible {
    visibility: visible;
    opacity: 1;
}

/* Compare page */

.compare-page {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 20px 80px;
}

.compare-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.compare-header h1 {
    margin: 0;
    color: #202b50;
    font-size: 2rem;
}

.compare-header p {
    margin-top: 8px;
    color: #7b8191;
}

.compare-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    align-items: stretch;
    gap: 18px;
}

.compare-product-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 18px;
    border: 1px solid #e1e5ed;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(30, 42, 75, 0.08);
}

.compare-image-box {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 230px;
    margin-bottom: 15px;
    overflow: hidden;
    border-radius: 12px;
    background: #fafbfc;
}

.compare-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.compare-product-card h2 {
    min-height: 58px;
    margin: 0 0 16px;
    color: #202b50;
    font-size: 1.05rem;
    line-height: 1.8;
}

.compare-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #edf0f4;
    color: #73798a;
}

.compare-row strong {
    color: #202b50;
    text-align: left;
}

.compare-actions {
    display: flex;
    gap: 10px;
    padding-top: 18px;
}

.compare-actions .details-button,
.compare-actions .purchase-button {
    flex: 1;
    min-width: 0;
}

/* Detail page */

.detail-page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 80px;
}

.detail-header {
    margin-bottom: 20px;
}

.detail-card {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 32px;
    border: 1px solid #e1e5ed;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(30, 42, 75, 0.08);
}

.detail-top-wrapper {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 36px;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 30px;
}

.detail-image-box {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 380px;
    overflow: hidden;
    border-radius: 14px;
    background: #fafbfc;
    border: 1px solid #f0f2f5;
    padding: 16px;
}

.detail-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.detail-summary-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}

.detail-brand {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 0.85rem;
    font-weight: 800;
}

.detail-summary-info h1 {
    margin: 0;
    color: #202b50;
    font-size: clamp(1.25rem, 2vw, 1.65rem);
    line-height: 1.8;
}

.detail-price-box {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 8px;
}

.price-title {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.detail-price {
    color: var(--primary);
    font-size: 1.6rem;
    font-weight: 800;
}

.detail-main-purchase-btn {
    min-width: 240px;
    min-height: 48px;
    padding: 12px 28px;
    font-size: 0.95rem;
    border-radius: 12px;
    margin-top: 10px;
}

/* مشخصات اصلی ۳ ستونه تمام‌عرض */
.detail-full-width-content {
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: 100%;
}

.detail-section h2 {
    margin-bottom: 16px;
    color: #202b50;
    font-size: 1.15rem;
    font-weight: 700;
}

.detail-spec-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    width: 100%;
}

.detail-spec-grid > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 10px;
    background: #f8f9fb;
    border: 1px solid #f1f3f7;
}

.detail-spec-grid span {
    color: #73798a;
    font-size: 0.88rem;
}

.detail-spec-grid strong {
    color: #202b50;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: left;
}

.detail-text-content {
    color: #475569;
    line-height: 2;
    font-size: 0.95rem;
    text-align: justify;
    background: #fbfcfe;
    padding: 18px 22px;
    border-radius: 12px;
    border: 1px solid #edf2f7;
}

.detail-spec-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-spec-list > div {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 8px;
    background: #f8f9fb;
}

.detail-spec-list span {
    color: #73798a;
}

.detail-spec-list strong {
    color: #202b50;
    text-align: left;
}

/* واکنش‌گرایی برای صفحه جزئیات */
@media (max-width: 900px) {
    .detail-spec-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .detail-top-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .detail-image-box {
        height: 300px;
    }

    .detail-main-purchase-btn {
        width: 100%;
    }

    .detail-spec-grid {
        grid-template-columns: 1fr;
    }
}

/* Empty and footer */

.empty-state,
.no-results {
    max-width: 500px;
    margin: 40px auto;
    padding: 48px 24px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-surface);
    box-shadow: var(--card-shadow);
    text-align: center;
    color: var(--text-muted);
}

.site-footer {
    padding: 24px 0;
    border-top: 1px solid var(--border-light);
    background: #fff;
    color: var(--text-light);
    font-size: 0.82rem;
    text-align: center;
}

/* Responsive queries */

@media (max-width: 800px) {
    .detail-card {
        grid-template-columns: 1fr;
        gap: 25px;
        padding: 18px;
    }

    .detail-image-box {
        height: 330px;
    }
}

@media (max-width: 700px) {
    .radio-options {
        grid-template-columns: 1fr;
    }

    .header-content,
    .results-header-bar,
    .compare-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .products-grid,
    .compare-products-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .price-wrapper {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }

    .price-value {
        justify-content: flex-start;
    }

    .card-actions {
        flex-direction: column;
    }

    .card-actions .details-button,
    .card-actions .purchase-button {
        width: 100%;
    }

    .compare-bar-content {
        width: 100%;
        min-width: 0;
        flex-direction: column;
        gap: 10px;
    }

    .compare-message {
        right: 0;
        width: 100%;
        min-width: 0;
        transform: none;
    }
}

@media (max-width: 500px) {
    .container {
        width: min(100% - 20px, 1200px);
    }

    .form-card {
        padding: 22px 16px;
    }

    .detail-page,
    .compare-page {
        padding-right: 10px;
        padding-left: 10px;
    }

    .detail-spec-grid {
        grid-template-columns: 1fr;
    }

    .compare-product-card {
        padding: 14px;
    }

    .compare-image-box {
        height: 210px;
    }
}

/* خطی که بالای قیمت قرار دارد */
.product-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    width: 100%;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

/* بخش بالایی کارت محصول */
.product-top {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

/* برند به‌صورت برچسب کم‌رنگ */
.product-brand {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    border: none;
    border-radius: 8px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* نمایش کامل عنوان محصول */
.product-title {
    min-height: 0;
    margin: 0;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.8;
    text-align: justify;
    text-justify: inter-word;
    word-break: break-word;
    overflow: visible;
}

.detail-main-purchase-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 54px;
    margin-top: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 900;
    text-align: center;
}

/* هدر اصلی */
.site-header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between; /* پخش کردن المان‌ها در سه بخش */
    gap: 15px;
}

/* بخش چپ: دکمه بازگشت */
.header-left {
    flex: 1;
    display: flex;
    justify-content: flex-start;
}

.back-button {
    background: #f0f0f1;
    color: #3f4064;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    transition: 0.3s;
}

.back-button:hover {
    background: #e0e0e2;
}

/* بخش وسط: شعار */
.header-center {
    flex: 2;
    text-align: center;
}

.header-subtitle {
    font-size: 0.85rem;
    color: #717171;
}

/* بخش راست: لوگو */
.header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.site-logo {
    height: 45px; /* اندازه لوگو را اینجا تنظیم کن */
    width: auto;
    display: block;
}

/* مخفی کردن شعار در موبایل برای شلوغ نشدن */
@media (max-width: 600px) {
    .header-center {
        display: none;
    }
}
