/* =========================================================
   GLOBAL VARIABLES
========================================================= */
:root {
    --bg: #0A192F;
    --bg-soft: #112240;
    --primary: #1D4ED8;
    --primary-dark: #1E3A8A;
    
    --danger: #EF4444;
    --success: #10B981;
    --accent: #F59E0B;
    --accent-dark: #D97706;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 2px 6px rgba(0,0,0,.4);
    --shadow-md: 0 4px 12px rgba(245, 158, 11, .25);

    --transition: .25s ease;

    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;
    --border: rgba(29, 78, 216, 0.3);
}

/* =========================================================
   RESET & BASE
========================================================= */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    overflow-x: hidden;  /* جلوگیری از اسکرول افقی کل صفحه */
    width: 100%;
    max-width: 100vw;
}

/* =========================================================
   FORM LAYOUT - MOBILE FIRST
========================================================= */
.form-layout {
    display: grid;
    gap: 1rem;
    width: 100%;
    max-width: 100%;  /* حذف max-width ثابت */
    margin: 0 auto;
    padding: 0.75rem;
}

/* =========================================================
   PROGRESS CARD
========================================================= */
.progress-card {
    background: var(--bg-soft);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 76px;
    z-index: 100;
    width: 100%;
    overflow: hidden;  /* جلوگیری از سرریز */
}

.progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .7rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.section-badge {
    background: rgba(245, 158, 11, .15);
    color: var(--accent);
    padding: .25rem .75rem;
    font-size: .8rem;
    font-weight: 700;
    border-radius: 20px;
    border: 1px solid rgba(245, 158, 11, .3);
    white-space: nowrap;
}

.progress-percent {
    font-size: .85rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

/* =========================================================
   STEPS BAR - FULLY RESPONSIVE
========================================================= */
.steps-wrapper {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 0;
    width: 100%;
    -webkit-overflow-scrolling: touch;  /* اسکرول نرم در iOS */
}

.steps-wrapper::-webkit-scrollbar {
    display: none;
}

.step-item { 
    display: flex; 
    align-items: center; 
    flex-shrink: 0;
    min-width: fit-content;
}

.step-line {
    width: 16px;
    min-width: 16px;
    height: 2px;
    background: var(--border);
    transition: var(--transition);
    flex-shrink: 0;
}

.step-line.completed { 
    background: var(--accent); 
}

.step-circle {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
    font-size: .75rem;
    flex-shrink: 0;
}

.step-circle.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0F172A;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .25);
}

.step-circle.completed {
    background: rgba(245, 158, 11, .15);
    color: var(--accent);
    border-color: var(--accent);
}

.step-label {
    margin-top: .25rem;
    font-size: .6rem;
    text-align: center;
    max-width: 50px;
    color: var(--text-muted);
    opacity: .6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.step-label.active {
    color: var(--accent);
    opacity: 1;
    font-weight: 700;
}

.step-label.completed {
    color: var(--text-secondary);
    opacity: 1;
}

/* =========================================================
   SECTION HEADER
========================================================= */
.section-header-card {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    color: #fff;
    gap: 0.75rem;
    box-shadow: var(--shadow-md);
    width: 100%;
}

.section-num-circle {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,.2);
    border: 2px solid rgba(255,255,255,.3);
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-header-card h5 {
    font-size: 1rem;
    word-break: break-word;
}

/* =========================================================
   QUESTION CARD
========================================================= */
.question-wrapper { 
    transition: .35s ease; 
    width: 100%;
}

.hidden-question { 
    display: none !important; 
}

.question-card {
    background: var(--bg-soft);
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
    width: 100%;
}

.question-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.q-header {
    background: rgba(10, 25, 47, 0.5);
    padding: .7rem 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: nowrap;
}

.q-number {
    width: 26px;
    height: 26px;
    min-width: 26px;
    background: var(--accent);
    color: #0F172A;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
}

.q-label {
    font-weight: 600;
    color: var(--text-primary);
    flex-grow: 1;
    font-size: .9rem;
    word-break: break-word;
}

.required-star {
    color: var(--danger);
    font-weight: bold;
}

.q-body { 
    padding: 1rem; 
    width: 100%;
}

/* =========================================================
   HELP BOX
========================================================= */
.help-box {
    background: rgba(29, 78, 216, .15);
    border: 1px solid rgba(29, 78, 216, .3);
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: .78rem;
    display: flex;
    gap: .5rem;
    margin-bottom: 0.75rem;
    word-break: break-word;
}

/* =========================================================
   CHOICE ITEMS
========================================================= */
.choices-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: 100%;
}

.choice-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem .85rem;
    border-radius: var(--radius-md);
    border: 1.4px solid var(--border);
    background: rgba(10, 25, 47, 0.5);
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.choice-item:hover { 
    border-color: var(--accent);
    background: rgba(245, 158, 11, .1);
}

.choice-item:has(input:checked) {
    border-color: var(--accent);
    background: rgba(245, 158, 11, .15);
}

.choice-item input {
    width: 18px;
    height: 18px;
    min-width: 18px;
    accent-color: var(--accent);
}

.choice-label {
    flex-grow: 1;
    font-size: .85rem;
    color: var(--text-secondary);
    transition: var(--transition);
    word-break: break-word;
}

input:checked ~ .choice-label {
    color: var(--text-primary);
    font-weight: 600;
}

/* =========================================================
   BOOLEAN YES / NO BUTTONS
========================================================= */
.bool-group {
    display: grid;
    gap: .6rem;
    grid-template-columns: 1fr 1fr;
    width: 100%;
}

.bool-btn {
    padding: .8rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    background: rgba(10, 25, 47, 0.5);
    font-weight: 600;
    font-size: .9rem;
    color: var(--text-secondary);
    transition: var(--transition);
    user-select: none;
}

.bool-btn:hover {
    border-color: var(--accent);
    background: rgba(245, 158, 11, .15);
}

.yes-selected {
    border-color: var(--success);
    background: rgba(16, 185, 129, .2);
    color: var(--success);
}

.no-selected {
    border-color: var(--danger);
    background: rgba(239, 68, 68, .15);
    color: var(--danger);
}

/* =========================================================
   FORM CONTROLS
========================================================= */
.form-control {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: rgba(10, 25, 47, 0.5);
    border: 1.4px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: .65rem .85rem;
    font-size: .9rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .15);
    outline: none;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.input-group {
    width: 100%;
    display: flex;
}

.input-group .form-control {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: .65rem .85rem;
    background: var(--bg-light);
    border: 1.4px solid var(--border);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: none;
    color: var(--text-muted);
    font-size: .9rem;
}

/* =========================================================
   NAVIGATION CARD
========================================================= */
.nav-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}

.nav-info {
    font-size: .8rem;
    color: var(--text-secondary);
    display: flex;
    gap: .4rem;
    align-items: center;
    white-space: nowrap;
}

.nav-info .dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

/* =========================================================
   ERROR FEEDBACK
========================================================= */
.field-error {
    margin-top: .4rem;
    background: rgba(239, 68, 68, .15);
    padding: .4rem .7rem;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    color: var(--danger);
    display: flex;
    gap: .35rem;
    border: 1px solid rgba(239, 68, 68, .3);
    word-break: break-word;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 576px) {
    .form-layout {
        padding: 0.5rem;
        gap: 0.75rem;
    }
    
    .bool-group {
        grid-template-columns: 1fr;
    }
    
    .nav-card {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-card .btn {
        width: 100%;
        justify-content: center;
    }
    
    .q-header span[style*="font-size:.72rem"] {
        display: none;
    }
    
    .choice-item {
        padding: .55rem .7rem;
    }
    
    .choice-label {
        font-size: .8rem;
    }
}

@media (min-width: 768px) {
    .form-layout {
        padding: 1.5rem;
        max-width: 850px;
        gap: 1.5rem;
    }
    
    .progress-card {
        padding: 1.25rem 1.5rem;
    }
    
    .section-header-card {
        padding: 1.5rem 1.75rem;
    }
    
    .q-header {
        padding: .85rem 1.25rem;
    }
    
    .q-body {
        padding: 1.25rem;
    }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}


/* ==================== لایت مود ==================== */
[data-theme="light"] {
    --bg: #F8FAFC;
    --bg-soft: #FFFFFF;
    --primary: #1E40AF;
    --primary-dark: #1E3A8A;
    --accent: #1E40AF;
    --accent-dark: #1E3A8A;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --border: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(30, 64, 175, 0.15);
}

[data-theme="light"] .section-header-card {
    background: linear-gradient(135deg, #1E40AF, #1E3A8A) !important;
    color: #FFFFFF !important;
}

[data-theme="light"] .section-num-circle {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    color: #FFFFFF !important;
}

[data-theme="light"] .section-header-card h5 {
    color: #FFFFFF !important;
}

[data-theme="light"] .q-number {
    background: #1E40AF !important;
    color: #FFFFFF !important;
}

[data-theme="light"] .choice-item:has(input:checked) {
    background: rgba(30, 64, 175, 0.08) !important;
    border-color: #1E40AF !important;
}

[data-theme="light"] input:checked ~ .choice-label {
    color: #0F172A !important;
}

[data-theme="light"] .form-control {
    background: #FFFFFF !important;
    border: 1.4px solid rgba(0, 0, 0, 0.1) !important;
    color: #0F172A !important;
}

[data-theme="light"] .form-control:focus {
    border-color: #1E40AF !important;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15) !important;
}

[data-theme="light"] .step-circle.active {
    background: #1E40AF !important;
    border-color: #1E40AF !important;
    color: #FFFFFF !important;
}

[data-theme="light"] .step-circle.completed {
    background: rgba(30, 64, 175, 0.1) !important;
    color: #1E40AF !important;
    border-color: #1E40AF !important;
}

[data-theme="light"] .step-label.active {
    color: #1E40AF !important;
}

[data-theme="light"] .step-line.completed {
    background: #1E40AF !important;
}

[data-theme="light"] .section-badge {
    background: rgba(30, 64, 175, 0.1) !important;
    color: #1E40AF !important;
    border: 1px solid rgba(30, 64, 175, 0.2) !important;
}

[data-theme="light"] .bool-btn {
    background: #F8FAFC !important;
    border: 2px solid rgba(0, 0, 0, 0.08) !important;
    color: #475569 !important;
}

[data-theme="light"] .bool-btn:hover {
    background: #F1F5F9 !important;
    border-color: #1E40AF !important;
}

[data-theme="light"] .input-group-text {
    background: #F1F5F9 !important;
    border: 1.4px solid rgba(0, 0, 0, 0.08) !important;
    color: #475569 !important;
}