*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg1: #eef5ff;
    --bg2: #f7fbff;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #475569;
    --border: #e5e7eb;
    --border-2: #cbd5e1;
    --soft: #f8fafc;
    --primary: #2563eb;
    --primary-2: #0ea5e9;
    --secondary: #64748b;
    --success-bg: #ecfdf5;
    --success-text: #166534;
    --success-border: #bbf7d0;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --error-border: #fecaca;
    --shadow: 0 15px 40px rgba(15, 23, 42, 0.08);
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg1), var(--bg2));
    color: var(--text);
    line-height: 1.8;
    direction: rtl;
    text-align: right;
}

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

button,
input,
textarea,
select {
    font: inherit;
}

.page {
    max-width: 1100px;
    margin: 32px auto;
    padding: 16px;
}

.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
}

.hero h1 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.5;
}

.hero p {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 15px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--soft);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin: 18px 0;
    word-break: break-word;
}

.alert.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.alert.error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.progress-wrap {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin: 20px 0 24px;
}

.progress-bar {
    height: 100%;
    width: 25%;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
    transition: width 0.3s ease;
}

.step {
    display: none;
}

.step.active {
    display: block;
}

.grid.two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.8;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
    resize: vertical;
    min-height: 110px;
}

.choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.choice-group label,
.scale-item {
    background: var(--soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.choice-group label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    min-height: 44px;
}

.question-list {
    display: grid;
    gap: 16px;
}

.question-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    background: #fcfdff;
}

.question-title {
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.9;
}

.scale-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.scale-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    min-height: 88px;
    justify-content: center;
    transition: 0.2s ease;
}

.scale-item small {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}

/* رادیوباتن سفارشی */
.choice-group input[type="radio"],
.scale-item input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #64748b;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    position: relative;
    margin: 0;
    flex-shrink: 0;
}

.choice-group input[type="radio"]:checked,
.scale-item input[type="radio"]:checked {
    border-color: var(--primary);
    background: var(--primary);
}

.choice-group input[type="radio"]:checked::after,
.scale-item input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    inset: 4px;
    background: #fff;
    border-radius: 50%;
}

.scale-item:has(input[type="radio"]:checked),
.choice-group label:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: #eff6ff;
}

/* اگر :has در بعضی مرورگرها کار نکرد، مشکلی برای عملکرد اصلی پیش نمی‌آید */

.actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
}

.btn,
button,
input[type="submit"] {
    border: none;
    background: var(--primary);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    min-height: 46px;
    transition: transform 0.15s ease, opacity 0.2s ease, background 0.2s ease;
    touch-action: manipulation;
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
    opacity: 0.96;
}

.btn:active,
button:active,
input[type="submit"]:active {
    transform: scale(0.98);
}

.btn.secondary {
    background: var(--secondary);
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    min-width: 700px;
}

th,
td {
    border: 1px solid var(--border);
    padding: 10px;
    text-align: right;
    vertical-align: top;
    font-size: 14px;
    line-height: 1.8;
}

th {
    background: var(--soft);
    white-space: nowrap;
}

.admin-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    background: #e0f2fe;
    color: #075985;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
}

.link-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0f766e;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    min-height: 42px;
}

.link-btn.gray {
    background: #475569;
}

.auth-box {
    max-width: 420px;
    margin: 60px auto;
}

/* ---------- تبلت ---------- */
@media (max-width: 992px) {
    .page {
        max-width: 100%;
        padding: 14px;
    }

    .card {
        padding: 20px;
        border-radius: 18px;
    }

    .hero h1 {
        font-size: 24px;
    }

    .scale-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ---------- موبایل ---------- */
@media (max-width: 768px) {
    body {
        line-height: 1.9;
    }

    .page {
        margin: 16px auto;
        padding: 10px;
    }

    .card {
        padding: 16px;
        border-radius: 16px;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    }

    .hero h1 {
        font-size: 22px;
        line-height: 1.7;
    }

    .hero p {
        font-size: 14px;
        margin-bottom: 14px;
    }

    .legend {
        gap: 8px;
        padding: 10px;
        font-size: 13px;
    }

    .grid.two {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .field {
        margin-bottom: 16px;
    }

    .field label {
        font-size: 14px;
        margin-bottom: 6px;
    }

    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        padding: 12px;
        font-size: 16px; /* جلوگیری از زوم آیفون */
        border-radius: 10px;
    }

    textarea {
        min-height: 100px;
    }

    .question-card {
        padding: 14px;
        border-radius: 14px;
    }

    .question-title {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .choice-group {
        flex-direction: column;
        gap: 10px;
    }

    .choice-group label {
        width: 100%;
        padding: 12px;
        border-radius: 10px;
        justify-content: flex-start;
    }

    .scale-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .scale-item {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        text-align: right;
        min-height: auto;
        padding: 12px;
        gap: 10px;
        border-radius: 10px;
    }

    .scale-item small {
        font-size: 13px;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn,
    .actions button,
    .actions input[type="submit"],
    .link-btn {
        width: 100%;
    }

    .btn,
    button,
    input[type="submit"] {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 15px;
    }

    .admin-actions {
        flex-direction: column;
    }

    .admin-actions > * {
        width: 100%;
    }

    .table-wrap {
        margin-top: 12px;
    }

    table {
        min-width: 640px;
    }

    th,
    td {
        font-size: 13px;
        padding: 8px;
    }

    .alert {
        font-size: 14px;
        padding: 12px 14px;
    }

    .auth-box {
        max-width: 100%;
        margin: 24px auto;
    }
}

/* ---------- موبایل خیلی کوچک ---------- */
@media (max-width: 480px) {
    .page {
        padding: 8px;
    }

    .card {
        padding: 14px;
    }

    .hero h1 {
        font-size: 20px;
    }

    .hero p,
    .question-title,
    .field label {
        font-size: 13px;
    }

    .legend {
        font-size: 12px;
    }

    .btn,
    button,
    input[type="submit"],
    .link-btn {
        font-size: 14px;
    }

    .badge {
        font-size: 11px;
    }
}
