/* ==========================================================================
   Persian Academic Research Survey - Professional RTL Stylesheet
   Typography: Vazirmatn (Local) + High-legibility fallbacks
   ========================================================================== */

@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/vazirmatn-400.ttf') format('truetype');
}

@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/vazirmatn-500.ttf') format('truetype');
}

@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/vazirmatn-700.ttf') format('truetype');
}

:root {
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-light: #eff6ff;
    --primary-border: #93c5fd;
    --primary-gradient: linear-gradient(135deg, #2563eb, #1d4ed8);
    
    --text-main: #0f172a;
    --text-body: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;
    --bg-input: #f8fafc;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-focus: #3b82f6;
    
    --error-color: #dc2626;
    --error-bg: #fef2f2;
    --error-border: #fca5a5;
    
    --success-color: #16a34a;
    --success-bg: #f0fdf4;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-highlight: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

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

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Tahoma, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-body);
    background-color: var(--bg-page);
    margin: 0;
    padding: 24px 16px;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Container ─────────────────────────────────────────────────────────── */
.container {
    max-width: 780px;
    margin: 0 auto 40px auto;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 32px 36px;
}

@media (max-width: 640px) {
    body {
        padding: 12px 8px;
    }
    .container {
        padding: 20px 16px;
        border-radius: var(--radius-lg);
    }
}

/* ── Academic Header ──────────────────────────────────────────────────── */
.academic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
    color: var(--text-muted);
}

.academic-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: var(--primary);
    background-color: var(--primary-light);
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.82rem;
}

/* ── Progress Indicator ───────────────────────────────────────────────── */
.progress-container {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 28px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.progress-step-pill {
    background-color: var(--primary);
    color: #ffffff;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 0.82rem;
}

.progress-bar-wrapper {
    width: 100%;
    background-color: #e2e8f0;
    border-radius: 9999px;
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

/* ── Headings & Content Typography ────────────────────────────────────── */
h1, h2, h3, h4 {
    color: var(--text-main);
    font-weight: 700;
    line-height: 1.4;
    margin-top: 0;
}

h1 {
    font-size: 1.55rem;
    margin-bottom: 20px;
}

h2 {
    font-size: 1.35rem;
    margin-bottom: 20px;
    color: var(--text-main);
}

h3 {
    font-size: 1.18rem;
    margin-bottom: 14px;
}

p {
    margin-top: 0;
    margin-bottom: 16px;
}

/* ── Instructions Banner ─────────────────────────────────────────────── */
.instruction {
    background-color: #f0f9ff;
    border-right: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 28px;
    color: #0369a1;
    font-size: 0.98rem;
    line-height: 1.8;
}

.instruction p {
    margin: 0;
}

/* ── Consent & Notice Boxes ──────────────────────────────────────────── */
.consent-box {
    background-color: #fffbeb;
    border: 1px solid #fef3c7;
    border-right: 4px solid #f59e0b;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    margin: 24px 0;
    color: #92400e;
    font-size: 0.95rem;
    line-height: 1.8;
}

.researcher-card {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin: 24px 0;
    font-size: 0.92rem;
}

.researcher-card p {
    margin-bottom: 6px;
}

.researcher-card p:last-child {
    margin-bottom: 0;
}

.researcher-card a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.researcher-card a:hover {
    text-decoration: underline;
}

/* ── Question Blocks ──────────────────────────────────────────────────── */
.question-block {
    background-color: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 24px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.question-block:hover {
    border-color: var(--border-hover);
}

.question-block.has-error {
    border-color: var(--error-border);
    background-color: #fffafb;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.question-header-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.question-number-badge {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.question-text {
    font-weight: 600;
    font-size: 1.04rem;
    color: var(--text-main);
    line-height: 1.7;
    margin: 0;
    flex-grow: 1;
}

/* ── Likert 7-Point Rating System ─────────────────────────────────────── */
.likert-wrapper {
    margin-top: 14px;
}

/* Desktop Horizontal Segmented Cards */
.likert-group {
    display: flex;
    gap: 8px;
}

.likert-option-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    min-height: 96px;
}

.likert-option-card:hover {
    background-color: var(--bg-subtle);
    border-color: var(--primary-border);
}

.likert-option-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.likert-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.likert-label-text {
    font-size: 0.80rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-body);
}

/* Selected state for Likert */
.likert-option-card.is-selected,
.likert-option-card:has(input[type="radio"]:checked) {
    background-color: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 0 0 1.5px var(--primary);
}

.likert-option-card.is-selected .likert-num,
.likert-option-card:has(input[type="radio"]:checked) .likert-num {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.likert-option-card.is-selected .likert-label-text,
.likert-option-card:has(input[type="radio"]:checked) .likert-label-text {
    color: var(--primary);
    font-weight: 700;
}

/* Mobile Likert: Stacked readable cards */
@media (max-width: 680px) {
    .likert-group {
        flex-direction: column;
        gap: 6px;
    }
    .likert-option-card {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        text-align: right;
        padding: 12px 14px;
        min-height: 48px;
    }
    .likert-num {
        margin-bottom: 0;
        margin-left: 12px;
        flex-shrink: 0;
    }
    .likert-label-text {
        font-size: 0.92rem;
    }
}

/* ── Single Choice Options (Vertical Cards) ───────────────────────────── */
.options-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.choice-option-card {
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    font-size: 0.96rem;
    color: var(--text-body);
}

.choice-option-card:hover {
    background-color: var(--bg-subtle);
    border-color: var(--primary-border);
}

.choice-option-card input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-left: 14px;
    margin-right: 0;
    flex-shrink: 0;
    background-color: #ffffff;
    display: grid;
    place-content: center;
    transition: all 0.2s ease;
}

.choice-option-card input[type="radio"]::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    background-color: var(--primary);
}

.choice-option-card input[type="radio"]:checked::before {
    transform: scale(1);
}

.choice-option-card input[type="radio"]:checked {
    border-color: var(--primary);
}

.choice-option-card.is-selected,
.choice-option-card:has(input[type="radio"]:checked) {
    background-color: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
    color: var(--text-main);
    font-weight: 600;
}

/* ── Number / Age Input (Integer Only) ─────────────────────────────────── */
.number-input-container {
    margin-top: 14px;
}

.number-input-wrapper {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px 12px;
    transition: all 0.2s ease;
}

.number-input-wrapper:focus-within {
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: var(--shadow-highlight);
}

.number-input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    width: 120px;
    padding: 8px 6px;
    text-align: center;
    outline: none;
}

.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.number-unit {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-right: 6px;
}

.input-hint {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ── Error Messages ───────────────────────────────────────────────────── */
.error-msg {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--error-color);
    font-size: 0.88rem;
    font-weight: 600;
    margin-top: 10px;
}

.error-msg::before {
    content: "⚠️";
    font-size: 0.95rem;
}

/* ── Action Buttons ───────────────────────────────────────────────────── */
.action-area {
    margin-top: 36px;
    text-align: center;
}

.btn-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

@media (max-width: 500px) {
    .btn-group {
        display: flex;
        width: 100%;
        gap: 10px;
    }
    .btn-group .btn {
        flex: 1;
        padding: 12px 14px;
        font-size: 0.94rem;
    }
}

.btn {
    background: var(--primary-gradient);
    color: #ffffff;
    border: none;
    padding: 14px 40px;
    font-family: inherit;
    font-size: 1.08rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.25), 0 2px 4px -2px rgba(37, 99, 235, 0.2);
    transition: all 0.2s ease;
    display: inline-block;
    text-decoration: none;
    user-select: none;
}

.btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px -2px rgba(37, 99, 235, 0.35);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-body);
    border: 1.5px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    border-color: var(--text-muted);
    color: var(--text-main);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:disabled {
    background: #94a3b8;
    color: #ffffff;
    border-color: transparent;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.save-notice {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin-top: 12px;
}

.btn-withdraw {
    background: none;
    color: var(--text-light);
    border: none;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.82rem;
    text-decoration: underline;
    cursor: pointer;
    margin-top: 24px;
    transition: color 0.2s ease;
}

.btn-withdraw:hover {
    color: var(--error-color);
}

/* ── Scenario Display Page (Step 3) ───────────────────────────────────── */
.scenario-intro-box {
    background-color: var(--bg-subtle);
    border-radius: var(--radius-md);
    padding: 18px 22px;
    margin-bottom: 24px;
    font-size: 0.98rem;
    line-height: 1.8;
}

.scenario-product-card {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-sm);
}

.scenario-product-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.spec-item {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.92rem;
}

.spec-key {
    color: var(--text-muted);
}

.spec-val {
    font-weight: 700;
    color: var(--text-main);
}

.scenario-image-container {
    text-align: center;
    margin-bottom: 28px;
}

.scenario-image-container img {
    max-width: 100%;
    height: auto;
    max-height: 280px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.table-responsive {
    overflow-x: auto;
    margin-bottom: 28px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: #ffffff;
}

.scenario-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 540px;
    font-size: 0.92rem;
}

.scenario-table th, .scenario-table td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.scenario-table th {
    background-color: var(--bg-subtle);
    font-weight: 700;
    color: var(--text-main);
}

.scenario-table tr:last-child td {
    border-bottom: none;
}

.highlighted-row {
    background-color: #eff6ff !important;
    font-weight: 700;
    color: var(--primary);
}


.scenario-summary {
    background: linear-gradient(135deg, #f0f7ff, #faf5ff);
    border: 1.5px solid #dbeafe;
    border-right: 5px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-sm);
}

.summary-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #ede9fe, #dbeafe);
    color: #4f46e5;
    border: 1px solid #c7d2fe;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.summary-text-p {
    font-size: 1rem;
    line-height: 1.85;
    color: var(--text-main);
    margin: 0;
}

/* ── Completion & Message Pages ───────────────────────────────────────── */
.completion-card {
    text-align: center;
    padding: 40px 20px;
}

.completion-icon {
    width: 64px;
    height: 64px;
    background-color: var(--success-bg);
    color: var(--success-color);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 20px;
}

.completion-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 14px;
}

.completion-desc {
    color: var(--text-body);
    font-size: 1.05rem;
    max-width: 520px;
    margin: 0 auto 24px auto;
}

/* ── Admin Preview Nav Bar ────────────────────────────────────────────── */
.preview-nav {
    background-color: #1e293b;
    color: #ffffff;
    padding: 12px 16px;
    margin-bottom: 24px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.preview-nav a {
    color: #93c5fd;
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.preview-nav a:hover {
    background-color: #334155;
    text-decoration: underline;
}

/* ── Print Styles ─────────────────────────────────────────────────────── */
@media print {
    body {
        background: #ffffff;
        padding: 0;
    }
    .container {
        border: none;
        box-shadow: none;
        padding: 0;
    }
    .action-area, .withdraw-form, .preview-nav {
        display: none !important;
    }
}
