/* assets/css/frontend.css
   نسخه ۳.۰ — بازنویسی‌شده با CSS Logical Properties برای پشتیبانی صحیح
   از هر دو جهت RTL (فارسی) و LTR (انگلیسی) بدون نیاز به کد جدا.
   جهت واقعی از خصیصه dir روی #cp-popup خوانده می‌شود (در popup.php تنظیم
   شده) و مرورگر آن را به‌صورت خودکار روی خصیصه CSS direction اعمال می‌کند؛
   بر همین اساس تمام مقادیر padding/margin/border/inset از معادل منطقی
   (inline-start/end, block-start/end) استفاده می‌کنند تا خودبه‌خود در هر
   دو جهت درست بنشینند.

   فونت‌ها (Vazirmatn / Inter) از قبل به‌صورت لوکال در قالب سایت لود
   شده‌اند؛ این فایل فقط font-family مناسب هر زبان را از طریق کلاس
   cp-lang-fa / cp-lang-en انتخاب می‌کند.
*/

.cp-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    justify-content: center;
    align-items: center;
    padding: 20px;

    --cp-font: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.cp-popup.cp-lang-en {
    --cp-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.cp-popup.active {
    display: flex;
}
/* اطمینان از این‌که محاسبه خصیصه‌های منطقی (inline/block) بر اساس dir
   واقعی این المان انجام شود، نه المان‌های اجدادش. */
.cp-popup[dir="rtl"] { direction: rtl; }
.cp-popup[dir="ltr"] { direction: ltr; }

.cp-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.4s ease;
}

.cp-container {
    position: relative;
    background: #FFFFFF;
    padding-block: 40px 32px;
    padding-inline: 44px;
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    border-block-start: 5px solid #2563EB;
    max-height: 92vh;
    overflow-y: auto;
    animation: cpSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
    font-family: var(--cp-font);
}
@keyframes cpSlideIn {
    from {
        opacity: 0;
        /* فقط روی محور Y — این انیمیشن جهت‌دار نیست و در RTL/LTR یکسان است */
        transform: scale(0.92) translateY(24px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.cp-rounded .cp-container {
    border-radius: 28px;
}
.cp-shadow .cp-container {
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.18), 0 10px 30px rgba(0, 0, 0, 0.06);
}

.cp-close {
    position: absolute;
    top: 14px;
    /* گوشه‌ی "پایان" ردیف — به‌صورت خودکار در فارسی چپ و در انگلیسی راست
       می‌نشیند، بدون نیاز به override جدا برای هر زبان. */
    inset-inline-end: 18px;
    background: #F1F5F9;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #64748B;
    transition: all 0.25s ease;
    padding: 6px 10px;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cp-close:hover {
    background: #FEE2E2;
    color: #EF4444;
    transform: rotate(90deg);
}
.cp-close:active {
    transform: rotate(90deg) scale(0.92);
}

.cp-header {
    text-align: center;
    margin-block-end: 28px;
}
.cp-icon {
    font-size: 40px;
    margin-block-end: 10px;
    display: block;
}
.cp-header h3 {
    font-size: 24px;
    font-weight: 800;
    color: #0F172A;
    margin-block: 0 6px;
    letter-spacing: -0.01em;
}
.cp-header p {
    font-size: 15px;
    color: #64748B;
    margin: 0;
    line-height: 1.7;
    font-weight: 400;
}

.cp-field {
    margin-block-end: 18px;
}
.cp-field label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #0F172A;
    margin-block-end: 5px;
}
.cp-required {
    color: #EF4444;
}
.cp-field input,
.cp-field textarea {
    width: 100%;
    padding-block: 12px;
    padding-inline: 16px;
    border: 2px solid #E2E8F0;
    border-radius: 14px;
    font-size: 15px;
    font-family: var(--cp-font);
    transition: all 0.25s ease;
    background: #F8FAFC;
    color: #0F172A;
    box-sizing: border-box;
    font-weight: 450;
}
/* فیلدهای ایمیل/موبایل همیشه LTR هستند (حتی داخل پاپ‌اپ فارسی) چون
   ایمیل و شماره تلفن رشته‌های لاتین/عددی جهت‌دار چپ‌به‌راست‌اند. */
.cp-field input[type="email"],
.cp-field input[type="tel"] {
    direction: ltr;
    text-align: start;
}
.cp-field input::placeholder,
.cp-field textarea::placeholder {
    color: #94A3B8;
    font-weight: 350;
}
.cp-field input:hover,
.cp-field textarea:hover {
    background: #FFFFFF;
    border-color: #CBD5E1;
}
.cp-field input:focus,
.cp-field textarea:focus {
    border-color: #2563EB;
    outline: none;
    background: #FFFFFF;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}
.cp-field input.error,
.cp-field textarea.error {
    border-color: #EF4444;
    background: #FEF2F2;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.08);
}
.cp-field input.error:focus,
.cp-field textarea.error:focus {
    border-color: #EF4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}
.cp-field textarea {
    resize: vertical;
    min-height: 100px;
    border-radius: 14px;
}
.cp-error {
    display: none;
    font-size: 13px;
    font-weight: 500;
    color: #EF4444;
    margin-block-start: 5px;
    padding-inline-start: 4px;
}
.cp-error.show {
    display: block;
    animation: cpFadeError 0.3s ease;
}
@keyframes cpFadeError {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* فیلد Honeypot — از دید کاربر واقعی کاملاً پنهان است (روش logical،
   مستقل از جهت زبان کار می‌کند) */
.cp-hp-field {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    inset-inline-start: -9999px !important;
}

.cp-hint {
    display: block;
    font-size: 12px;
    color: #94A3B8;
    margin-block-start: 5px;
    font-weight: 400;
}

.cp-submit {
    width: 80%;
    padding-block: 14px;
    padding-inline: 20px;
    color: #FFFFFF;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 700;
    font-family: var(--cp-font);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-block: 8px 0;
    margin-inline: auto;
    display: block;
    position: relative;
    letter-spacing: 0.02em;
    min-height: 52px;
}
.cp-submit:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.35);
}
.cp-submit:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}
.cp-submit .cp-submit-loader {
    display: none;
}
.cp-submit.loading .cp-submit-text {
    display: none;
}
.cp-submit.loading .cp-submit-loader {
    display: inline-block;
    animation: cpSpin 0.8s linear infinite;
}
@keyframes cpSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
.cp-submit.loading {
    opacity: 0.8;
    pointer-events: none;
    transform: scale(0.98);
}

#cp-response {
    margin-block-start: 14px;
    font-size: 15px;
    text-align: center;
    padding-block: 10px;
    padding-inline: 16px;
    border-radius: 12px;
    font-weight: 500;
    display: none;
}
#cp-response.success {
    display: block;
    color: #065F46;
    background: #D1FAE5;
    border: 1px solid #6EE7B7;
    animation: cpFadeError 0.4s ease;
}
#cp-response.error {
    display: block;
    color: #991B1B;
    background: #FEE2E2;
    border: 1px solid #FCA5A5;
    animation: cpFadeError 0.4s ease;
}

.cp-footer {
    text-align: center;
    margin-block-start: 20px;
    padding-block-start: 14px;
    border-block-start: 1px solid #E2E8F0;
}
.cp-footer small {
    font-size: 12px;
    color: #94A3B8;
    font-weight: 400;
}

.cp-popup.cp-dark .cp-container {
    background: #1E293B;
}
.cp-popup.cp-dark .cp-header h3 {
    color: #F8FAFC;
}
.cp-popup.cp-dark .cp-header p {
    color: #94A3B8;
}
.cp-popup.cp-dark .cp-field label {
    color: #E2E8F0;
}
.cp-popup.cp-dark .cp-field input,
.cp-popup.cp-dark .cp-field textarea {
    background: #0F172A;
    border-color: #334155;
    color: #F8FAFC;
}
.cp-popup.cp-dark .cp-field input::placeholder,
.cp-popup.cp-dark .cp-field textarea::placeholder {
    color: #64748B;
}
.cp-popup.cp-dark .cp-field input:focus,
.cp-popup.cp-dark .cp-field textarea:focus {
    border-color: #2563EB;
    background: #0F172A;
}
.cp-popup.cp-dark .cp-close {
    background: #334155;
    color: #94A3B8;
}
.cp-popup.cp-dark .cp-close:hover {
    background: #FEE2E2;
    color: #EF4444;
}
.cp-popup.cp-dark .cp-footer {
    border-color: #334155;
}
.cp-popup.cp-dark .cp-footer small {
    color: #64748B;
}
.cp-popup.cp-dark .cp-error {
    color: #F87171;
}

[data-cp-trigger] {
    cursor: pointer;
}

@media (max-width: 768px) {
    .cp-container {
        padding-block: 32px 24px;
        padding-inline: 28px;
        max-width: 420px;
    }
    .cp-header h3 {
        font-size: 22px;
    }
    .cp-header p {
        font-size: 14px;
    }
    .cp-field input,
    .cp-field textarea {
        font-size: 14px;
        padding-block: 10px;
        padding-inline: 14px;
    }
    .cp-submit {
        width: 85%;
        font-size: 16px;
        padding-block: 12px;
        padding-inline: 18px;
        min-height: 48px;
    }
}

@media (max-width: 480px) {
    .cp-container {
        padding-block: 24px 20px;
        padding-inline: 18px;
        max-width: 100%;
        border-radius: 20px;
        margin: 10px;
    }
    .cp-header h3 {
        font-size: 20px;
    }
    .cp-header p {
        font-size: 13px;
    }
    .cp-icon {
        font-size: 32px;
    }
    .cp-field input,
    .cp-field textarea {
        font-size: 13px;
        padding-block: 10px;
        padding-inline: 12px;
        border-radius: 12px;
    }
    .cp-field label {
        font-size: 13px;
    }
    .cp-submit {
        width: 100%;
        font-size: 15px;
        padding-block: 12px;
        padding-inline: 16px;
        border-radius: 12px;
        min-height: 44px;
    }
    .cp-close {
        top: 10px;
        inset-inline-end: 12px;
        width: 32px;
        height: 32px;
        font-size: 18px;
        padding: 4px 8px;
    }
    #cp-response {
        font-size: 13px;
        padding-block: 8px;
        padding-inline: 12px;
    }
    .cp-footer small {
        font-size: 11px;
    }
}

@media (max-width: 380px) {
    .cp-container {
        padding-block: 20px 16px;
        padding-inline: 14px;
    }
    .cp-header h3 {
        font-size: 18px;
    }
    .cp-field input,
    .cp-field textarea {
        font-size: 12px;
        padding-block: 8px;
        padding-inline: 10px;
    }
    .cp-submit {
        font-size: 14px;
        padding-block: 10px;
        padding-inline: 14px;
        min-height: 40px;
    }
}

.cp-container::-webkit-scrollbar {
    width: 4px;
}
.cp-container::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 10px;
}
.cp-container::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 10px;
}
.cp-container::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}
.cp-popup.cp-dark .cp-container::-webkit-scrollbar-track {
    background: #1E293B;
}
.cp-popup.cp-dark .cp-container::-webkit-scrollbar-thumb {
    background: #475569;
}
