/* ✅ استایل فرم مینیمال Shadcn - نسخه موبایل فیکس */

:root {
    --primary: #18181b;
    --primary-hover: #09090b;
    --border: #e2e8f0;
    --input-bg: #ffffff;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --text: #0f172a;
    --text-muted: #64748b;
    --radius: 8px;
}

/* فونت فارسی - اضافه شده */
body .ahanak-form-wrapper,
.ahanak-form-wrapper * {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Vazir', 'IRANSans', Tahoma, Arial, sans-serif !important;
}

.ahanak-form-wrapper {
    max-width: 650px;
    margin: 40px auto;
    padding: 0 16px;
    box-sizing: border-box; /* ✅ اضافه شد */
}

/* هدر فرم */
.ahanak-form-header {
    text-align: center;
    margin-bottom: 32px;
}

.ahanak-form-header h2 {
    font-size: clamp(18px, 4vw, 24px); /* ✅ ریسپانسیو شد */
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px 0;
}

.ahanak-form-header p {
    font-size: clamp(13px, 2.5vw, 14px); /* ✅ ریسپانسیو شد */
    color: var(--text-muted);
    margin: 0;
}

/* فرم اصلی */
.ahanak-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: clamp(1.25rem, 4vw, 2rem); /* ✅ پدینگ انعطاف‌پذیر */
    background: var(--input-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    box-sizing: border-box; /* ✅ اضافه شد */
    width: 100%; /* ✅ اضافه شد */
    max-width: 100%; /* ✅ اضافه شد */
    overflow: hidden; /* ✅ جلوگیری از خروج محتوا */
}

/* گروه فیلدها */
.ahanak-form .acf-field,
.ahanak-form .form-field {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-sizing: border-box !important; /* ✅ اضافه شد */
}

.ahanak-form .acf-label {
    margin-bottom: 8px !important;
}

.ahanak-form .acf-label label {
    font-size: clamp(13px, 2.5vw, 14px) !important; /* ✅ ریسپانسیو */
    font-weight: 600 !important; /* ✅ تغییر از 500 به 600 */
    color: var(--text) !important;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ahanak-form .acf-required {
    color: var(--error) !important;
}

/* اینپوت‌ها - فیکس موبایل */
.ahanak-form input[type="text"],
.ahanak-form input[type="tel"],
.ahanak-form input[type="email"],
.ahanak-form textarea,
.ahanak-form select {
    width: 100% !important;
    max-width: 100% !important; /* ✅ اضافه شد */
    padding: 10px 14px !important;
    font-size: clamp(14px, 2.5vw, 15px) !important; /* ✅ ریسپانسیو */
    background: var(--input-bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: var(--text) !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
    box-sizing: border-box !important; /* ✅ اضافه شد */
}

/* فیلد موبایل با آیکون */
.ahanak-form .mobile-field {
    position: relative;
}

.ahanak-form .mobile-field input[type="tel"] {
    direction: ltr !important;
    text-align: left !important;
    font-family: 'Courier New', monospace !important;
    letter-spacing: 1px !important;
    padding-right: 40px !important;
}

.ahanak-form .mobile-field::after {
    content: '📱';
    position: absolute;
    top: 38px;
    right: 14px;
    font-size: 18px;
    pointer-events: none;
}

.ahanak-form input::placeholder,
.ahanak-form textarea::placeholder {
    color: #94a3b8 !important;
    font-size: clamp(13px, 2.5vw, 14px) !important; /* ✅ اضافه شد */
}

/* حالت فوکوس */
.ahanak-form input:focus,
.ahanak-form textarea:focus,
.ahanak-form select:focus {
    background: var(--input-bg) !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    outline: none !important;
}

/* تکست‌اریا */
.ahanak-form textarea {
    resize: vertical !important;
    min-height: 120px !important;
    line-height: 1.6 !important;
}

/* اینپوت فایل - فیکس موبایل */
.ahanak-form .acf-file-uploader {
    background: #f8fafc !important;
    border: 2px dashed var(--border) !important;
    border-radius: var(--radius) !important;
    padding: 20px 12px !important; /* ✅ کاهش پدینگ */
    text-align: center !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important; /* ✅ اضافه شد */
    width: 100% !important; /* ✅ اضافه شد */
}

.ahanak-form .acf-file-uploader:hover {
    border-color: #cbd5e1 !important;
    background: #f1f5f9 !important;
}

.ahanak-form input[type="file"] {
    width: 100% !important; /* ✅ اضافه شد */
    max-width: 100% !important; /* ✅ اضافه شد */
    padding: 8px !important; /* ✅ کاهش پدینگ */
    cursor: pointer !important;
    font-size: clamp(12px, 2.5vw, 14px) !important; /* ✅ ریسپانسیو */
    border: 2px dashed var(--border) !important;
    background: #f8fafc !important;
    box-sizing: border-box !important; /* ✅ اضافه شد */
    word-break: break-word; /* ✅ اضافه شد */
}

.ahanak-form input[type="file"]:hover {
    border-color: #cbd5e1 !important;
    background: #f1f5f9 !important;
}

.ahanak-form input[type="file"]::file-selector-button {
    padding: 6px 12px; /* ✅ کاهش پدینگ */
    background: var(--primary);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: clamp(11px, 2vw, 13px); /* ✅ ریسپانسیو */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    margin-left: 8px;
    white-space: nowrap; /* ✅ اضافه شد */
}

.ahanak-form input[type="file"]::file-selector-button:hover {
    background: var(--primary-hover);
}

/* دکمه ارسال */
.ahanak-form .acf-form-submit {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.ahanak-btn {
    background: var(--primary) !important;
    color: #ffffff !important;
    border: none !important;
    padding: 12px 24px !important;
    border-radius: var(--radius) !important;
    cursor: pointer !important;
    font-size: clamp(14px, 2.5vw, 15px) !important; /* ✅ ریسپانسیو */
    font-weight: 600 !important; /* ✅ تغییر از 500 به 600 */
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
    width: 100% !important;
    box-sizing: border-box !important; /* ✅ اضافه شد */
}

.ahanak-btn .btn-icon {
    transition: transform 0.2s;
}

.ahanak-btn:hover {
    background: var(--primary-hover) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    transform: translateY(-1px);
}

.ahanak-btn:hover .btn-icon {
    transform: translateX(-2px);
}

.ahanak-btn:active {
    transform: translateY(0) !important;
}

.ahanak-btn:disabled {
    background: #e2e8f0 !important;
    color: #94a3b8 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* پیام موفقیت */
.ahanak-success-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px; /* ✅ کاهش پدینگ */
    background: var(--success-bg);
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    color: var(--success);
    margin-bottom: 24px;
    animation: slideIn 0.3s ease-out;
    box-sizing: border-box; /* ✅ اضافه شد */
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ahanak-success-box .icon {
    font-size: 20px; /* ✅ کاهش سایز */
    flex-shrink: 0;
    background: #dcfce7;
    width: 36px; /* ✅ کاهش سایز */
    height: 36px; /* ✅ کاهش سایز */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.ahanak-success-box .content {
    flex: 1;
    line-height: 1.6;
    word-break: break-word; /* ✅ اضافه شد */
}

.ahanak-success-box p {
    margin: 0 0 12px 0;
    font-size: clamp(13px, 2.5vw, 15px); /* ✅ ریسپانسیو */
}

.ahanak-success-box .tracking-code {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px; /* ✅ کاهش پدینگ */
    background: #dcfce7;
    border-radius: 8px;
    margin: 12px 0;
    flex-wrap: wrap; /* ✅ اضافه شد */
}

.ahanak-success-box .tracking-code .label {
    font-size: clamp(12px, 2.5vw, 14px); /* ✅ ریسپانسیو */
    font-weight: 500;
}

.ahanak-success-box .tracking-code .code {
    font-family: 'Courier New', monospace;
    font-size: clamp(14px, 3vw, 16px); /* ✅ ریسپانسیو */
    font-weight: 700;
    color: #15803d;
    background: white;
    padding: 4px 10px; /* ✅ کاهش پدینگ */
    border-radius: 6px;
    letter-spacing: 1px;
}

.ahanak-success-box .field-description {
    font-size: clamp(12px, 2vw, 13px); /* ✅ ریسپانسیو */
    color: #16a34a;
    margin: 8px 0 0 0;
}

/* پیام خطا */
.ahanak-error-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px; /* ✅ کاهش پدینگ */
    background: var(--error-bg);
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: var(--error);
    margin-bottom: 24px;
    animation: slideIn 0.3s ease-out;
    box-sizing: border-box; /* ✅ اضافه شد */
}

.ahanak-error-box .icon {
    font-size: 18px; /* ✅ کاهش سایز */
    flex-shrink: 0;
}

/* خطای فیلد */
.ahanak-form .acf-error-message {
    font-size: clamp(12px, 2vw, 13px) !important; /* ✅ ریسپانسیو */
    color: var(--error) !important;
    margin-top: 6px !important;
    padding: 6px 10px !important;
    background: var(--error-bg) !important;
    border-radius: 6px !important;
    border: 1px solid #fecaca !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    word-break: break-word !important; /* ✅ اضافه شد */
}

.ahanak-form .acf-error-message::before {
    content: '⚠️';
    font-size: 14px;
    flex-shrink: 0; /* ✅ اضافه شد */
}

.ahanak-form .acf-field.error input,
.ahanak-form .acf-field.error textarea,
.ahanak-form .acf-field.error select {
    border-color: var(--error) !important;
    background: #fffbfb !important;
}

/* لودینگ اسپینر */
.ahanak-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* نوتیفیکیشن‌های ACF */
.ahanak-form .acf-notice {
    padding: 12px 14px !important; /* ✅ کاهش پدینگ */
    border-radius: 8px !important;
    margin-bottom: 16px !important;
    font-size: clamp(13px, 2.5vw, 14px) !important; /* ✅ ریسپانسیو */
    border: none !important;
    word-break: break-word !important; /* ✅ اضافه شد */
}

.ahanak-form .acf-notice.-success {
    background: var(--success-bg) !important;
    color: var(--success) !important;
    border: 1px solid #bbf7d0 !important;
}

.ahanak-form .acf-notice.-error {
    background: var(--error-bg) !important;
    color: var(--error) !important;
    border: 1px solid #fecaca !important;
}

.ahanak-form .acf-notice p {
    margin: 0 !important;
}

/* حذف استایل‌های اضافی ACF */
.ahanak-form .acf-fields > .acf-field {
    padding: 0 !important;
}

.ahanak-form .acf-input {
    margin: 0 !important;
}

.ahanak-form .acf-input-wrap {
    margin: 0 !important;
}

/* ریسپانسیو موبایل */
@media (max-width: 640px) {
    .ahanak-form {
        gap: 1.25rem;
    }

    .ahanak-form-wrapper {
        margin: 20px auto;
        padding: 0 12px;
    }

    .ahanak-success-box .tracking-code {
        flex-direction: column;
        align-items: flex-start;
    }

    .ahanak-form .mobile-field::after {
        top: 36px;
        right: 12px;
        font-size: 16px;
    }
}

@media (max-width: 400px) {
    .ahanak-form {
        padding: 1rem;
        gap: 1rem;
    }

    .ahanak-form-wrapper {
        padding: 0 8px;
        margin: 16px auto;
    }

    .ahanak-form input[type="file"]::file-selector-button {
        font-size: 11px;
        padding: 5px 10px;
        margin-left: 6px;
    }
}

/* فوکوس Accessibility */
.ahanak-form *:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* حالت Disabled */
.ahanak-form input:disabled,
.ahanak-form textarea:disabled,
.ahanak-form select:disabled {
    background: #f1f5f9 !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

/* انیمیشن فید-این برای فرم */
.ahanak-form-wrapper {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
