@import url('https://cdnjs.cloudflare.com/ajax/libs/vazirmatn/33.0.3/Vazirmatn-font-face.css');

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-800: #1f2937;
    --radius: 10px;
    /* Force light form-control rendering regardless of the OS/browser dark-mode
       preference. Without this, native <select> dropdown popups can inherit a
       dark system palette while our own CSS still requests dark text - result:
       unreadable "light text on light background" or "dark text on dark bg". */
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img { max-width: 100%; height: auto; }

body {
    font-family: var(--app-font-family, 'Vazirmatn', Tahoma, sans-serif);
    background: var(--gray-50);
    color: var(--gray-800);
    margin: 0;
    line-height: 1.8;
}

.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 18px 0;
}
.site-title { font-weight: 700; font-size: 18px; }

.site-footer {
    text-align: center;
    color: var(--gray-400);
    font-size: 13px;
    padding: 30px 0;
}

main.container { padding-top: 32px; padding-bottom: 32px; }

.form-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    padding: 28px;
    max-width: 100%;
    overflow-wrap: break-word;
}

.form-title { font-size: 22px; margin: 0 0 8px; }
.form-logo { margin-bottom: 16px; }
.form-logo img { display: inline-block; }
.form-description { color: var(--gray-600); margin: 0 0 24px; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1 1 220px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.required { color: var(--danger); }

.form-control {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    color: var(--gray-800);
    background-color: #fff;
    transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }

/* Explicitly light-styled native <select>/<option>/<optgroup>.
   `color-scheme: light` on :root alone is NOT reliably honored by every
   Chrome/Edge version for the native dropdown POPUP specifically when the
   OS is in dark mode (long-standing browser quirk) - repeating it directly
   on the <select> itself, plus !important on the option colors, is the
   standard, cross-browser-reliable fix. !important is used here only
   because native OS dark-mode styling otherwise wins over normal-specificity
   author CSS for this one, well-documented case. */
select.form-control {
    color-scheme: light;
}
select.form-control option,
select.form-control optgroup {
    color: var(--gray-800) !important;
    background-color: #fff !important;
}

textarea.form-control { resize: vertical; }

.form-radio-group, .form-checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.form-radio, .form-checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }

.help-text { font-size: 13px; color: var(--gray-400); margin: 6px 0 0; }
.field-error { font-size: 13px; color: var(--danger); margin: 6px 0 0; }
.has-error .form-control, .has-error-js .form-control { border-color: var(--danger); }

.hp-field { position: absolute; left: -9999px; top: -9999px; }

.form-nav { display: flex; gap: 10px; margin-top: 24px; }

.btn {
    display: inline-block;
    padding: 11px 22px;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; }
.alert p { margin: 0; }
.alert-error { background: #fef2f2; color: var(--danger); }
.alert-success { background: #f0fdf4; color: var(--success); }

.step-progress { display: flex; justify-content: space-between; margin-bottom: 28px; }
.step-dot { flex: 1; text-align: center; color: var(--gray-400); font-size: 13px; position: relative; }
.step-dot .step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%; background: var(--gray-200);
    color: #fff; font-weight: 700; margin-bottom: 6px;
}
.step-dot.active .step-num { background: var(--primary); }
.step-dot .step-label { display: block; }

.success-card { text-align: center; }
.success-icon {
    width: 64px; height: 64px; border-radius: 50%; background: #f0fdf4; color: var(--success);
    font-size: 32px; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px;
}
.tracking-box { background: var(--gray-50); border-radius: 8px; padding: 18px; margin: 20px 0; }
.tracking-code { font-size: 24px; font-weight: 700; letter-spacing: 1px; direction: ltr; margin-bottom: 12px; }

.status-badge { color: #fff; padding: 4px 10px; border-radius: 999px; font-size: 13px; }

/* --- Icons (question-level and option-level) --- */
.field-icon { vertical-align: -3px; margin-inline-end: 4px; }
.form-radio .field-icon, .form-checkbox .field-icon { margin-inline-start: 2px; }

/* --- Rating (stars) --- */
.rating-field { display: inline-flex; flex-direction: row-reverse; gap: 4px; font-size: 28px; }
.rating-field input { position: absolute; opacity: 0; width: 0; height: 0; }
.rating-field label { color: var(--gray-200); cursor: pointer; line-height: 1; transition: color .1s; }
.rating-field input:checked ~ label,
.rating-field label:hover,
.rating-field label:hover ~ label { color: #f59e0b; }

/* --- Scale (numeric) --- */
.scale-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.scale-option { position: relative; }
.scale-option input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.scale-option span {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--gray-200);
    font-weight: 600; transition: background .1s, color .1s;
}
.scale-option input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.scale-caption { display: flex; justify-content: space-between; font-size: 12px; color: var(--gray-400); margin-top: 6px; }

/* --- Matrix (grid question) --- */
.matrix-field-wrap { overflow-x: auto; }
.matrix-field { border-collapse: collapse; width: 100%; font-size: 14px; }
.matrix-field th, .matrix-field td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--gray-100); }
.matrix-row-label { text-align: right !important; font-weight: 600; white-space: nowrap; }

@media (max-width: 600px) {
    .form-card { padding: 20px; border-radius: 0; }
    .container { padding: 0 12px; }
    .step-dot .step-label { display: none; }
}
