/* =================================================================== */
/* === استایل‌های به‌روز شده و هماهنگ با تم اصلی برای مودال‌ها === */
/* =================================================================== */

/* ====== ۱. لایه اصلی مودال (Overlay) ====== */
.purchase-modal-overlay {
    position: fixed;
    inset: 0; /* معادل top:0; right:0; bottom:0; left:0; */
    background-color: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;

    /* انیمیشن نرم برای نمایش/مخفی شدن */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.purchase-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ====== ۲. استایل پایه محتوای مودال (Glassmorphism) ====== */
.purchase-modal-content,
.verification-modal-content,
.pre-invoice-content,
.error-modal-content {
    /* استفاده از استایل شیشه‌ای هماهنگ با صفحه */
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    
    color: var(--text-light);
    border-radius: 20px;
    max-width: 800px; /* افزایش عرض برای نمایش بهتر */
    width: 95%;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    padding: 2.5rem;
    position: relative;

    /* انیمیشن ورود محتوا */
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* فعال شدن انیمیشن ورود محتوا */
.purchase-modal-overlay.active > div {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ====== ۳. دکمه بستن مودال ====== */
.purchase-modal-close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem; /* اصلاح شده برای چیدمان راست‌چین */
    background: transparent;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-dark);
    transition: color 0.2s ease, transform 0.2s ease;
    line-height: 1;
}
.purchase-modal-close-btn:hover {
    color: var(--text-light);
    transform: rotate(90deg);
}

/* ====== ۴. مودال اصلی خرید (فرم و خلاصه) ====== */
.purchase-grid {
    display: grid;
    grid-template-columns: 1fr 300px; /* تنظیم ستون‌ها */
    gap: 2.5rem;
}

.product-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.product-icon {
    width: 48px;
    height: 48px;
}
.product-header h1 {
    font-size: 1.5rem;
    font-weight: 500;
    color: #fff; /* رنگ روشن‌تر برای عنوان */
}

.shahkar-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--warning-border);
    margin-bottom: 1.5rem;
}
.shahkar-notice .icon {
    font-size: 1.2rem;
    margin-top: 2px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.25rem;
}
.form-group label {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}
.form-group input {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-group input::placeholder {
    color: var(--text-dark);
}
.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--glow-color);
    outline: none;
}

.purchase-summary-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.summary-product-image img {
    max-width: 100%;
    border-radius: 16px;
    opacity: 0.9;
}
.price-summary {
    font-size: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(0,0,0,0.15);
}
.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.price-row strong {
    font-weight: 500;
}
.terms-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-dark);
}
.terms-group a {
    color: var(--primary-color);
    text-decoration: none;
}
.terms-group a:hover {
    text-decoration: underline;
}

/* ====== ۵. دکمه‌های عمومی ====== */
.cta-button {
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px var(--glow-color);
    width: 100%;
    text-align: center;
}
.cta-button:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 0 25px var(--glow-color);
    background: #fff;
    color: var(--primary-color);
}
.cta-button:disabled {
    background: #555;
    color: #999;
    border-color: #555;
    box-shadow: none;
    cursor: not-allowed;
}
.secondary-cta {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border-color);
    box-shadow: none;
}
.secondary-cta:hover:not(:disabled) {
    background: var(--border-color);
    color: #fff;
}

/* ====== ۶. مودال تایید شماره تماس ====== */
.verification-modal-content { max-width: 450px; }
.verification-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}
.verification-header .fas {
    font-size: 2rem;
    color: var(--primary-color);
}
.verification-body {
    text-align: center;
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
}
.verification-body strong {
    color: var(--text-light);
    font-weight: 500;
}
.code-inputs input {
    text-align: center;
    letter-spacing: 0.75rem;
    font-size: 1.75rem;
    padding: 0.75rem;
    width: 100%;
}
.resend-timer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 1.5rem;
    gap: 1rem;
}
.resend-btn {
    border: none;
    background: transparent;
    color: var(--primary-color);
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}
.resend-btn:disabled {
    color: var(--text-dark);
    cursor: not-allowed;
}
.verification-footer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ====== ۷. مودال پیش‌فاکتور ====== */
.pre-invoice-content { max-width: 600px; }
.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.invoice-header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.invoice-header-logo .fas {
    font-size: 1.5rem;
    color: var(--primary-color);
}
.invoice-parties {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: var(--text-dark);
}
.party-info h4 {
    color: var(--text-light);
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.seller-info { text-align: left; }
.invoice-table {
    width: 100%;
    border-collapse: collapse;
}
.invoice-table th, .invoice-table td {
    border: 1px solid var(--border-color);
    padding: 1rem;
    text-align: center;
}
.invoice-table th {
    background: rgba(0,0,0,0.2);
    color: var(--text-light);
    font-weight: 500;
}
.invoice-footer {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* ====== ۸. مودال خطا ====== */
.error-modal-content { max-width: 400px; text-align: center; }
.error-modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    color: #ff4757; /* رنگ قرمز برای خطا */
}
.error-modal-header .icon { font-size: 3rem; }
.error-modal-header h3 { font-size: 1.5rem; margin: 0; }
.error-modal-body {
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 2rem;
}
.error-modal-footer .cta-button {
    background: #ff4757;
    border-color: #ff4757;
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.4);
}
.error-modal-footer .cta-button:hover:not(:disabled) {
    background: #fff;
    color: #ff4757;
}

/* ====== ۹. واکنش‌گرایی (Responsive) ====== */
@media (max-width: 768px) {
    .purchase-grid {
        grid-template-columns: 1fr; /* ستون‌ها روی هم قرار می‌گیرند */
    }
    .purchase-summary-section {
        /* معکوس کردن ترتیب برای نمایش عکس در بالا */
        grid-row: 1; 
    }
    .purchase-modal-content,
    .verification-modal-content,
    .pre-invoice-content,
    .error-modal-content {
        padding: 2rem 1.5rem;
        width: 90%;
    }
    .invoice-parties {
        flex-direction: column;
        gap: 1.5rem;
    }
    .seller-info { text-align: right; }
}
