/* ---------- ธีมหลักของระบบแบบสอบถาม ---------- */
:root {
    --brand: #1b5e9e;
    --brand-dark: #144a7d;
    --brand-soft: #eaf2fb;
}

body {
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
    background: #f2f5f9;
    color: #212529;
}

.navbar-brand-app { font-weight: 600; letter-spacing: .2px; }

.bg-brand { background-color: var(--brand) !important; }
.text-brand { color: var(--brand) !important; }
.btn-brand {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-brand:hover, .btn-brand:focus {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}

.survey-header {
    background: linear-gradient(135deg, var(--brand) 0%, #2a86d6 100%);
    color: #fff;
    border-radius: .75rem;
}

.section-title {
    background: var(--brand-soft);
    border-left: 5px solid var(--brand);
    padding: .65rem 1rem;
    border-radius: .35rem;
    font-weight: 600;
    color: var(--brand-dark);
}

.q-text { line-height: 1.65; }

/* ตารางให้คะแนน */
.rating-table th { vertical-align: middle; text-align: center; }
.rating-table td.q-cell { min-width: 260px; }
.rating-table td.score-cell { text-align: center; vertical-align: middle; width: 84px; }
.rating-table input[type="radio"] { width: 1.2rem; height: 1.2rem; cursor: pointer; }
.rating-table tbody tr:hover { background: #f8fbff; }
.rating-table tr.is-invalid-row { background: #fff2f2 !important; }

/* มุมมองมือถือ: แสดงเป็นการ์ดแทนตาราง */
.rating-card .form-check-label { cursor: pointer; }

.card-stat .display-6 { font-weight: 700; }

.table-sm td, .table-sm th { padding: .45rem .5rem; }

.required::after { content: " *"; color: #dc3545; }

footer.app-footer {
    font-size: .875rem;
    color: #6c757d;
}

@media print {
    .no-print, .navbar, footer.app-footer { display: none !important; }
    body { background: #fff; }
    .card { border: 1px solid #dee2e6 !important; box-shadow: none !important; }
    a[href]::after { content: none !important; }
}

/* ---------- รายการให้คะแนนแบบตอบสนองทุกขนาดจอ ---------- */
.rating-head {
    background: var(--brand);
    color: #fff;
    border-radius: .5rem .5rem 0 0;
    font-weight: 600;
    padding: .6rem .75rem;
}
.rating-item {
    border: 1px solid #e3e8ef;
    border-top: none;
    padding: .85rem .75rem;
    margin: 0;
    background: #fff;
}
.rating-item:first-of-type { border-top: 1px solid #e3e8ef; }
.rating-list .rating-item:last-child { border-radius: 0 0 .5rem .5rem; }
.rating-item:hover { background: #f8fbff; }
.rating-item.is-missing { background: #fff3f3; border-color: #f1aeb5; }
.rating-opt { text-align: center; }
.rating-opt input[type="radio"] {
    width: 1.35rem; height: 1.35rem; cursor: pointer; margin: 0 auto;
    display: block; float: none;
}
.rating-opt label { cursor: pointer; display: block; margin-top: .2rem; }
.rating-qno {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.75rem; height: 1.75rem; border-radius: 50%;
    background: var(--brand-soft); color: var(--brand-dark);
    font-weight: 600; font-size: .85rem; margin-right: .4rem;
}

/* ---------- ปุ่มชิป (Chip) สำหรับตัวเลือกส่วนที่ 1 ---------- */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.chip-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 1.05rem;
    border: 1.5px solid #d3dbe6;
    border-radius: 999px;
    background: #fff;
    color: #33404f;
    cursor: pointer;
    line-height: 1.5;
    transition: all .15s ease;
    user-select: none;
}
.chip:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.chip-input:checked + .chip {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(27, 94, 158, .28);
}
.chip-input:checked + .chip::before {
    content: "\2713";                      /* เครื่องหมายถูก */
    font-size: .9rem;
    line-height: 1;
}
.chip-input:focus-visible + .chip { outline: 3px solid rgba(27, 94, 158, .35); outline-offset: 2px; }
.chip-group.is-invalid .chip { border-color: #dc3545; }

/* ---------- ตัวบอกขั้นตอน (Stepper) ---------- */
.wizard-nav { background: #fff; border-radius: .75rem; padding: 1rem 1rem .75rem; }
.wizard-steps {
    display: flex;
    list-style: none;
    margin: 0 0 .85rem;
    padding: 0;
    gap: .25rem;
}
.wizard-steps li {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    text-align: center;
    color: #97a2b0;
    font-size: .8rem;
    position: relative;
}
.wizard-steps li .num {
    width: 2rem; height: 2rem;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: #eef1f5; color: #8b96a5;
    font-weight: 700;
    border: 2px solid transparent;
    transition: all .2s ease;
}
.wizard-steps li::after {
    content: "";
    position: absolute;
    top: 1rem; left: calc(50% + 1.35rem); right: calc(-50% + 1.35rem);
    height: 2px; background: #e5e9ef;
}
.wizard-steps li:last-child::after { display: none; }
.wizard-steps li.is-active { color: var(--brand-dark); font-weight: 600; }
.wizard-steps li.is-active .num { background: var(--brand); color: #fff; }
.wizard-steps li.is-done { color: #2f7d5f; }
.wizard-steps li.is-done .num { background: #d7f0e4; color: #2f7d5f; }
.wizard-steps li.is-done::after { background: #9fd9be; }
.wizard-progress { height: 6px; border-radius: 999px; }

.wizard-step[hidden] { display: none !important; }

@media (max-width: 575.98px) {
    .wizard-steps li .lbl { display: none; }
    .wizard-steps li::after { top: 1rem; left: calc(50% + 1.2rem); right: calc(-50% + 1.2rem); }
}

/* ---------- ปุ่มควบคุมขั้นตอน ---------- */
/* มือถือ : ตัวนับอยู่บนสุดกึ่งกลาง ปุ่มเรียงเป็นแถวเดียวเต็มความกว้าง */
.wizard-controls {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.wizard-counter {
    order: -1;
    text-align: center;
    color: #6c757d;
    font-size: .875rem;
}
.wizard-actions {
    display: flex;
    gap: .6rem;
    width: 100%;
}
.wizard-actions .btn {
    flex: 1 1 0;
    white-space: nowrap;
    padding-left: .75rem;
    padding-right: .75rem;
}
.wizard-actions #btnPrev { flex: 0 1 40%; }

/* จอตั้งแต่แท็บเล็ตขึ้นไป : ตัวนับชิดซ้าย ปุ่มชิดขวาตามความกว้างข้อความ */
@media (min-width: 576px) {
    .wizard-controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }
    .wizard-counter { order: 0; text-align: left; }
    .wizard-actions { width: auto; margin-left: auto; }
    .wizard-actions .btn { flex: 0 0 auto; padding-left: 2rem; padding-right: 2rem; }
    .wizard-actions #btnPrev { flex: 0 0 auto; padding-left: 1.5rem; padding-right: 1.5rem; }
}
