/*
 * Progress components — สกัดจาก _reference/orgcare360_design_system_preview_v4_motion_progress_standalone.html
 * (ส่วน "Motion, sliders and progress preview v4" บรรทัดเดียวที่ minified — แยก selector
 * เฉพาะกลุ่ม progress/spinner/skeleton ออกมา) ต้องโหลดหลัง tokens.css
 * ใช้ --motion-speed (ประกาศไว้ใน tokens.css) เป็นตัวคูณความเร็ว animation — ถ้าต้องการ slow-motion
 * demo ให้ตั้งค่านี้ใน scope ที่ต้องการแทนการแก้ keyframe duration ตรงๆ
 */

.progress-stack { display: grid; gap: 14px; }
.oc-progress-row { display: grid; gap: 6px; }
.oc-progress-row > div:first-child, .job-meta, .capacity-progress > div:first-child { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.oc-progress { height: 9px; border-radius: 999px; background: var(--surface-muted); border: 1px solid var(--border); overflow: hidden; position: relative; }
.oc-progress > i { display: block; width: var(--value, 0%); height: 100%; background: var(--primary); border-radius: inherit; transition: width calc(260ms * var(--motion-speed)) ease; }
.oc-progress.success > i, .oc-progress-row.success .oc-progress > i { background: var(--success); }
.oc-progress.warning > i, .oc-progress-row.warning .oc-progress > i { background: var(--warning); }
.oc-progress.danger > i, .oc-progress-row.danger .oc-progress > i { background: var(--danger); }
.oc-progress.paused > i { background: var(--muted); }
.oc-progress.disabled { opacity: .42; }
.oc-progress.indeterminate > i { width: 34%; position: absolute; animation: oc-progress-indeterminate calc(1.25s * var(--motion-speed)) ease-in-out infinite; }
.inline-processing { display: flex; align-items: center; gap: 11px; margin-top: 16px; }
.inline-processing div { display: grid; gap: 2px; }
.inline-processing small { color: var(--muted); }
@keyframes oc-progress-indeterminate { 0% { left: -38%; } 100% { left: 104%; } }

.segmented-progress { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin: 14px 0 10px; }
.segmented-progress i { height: 10px; border-radius: 999px; background: var(--surface-muted); border: 1px solid var(--border); }
.segmented-progress i.done { background: var(--success); border-color: var(--success); }
.segmented-progress i.current { background: var(--primary); border-color: var(--primary); animation: oc-pulse calc(1.4s * var(--motion-speed)) ease-in-out infinite; }

.stacked-progress { display: flex; height: 14px; overflow: hidden; border-radius: 999px; background: var(--surface-muted); border: 1px solid var(--border); }
.stacked-progress > i { width: var(--value); height: 100%; }
.stacked-progress .success, .stacked-legend i.success { background: var(--success); }
.stacked-progress .info, .stacked-legend i.info { background: var(--primary); }
.stacked-progress .warning, .stacked-legend i.warning { background: var(--warning); }
.stacked-progress .danger, .stacked-legend i.danger { background: var(--danger); }
.stacked-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; font-size: 10px; color: var(--muted); }
.stacked-legend span { display: flex; align-items: center; gap: 5px; }
.stacked-legend i { width: 8px; height: 8px; border-radius: 2px; }

.circle-progress-set { display: flex; justify-content: space-around; gap: 14px; flex-wrap: wrap; }
.circle-progress { width: 92px; height: 112px; position: relative; display: grid; place-items: center; align-content: start; }
.circle-progress svg { width: 82px; height: 82px; transform: rotate(-90deg); }
.circle-progress circle { fill: none; stroke: var(--surface-muted); stroke-width: 5; }
.circle-progress circle.value { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: calc(113.1 - (113.1 * var(--progress, 0) / 100)); transition: stroke-dashoffset calc(500ms * var(--motion-speed)) ease; }
.circle-progress.success circle.value { stroke: var(--success); }
.circle-progress.warning circle.value { stroke: var(--warning); }
.circle-progress strong { position: absolute; top: 29px; font-size: 16px; }
.circle-progress small { font-size: 10px; color: var(--muted); margin-top: -4px; }
.circle-progress.small { width: 68px; height: 68px; }
.circle-progress.small svg { width: 64px; height: 64px; }
.circle-progress.small strong { top: 23px; font-size: 12px; }

.upload-progress-list { display: grid; gap: 10px; }
.upload-progress-list article { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); }
.upload-progress-list article > div { display: grid; gap: 6px; min-width: 0; }
.upload-progress-list small { color: var(--muted); }
.file-type { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 10px; font-weight: 800; }

.job-progress { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.job-icon { width: 48px; height: 48px; border-radius: 13px; background: var(--primary-soft); display: grid; place-items: center; }
.job-progress > div:last-child { display: grid; gap: 7px; }
.job-progress small, .job-meta { color: var(--muted); }

.sync-queue { display: grid; gap: 10px; margin-bottom: 14px; }
.sync-queue > div { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.sync-queue small { color: var(--muted); }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.sync-dot.success { background: var(--success); }
.sync-dot.active { background: var(--primary); animation: oc-pulse calc(1.2s * var(--motion-speed)) infinite; }
.sync-dot.pending { background: var(--warning); }

.step-progress { list-style: none; padding: 0; margin: 12px 0 0; }
.step-progress.horizontal { display: grid; grid-template-columns: repeat(5, 1fr); }
.step-progress.horizontal li { position: relative; display: grid; justify-items: center; text-align: center; gap: 7px; }
.step-progress.horizontal li:not(:last-child):after { content: ""; position: absolute; top: 16px; left: calc(50% + 18px); right: calc(-50% + 18px); height: 2px; background: var(--border); }
.step-progress.horizontal li.done:not(:last-child):after { background: var(--success); }
.step-progress li > i { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-muted); border: 2px solid var(--border); font-style: normal; font-weight: 700; z-index: 1; }
.step-progress li.done > i { background: var(--success); border-color: var(--success); color: #fff; }
.step-progress li.current > i { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 5px var(--primary-soft); }
.step-progress li div { display: grid; gap: 2px; }
.step-progress li strong { font-size: 12px; }
.step-progress li small { font-size: 10px; color: var(--muted); }
.step-progress.vertical { display: grid; gap: 0; }
.step-progress.vertical li { display: grid; grid-template-columns: auto 1fr; gap: 11px; position: relative; padding-bottom: 20px; }
.step-progress.vertical li:not(:last-child):after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--border); }
.step-progress.vertical li.done:not(:last-child):after { background: var(--success); }

.checklist-progress-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.checklist-progress-head > div:last-child { display: grid; gap: 3px; }
.checklist-progress-head small { color: var(--muted); }
.mini-checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; font-size: 12px; }
.mini-checklist li:before { content: "○"; margin-right: 7px; color: var(--muted); }
.mini-checklist li.done:before { content: "✓"; color: var(--success); font-weight: 800; }

.capacity-progress { display: grid; gap: 8px; margin-bottom: 16px; }
.capacity-track { height: 12px; border: 1px solid var(--border); background: var(--surface-muted); border-radius: 999px; position: relative; overflow: hidden; }
.capacity-track i { display: block; width: var(--value); height: 100%; background: var(--primary); }
.capacity-track.warning i { background: var(--warning); }
.capacity-track b { position: absolute; left: var(--position); top: -3px; bottom: -3px; width: 2px; background: var(--danger); }
.capacity-progress small { color: var(--muted); }

.loader-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 15px; }
.loader-grid > div { min-height: 78px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); display: grid; place-items: center; align-content: center; gap: 8px; }
.loader-grid small { color: var(--muted); }

.spinner { display: inline-flex; align-items: center; justify-content: center; }
.spinner.ring { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: oc-spin calc(.8s * var(--motion-speed)) linear infinite; }
.spinner.ring.small { width: 16px; height: 16px; border-width: 2px; }
.spinner.dots { gap: 3px; }
.spinner.dots i { width: 6px; height: 6px; background: var(--primary); border-radius: 50%; animation: oc-dot calc(1s * var(--motion-speed)) ease-in-out infinite; }
.spinner.dots i:nth-child(2) { animation-delay: calc(.12s * var(--motion-speed)); }
.spinner.dots i:nth-child(3) { animation-delay: calc(.24s * var(--motion-speed)); }
.spinner.bars { height: 24px; gap: 3px; }
.spinner.bars i { width: 4px; height: 12px; border-radius: 3px; background: var(--primary); animation: oc-bar calc(.9s * var(--motion-speed)) ease-in-out infinite; }
.spinner.bars i:nth-child(2) { animation-delay: .1s; }
.spinner.bars i:nth-child(3) { animation-delay: .2s; }
.spinner.bars i:nth-child(4) { animation-delay: .3s; }
.spinner.pulse { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); animation: oc-pulse calc(1.1s * var(--motion-speed)) ease-in-out infinite; }
.loading-btn { gap: 8px; pointer-events: none; }

.motion-skeleton { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: var(--surface-muted); }
.motion-skeleton span, .motion-skeleton i { display: block; background: var(--border); border-radius: 6px; animation: oc-skeleton calc(1.15s * var(--motion-speed)) ease-in-out infinite; }
.motion-skeleton.list { display: grid; grid-template-columns: 40px 1fr; gap: 10px; }
.motion-skeleton.list > i { width: 40px; height: 40px; border-radius: 50%; }
.motion-skeleton.list > div { display: grid; gap: 6px; }
.motion-skeleton.list span { height: 8px; }
.motion-skeleton.card { display: grid; gap: 7px; }
.motion-skeleton.card .media { height: 50px; }
.motion-skeleton.card span { height: 8px; }
.motion-skeleton.card .short { width: 62%; }
.motion-skeleton.table { display: grid; gap: 6px; }
.motion-skeleton.table span { height: 16px; }

/* ใช้ร่วมกันได้ทั้ง progress state matrix และ slider state matrix (sliders.css) */
.progress-state-matrix, .slider-state-matrix { display: grid; gap: 11px; }
.progress-state-matrix > div, .slider-state-matrix label { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 9px; font-size: 11px; }

/* Label chip เล็กๆ แสดง component ID — ใช้ร่วมกันในหัวการ์ดของ progress/sliders/carousels demo */
.component-id { font-size: 10px; letter-spacing: .08em; font-weight: 700; color: var(--primary); }

@keyframes oc-spin { to { transform: rotate(360deg); } }
@keyframes oc-dot { 0%, 100% { transform: translateY(0); opacity: .35; } 50% { transform: translateY(-5px); opacity: 1; } }
@keyframes oc-bar { 0%, 100% { height: 9px; opacity: .45; } 50% { height: 24px; opacity: 1; } }
@keyframes oc-pulse { 0%, 100% { opacity: .45; transform: scale(.92); } 50% { opacity: 1; transform: scale(1); } }
@keyframes oc-skeleton { 0%, 100% { opacity: .45; } 50% { opacity: .9; } }
