/* ==========================================================================
   استایل ماشین‌حساب‌های موج سوم
   رنگ‌ها و فونت مطابق طرح‌های نمونه ارسالی (پاپ‌آپ‌های فاکتور/کارنامه/سبد)
   ========================================================================== */

.mh-calc-wrapper {
    --mh-bg-body: #f8f7f5;
    --mh-surface: #ffffff;
    --mh-text-main: #1e293b;
    --mh-text-muted: #64748b;
    --mh-border-light: #e2e8f0;
    --mh-primary: #2d2e82;
    --mh-primary-light: #eff6ff;
    --mh-accent: #d97706;
    --mh-accent-green: #059669;
    --mh-accent-green-bg: #ecfdf5;
    --mh-profit-main: #16a34a;
    --mh-profit-light: #dcfce7;
    --mh-loss-main: #dc2626;
    --mh-loss-light: #fee2e2;


    color: var(--mh-text-main);
    box-sizing: border-box;
}

.mh-calc-wrapper * {
    box-sizing: border-box;
    font-family: inherit;
}

.mh-calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 760px) {
    .mh-calc-grid {
        grid-template-columns: 1fr;
    }
}

.mh-calc-card {
    background-color: var(--mh-surface);
    border: 1px solid var(--mh-border-light);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 4px 14px -6px rgba(15, 23, 42, 0.08);
}

.mh-calc-card-full {
    width: 100%;
}

.mh-card-title {
    margin: 0 0 18px 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--mh-text-main);
}

.mh-field{
    margin-top: 18px;
}

.mh-field-grow {
    flex: 1;
}

.mh-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--mh-text-main);
    margin-bottom: 8px;
}

.mh-input,
.mh-input-group {
    width: 100%;
}

.mh-input {
    width: 100%;
    border: 1px solid var(--mh-border-light);
    background-color: var(--mh-bg-body);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 0.9rem;
    color: var(--mh-text-main);
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
}

.mh-input:focus {
    border-color: #2d2e82;
    background-color: var(--mh-surface);
}

.mh-input-group {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--mh-border-light);
    background-color: var(--mh-bg-body);
    border-radius: 12px;
    overflow: hidden;
}

.mh-input-group .mh-input {
    border: none;
    background: transparent;
    border-radius: 0;
    flex: 1;
    min-width: 0;
}

.mh-input-group .mh-input:focus {
    background: transparent;
}

.mh-suffix {
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 0.8rem;
    color: var(--mh-text-muted);
    white-space: nowrap;
    border-right: 1px solid var(--mh-border-light);
}

.mh-suffix-select {
    border: none;
    border-right: 1px solid var(--mh-border-light);
    background-color: var(--mh-bg-body);
    color: var(--mh-text-muted);
    font-size: 0.8rem;
    padding: 0 10px;
    font-family: inherit;
}

.mh-hint {
    font-size: 0.72rem;
    color: var(--mh-text-muted);
    margin-top: 6px;
    line-height: 1.6;
}

.mh-toggle-link {
    font-size: 0.78rem;
    color: #2d2e82;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    display: inline-block;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.mh-collapse {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--mh-border-light);
}

.mh-collapse.mh-open {
    display: block;
}

.mh-action-btn {
    position: relative;
    width: 100%;
    background: linear-gradient(135deg, #2d2e82 0%, #10112b 100%);
    color: #ffffff;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    margin-top: 13px;
    overflow: hidden;
    box-shadow: 0 10px 20px -5px rgba(45, 46, 130, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
}

.mh-action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -6px rgba(45, 46, 130, 0.6);
}

.mh-action-btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 4px 10px -2px rgba(45, 46, 130, 0.4);
}

/* حالت «در حال پردازش» دکمه محاسبه */
.mh-action-btn.is-processing {
    cursor: not-allowed;
    background: linear-gradient(135deg, #202066 0%, #0a0b1c 100%);
    transform: scale(0.98);
    box-shadow: 0 4px 10px -2px rgba(45, 46, 130, 0.3);
}

/* افکت گذر نور (Shimmer) روی دکمه حین پردازش */
.mh-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transform: skewX(-25deg);
    z-index: 0;
}

.mh-action-btn.is-processing::before {
    animation: mhShimmerSweep 1.6s infinite;
}

@keyframes mhShimmerSweep {
    0% { left: -150%; }
    100% { left: 200%; }
}

.mh-btn-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.mh-btn-text {
    transition: opacity 0.15s;
}

/* نقطه‌های متحرک زمان پردازش */
.mh-dot-pulse {
    display: none;
    align-items: center;
    gap: 4px;
    direction: ltr;
}

.mh-action-btn.is-processing .mh-dot-pulse {
    display: flex;
}

.mh-dot-pulse span {
    width: 6px;
    height: 6px;
    background-color: #ffffff;
    border-radius: 50%;
    animation: mhDotBounce 1.4s infinite ease-in-out both;
}

.mh-dot-pulse span:nth-child(1) { animation-delay: -0.32s; }
.mh-dot-pulse span:nth-child(2) { animation-delay: -0.16s; }

@keyframes mhDotBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; box-shadow: 0 0 8px rgba(255, 255, 255, 0.8); }
}

.mh-action-btn-inline {
    width: auto;
    white-space: nowrap;
    padding: 14px 28px;
}

.mh-power-row {
    display: flex;
    align-items: flex-end;
    gap: 14px;
}

.mh-power-row .mh-input-group,
.mh-power-row .mh-action-btn-inline {
    height: 48px;
}

.mh-power-row .mh-action-btn-inline {
    flex-shrink: 0;
    box-sizing: border-box;
}

@media (max-width: 560px) {
    .mh-power-row {
        flex-direction: column;
        align-items: stretch;
    }
    .mh-power-row .mh-action-btn-inline {
        width: 100%;
    }
}

/* چک‌باکس «درصد کلی» در کارت شبیه‌ساز فاکتور */
.mh-checkbox-field {
    margin-top: 18px;
}

.mh-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--mh-text-main);
    cursor: pointer;
}

.mh-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: #2d2e82;
    cursor: pointer;
}

.mh-error-text {
    color: var(--mh-loss-main);
    font-size: 0.8rem;
    margin-top: 10px;
    min-height: 0;
}

/* ==========================================================================
   مودال مشترک (برای هر سه نتیجه استفاده می‌شود)
   ========================================================================== */

.mh-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: mhFadeIn 0.25s ease-out forwards;

}

.mh-modal-overlay.mh-active {
    display: flex;
}

@keyframes mhFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.mh-modal-content {
    background-color: var(--mh-surface, #fff);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    border-radius: 24px;
    overflow-y: auto;
    animation: mhSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    color: #1e293b;
}

@keyframes mhSlideUp {
    from { transform: translateY(40px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

@media (max-width: 480px) {
    .mh-modal-overlay { align-items: flex-end; }
    .mh-modal-content {
        border-radius: 26px 26px 0 0;
        max-height: 85vh;
        padding-bottom: 32px;
    }
}

.mh-drag-handle {
    width: 40px;
    height: 5px;
    background-color: #cbd5e1;
    border-radius: 10px;
    margin: 0 auto 16px auto;
    display: none;
}
@media (max-width: 480px) { .mh-drag-handle { display: block; } }

.mh-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.mh-modal-header h3 { margin: 0; font-size: 1.12rem; font-weight: 800; color: #1e293b; }

.mh-close-icon {
    background: #f8f7f5;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #64748b;
    cursor: pointer;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* --- عناصر مشترک داخل بدنه مودال --- */

.mh-invoice-list { margin-bottom: 20px; }
.mh-invoice-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px dashed #e2e8f0;
    font-size: 0.92rem;
}
.mh-invoice-item:last-child { border-bottom: none; }
.mh-invoice-item .mh-label { color: #64748b; font-weight: 500; }
.mh-invoice-item .mh-value { color: #1e293b; font-weight: 700; }
.mh-invoice-item .mh-value.mh-accent { color: #d97706; }
.mh-unit { font-size: 0.72rem; color: #94a3b8; margin-right: 4px; font-weight: normal; }

.mh-total-box {
    background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
    border-radius: 16px;
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    border: 1px solid #bfdbfe;
}
.mh-total-box .mh-label { color: #1e3a8a; font-weight: 700; font-size: 1.02rem; }
.mh-total-box .mh-value {
    color: #1e3a8a; font-weight: 900; font-size: 1.4rem;
    display: flex; align-items: baseline; direction: ltr;
}

.mh-insight-card {
    background-color: #f8f7f5;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 18px;
}
.mh-insight-text { font-size: 0.83rem; line-height: 1.8; color: #1e293b; margin-bottom: 12px; }
.mh-insight-text strong { color: #d97706; font-size: 0.98rem; }

.mh-progress-bg {
    background-color: #e2e8f0;
    height: 8px;
    border-radius: 4px;
    width: 100%;
    overflow: hidden;
}
.mh-progress-fill {
    height: 100%;
    background-color: #d97706;
    width: 0%;
    border-radius: 4px;
    transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

/* کارنامه سود/زیان */
.mh-result-box {
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    text-align: center;
    background-color: #dcfce7;
    border: 1px solid #bbf7d0;
}
.mh-result-box.mh-loss {
    background-color: #fee2e2;
    border-color: #fecaca;
}
.mh-result-label { font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; color: #16a34a; }
.mh-result-box.mh-loss .mh-result-label { color: #dc2626; }
.mh-result-number {
    font-weight: 900; font-size: 1.7rem; display: flex; align-items: baseline;
    direction: ltr; color: #16a34a;
}
.mh-result-box.mh-loss .mh-result-number { color: #dc2626; }
.mh-percent-badge {
    display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px;
    font-size: 0.82rem; font-weight: 700; margin-top: 10px; direction: ltr;
    background-color: #ffffff; color: #16a34a;
}
.mh-result-box.mh-loss .mh-percent-badge { color: #dc2626; }

/* سبد پیشنهادی قدرت خرید */
.mh-budget-banner {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.mh-budget-banner .mh-label { font-size: 0.83rem; color: #1e3a8a; font-weight: 600; }
.mh-budget-banner .mh-value { font-size: 1.02rem; color: #1e3a8a; font-weight: 900; }

.mh-suggestions-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.mh-suggestion-card {
    background-color: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transform: translateY(12px);
    animation: mhItemAppear 0.35s ease forwards;
}
@keyframes mhItemAppear { to { opacity: 1; transform: translateY(0); } }

.mh-asset-info { display: flex; align-items: center; gap: 12px; }
.mh-asset-icon-box {
    width: 36px; height: 36px; background-color: #f8f7f5; border-radius: 10px;
    display: flex; justify-content: center; align-items: center; font-size: 1.1rem; flex-shrink: 0;
}
.mh-asset-name { font-size: 0.88rem; color: #1e293b; font-weight: 700; }
.mh-asset-sub { font-size: 0.72rem; color: #64748b; margin-top: 2px; }
.mh-asset-result { text-align: left; flex-shrink: 0; }
.mh-quantity-badge {
    background-color: #ecfdf5; color: #059669; padding: 4px 10px; border-radius: 8px;
    font-size: 0.82rem; font-weight: 800; display: inline-block; direction: ltr;
}
.mh-remainder-text { font-size: 0.68rem; color: #64748b; margin-top: 3px; }
