/* ========================================
   치과·기공소 공용 스타일 (dental.css)
   base_layout 이 모든 화면에 싣는다 — 치과 화면(dental_layout, body.dental-page)과 기공소 화면(menu_layout, Phoenix)이 함께 쓴다.
   그래서 전역 선택자(#id, 일반 태그)를 쓰지 않는다. 치과 화면 전용 규칙은 .dental-page 아래에 둔다.
   치과 화면만 쓰는 부품(버튼·입력·붙은 선택·상단 바)은 dental_layout <style> 에, 두 쪽이 같이 쓰는 부품
   (치아 차트·치식 칩·상태 태그·태그 칩)은 여기 한 곳에만 둔다.
   ======================================== */

/* 색 토큰 — 치과 로즈·중립·오류. 새 규칙은 값 대신 이 이름을 쓴다 */
:root {
    --dental-brand: #963f4b;
    --dental-brand-dark: #873744;
    --dental-brand-light: #f7ecee;
    --dental-brand-hover: #efdadf;
    --dental-brand-subtle: #faf3f4;
    --dental-brand-border: #dec5ca;
    --dental-focus: #ad6672;
    --dental-border: #d0d4dc;
    --dental-border-strong: #aeb4bf;
    --dental-input-border: #7c8492;
    --dental-text: #18181b;
    --dental-muted: #71717a;
    --dental-danger: #b91c1c;          /* 위험 동작 버튼·필수 표시 */
    --dental-error-text: #9b3036;      /* 오류 문구·알림 글자 (바탕 --dental-error-bg) */
    --dental-error-bg: #fff1f0;
}

/* ===== 치아 차트 =====
   static/assets/js/tooth-chart.js(EDSToothChart)와 짝이다. 색·글자 크기·선 굵기는 여기 한 곳에서만 정한다(모듈은 클래스만 낸다).
   선택은 '데이터'라 브랜드 로즈를 쓰지 않는다 — 치과 차팅에서 빨강은 충치·치료 필요, 분홍은 잇몸으로 읽힌다.
   치과·기공소 공통 슬레이트 블루. 모드: .tooth-chart-svg.is-select(고르기) / .tooth-chart-svg.is-view(읽기 전용 확대) / .tooth-chart-mini.is-mini(썸네일).
   hover·포인터·초점은 .is-select 에만 — 읽기 전용 차트가 눌러지는 것처럼 보이지 않게. */
.tooth-chart-wrap {
    width: 100%;
}

.tooth-chart-svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 700px;               /* 넓은 창에서 끝없이 커지지 않게 (700px 에서 번호 12.4px) */
    margin: 0;                      /* 왼쪽 정렬 — 위 라벨·아래 셀렉트와 같은 왼쪽 모서리(가운데 두면 폼 열에서 혼자 떠 보인다).
                                       700px 이면 오른쪽 끝이 쉐이드 칩 줄 끝과 맞는다 */
    overflow: visible;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tooth-chart-svg.is-split {
    max-width: 420px;               /* 휴대폰 반쪽 두 장 — 한 칸 24px 이상, 번호 10px 이상 */
}

.tooth-chart-svg.is-view {
    max-width: 860px;               /* 확대 모달은 작성 화면보다 크게 */
}

/* 고르기 차트를 감싼 칸 — 끌기를 시작할 수 있는 곳이 보이게 연한 판(2026-11-07). 판 어디서 눌러도 끌기가 시작된다.
   점선이 아니라 실선 — 같은 화면의 파일 놓는 곳이 점선이라, 점선이면 '여기에 파일을 놓으라'로 읽힌다. 차트는 판 가운데 */
.tooth-chart-wrap:has(> .tooth-chart-svg.is-select) {
    padding: 12px 16px;
    background: #f8f9fb;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    touch-action: pan-y;
    touch-action: pan-y pinch-zoom;
}

.tooth-chart-wrap > .tooth-chart-svg.is-select {
    margin: 0 auto;
}

/* 고르기 차트 — 누른 채 끌면 지나간 치아를 함께 고른다(tooth-chart.js 의 '끌어서 여러 치아 고르기').
   터치: 가로로 끌면 고르고 세로로 밀면 화면이 스크롤된다(손가락이 차트 위에서 시작해도 화면을 내릴 수 있게).
   핀치 확대를 모르는 브라우저는 둘째 줄을 버리고 첫 줄을 쓴다 */
.tooth-chart-svg.is-select {
    touch-action: pan-y;
    touch-action: pan-y pinch-zoom;
    -webkit-touch-callout: none;    /* iOS 길게 누르기 메뉴가 끌기를 끊지 않게 */
}

.tooth-chart-svg text,
.tooth-chart-mini text {
    font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* 치관·치근 — 비선택 */
.tooth-chart-svg .tooth-crown,
.tooth-chart-mini .tooth-crown {
    fill: #f7f8fa;
    stroke: #b9bfc9;
    stroke-width: 1;
    stroke-linejoin: round;
}

.tooth-chart-svg .tooth-root {
    fill: #eceef2;
    stroke: #b9bfc9;
    stroke-width: 1;
    stroke-linejoin: round;
}

/* 선택 */
.tooth-chart-svg .tooth-g.selected .tooth-crown,
.tooth-chart-mini .tooth-g.selected .tooth-crown {
    fill: #6f92bb;
    stroke: #3e5d7d;
}

.tooth-chart-svg .tooth-g.selected .tooth-root {
    fill: #5a7ea8;
    stroke: #3e5d7d;
}

/* FDI 번호 — 자기 띠에만 있다(tooth-chart.js 배치가 10.5px 기준). 숫자 폭을 같게 */
.tooth-chart-svg .tooth-label {
    font-size: 10.5px;
    font-weight: 600;
    fill: #6b7280;
    text-anchor: middle;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

.tooth-chart-svg .tooth-g.selected .tooth-label {
    fill: #2f4a66;
    font-weight: 700;
}

/* 누름·초점 칸 — 칸 전체(번호 포함). 보이지 않지만 눌린다(fill 이 none 이면 눌리지 않는다) */
.tooth-chart-svg .tooth-hit {
    fill: transparent;
    stroke: none;
}

.tooth-chart-svg.is-select .tooth-g {
    cursor: pointer;
    outline: none;
}

.tooth-chart-svg.is-select .tooth-g .tooth-crown,
.tooth-chart-svg.is-select .tooth-g .tooth-root {
    transition: fill 0.15s ease, stroke 0.15s ease;
}

/* 키보드 초점 — 칸 테두리. 화면 배율과 상관없이 2px */
.tooth-chart-svg.is-select .tooth-g:focus-visible .tooth-hit {
    fill: rgba(62, 93, 125, 0.06);
    stroke: #3e5d7d;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

/* hover 는 마우스가 있는 기기에서만 — 터치 기기에서 해제한 치아가 연파랑으로 남지 않게 */
@media (hover: hover) {
    .tooth-chart-svg.is-select .tooth-g:hover .tooth-crown {
        fill: #e4ebf3;
        stroke: #7f9cbf;
    }

    .tooth-chart-svg.is-select .tooth-g:hover .tooth-root {
        fill: #d7e1ed;
        stroke: #7f9cbf;
    }

    /* 선택된 치아 위에서도 반응한다 — 다시 누르면 해제된다는 신호 */
    .tooth-chart-svg.is-select .tooth-g.selected:hover .tooth-crown {
        fill: #5b80ab;
        stroke: #2f4a66;
    }

    .tooth-chart-svg.is-select .tooth-g.selected:hover .tooth-root {
        fill: #4a6e98;
        stroke: #2f4a66;
    }
}

/* 정중선·상하악 분리선 */
.tooth-chart-midline {
    stroke: #c3c8d1;
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
}

.tooth-chart-jawline {
    stroke: #d0d4dc;
    stroke-width: 1;
}

/* 상악/하악, 'R·L = 환자 기준', R/L 글자 */
.jaw-label {
    font-size: 10px;
    font-weight: 600;
    fill: #71717a;
    pointer-events: none;
}

.tooth-chart-legend {
    font-size: 10px;
    font-weight: 500;
    fill: #71717a;
    pointer-events: none;
}

.tooth-chart-side {
    font-size: 11px;
    font-weight: 700;
    fill: #3e5d7d;
    text-anchor: middle;
}

/* 휴대폰 반쪽 두 장은 거의 1:1 로 그려진다 — 안내·상하악 글자를 한 단계 키운다(12px·11px) */
.tooth-chart-svg.is-split .tooth-chart-legend {
    font-size: 12px;
}

.tooth-chart-svg.is-split .jaw-label {
    font-size: 11px;
}

/* 썸네일(상세 화면) — 폭을 고정하지 않는다. 모든 요소가 클릭을 감싼 요소(확대 버튼)로 넘긴다 */
.tooth-chart-mini {
    display: block;
    width: 100%;
    max-width: 320px;
    height: auto;
    overflow: visible;
    pointer-events: none;
}

.tooth-chart-mini * {
    pointer-events: none;
}

.tooth-chart-mini .tooth-chart-midline {
    stroke-width: 1;
    stroke-dasharray: 3 2;
}

.tooth-chart-mini .tooth-chart-jawline {
    stroke-width: 0.75;
}

.tooth-chart-mini .tooth-chart-side {
    font-size: 8px;
}

/* 치식이 비었을 때 — 빈 차트 대신 말로 */
.tooth-chart-empty {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    font-size: 12px;
    color: #71717a;
}

/* 치식 칩 — 확대 모달 아래의 번호 목록 (EDSToothChart.badges). 상태 태그와 같은 24px·4px 모양, 숫자 폭 고정 */
.tooth-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    box-sizing: border-box;
    border-radius: 4px;
    background: #eef1f5;
    color: #3e5d7d;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tooth-chip.tooth-chip-invalid {
    background: #fdeceb;
    color: #b42318;
}

/* ===== 쉐이드 고르기 (의뢰서 작성) — 색 칸은 VITA Classical 근사값. 선택은 로즈 테두리 ===== */
.shade-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 32px;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid #d0d4dc;
    border-radius: 4px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: #18181b;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

@media (hover: hover) {
    .shade-btn:hover {
        border-color: #7c8492;
    }
}

.shade-btn:focus-visible {
    outline: 2px solid #ad6672;
    outline-offset: 2px;
}

.shade-btn.selected,
.shade-btn[aria-pressed="true"] {
    border-color: #963f4b;
    box-shadow: 0 0 0 1px #963f4b;
    font-weight: 700;
}

.shade-a1 { background-color: #f5ecd7; }
.shade-a2 { background-color: #efe2c0; }
.shade-a3 { background-color: #e8d5a6; }
.shade-a35 { background-color: #e3cc93; }
.shade-a4 { background-color: #dbc07a; }
.shade-b1 { background-color: #f2ead0; }
.shade-b2 { background-color: #ece0b8; }
.shade-b3 { background-color: #e5d49e; }
.shade-b4 { background-color: #ddc882; }
.shade-c1 { background-color: #e8dfc6; }
.shade-c2 { background-color: #ddd3ad; }
.shade-c3 { background-color: #d3c694; }
.shade-c4 { background-color: #c9b97b; }
.shade-d2 { background-color: #e0d5b5; }
.shade-d3 { background-color: #d5c89c; }
.shade-d4 { background-color: #cabb82; }

/* ===== 상태 태그 — 글자와 색을 함께 쓴다(색만으로 말하지 않는다). 누르는 것이 아니므로 hover·포인터 없음 =====
   PC앱 상태 태그와 같은 치수(최소 24px, 2px 8px, 11px, line-height 1.4, 4px).
   톤은 상태 코드 하나로 정한다: 기본(진행 단계 전부 — 접수~배송중) / -request(접수대기) / -done(배송완료) /
   -cancel(취소) / -error(반품·긴급). 진행 단계는 한 색이고 글자가 단계를 말한다. */
.dental-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 24px;
    padding: 2px 8px;
    box-sizing: border-box;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.4;
    font-weight: 500;
    white-space: nowrap;
    vertical-align: middle;
    background: #eef1f5;
    color: #3e5d7d;
}

/* 변형은 두 클래스로 — 어느 파일이 뒤에 실려도 기본 .dental-tag 가 변형 색을 덮지 못하게 */
.dental-tag.dental-tag-request { background: #faf0dc; color: #8b5b20; }
.dental-tag.dental-tag-done { background: #eaf3ed; color: #33634d; }
.dental-tag.dental-tag-cancel { background: #f0eef1; color: #66616a; }
.dental-tag.dental-tag-error { background: #fdeceb; color: #b42318; }

/* ===== 칩 — 고르는 필터(상태·태그·긴급만)와 보여주기만 하는 태그 =====
   중립 모양 하나: 흰 바탕, #d0d4dc 테두리, 32px. 태그 색은 8px 점(.dental-chip-dot)으로만 — 글자색으로 쓰면 노랑이 1.9:1 이 된다.
   고르는 칩: <button type="button" class="dental-chip" aria-pressed="false" data-track="…">
              <span class="dental-chip-dot" style="background:#4a6fa5"></span><span class="dental-chip-label">이름</span>
              (<span class="dental-chip-n">12</span>)</button>
   보여주기만: <span class="dental-chip dental-chip-static">…</span> (24px, 4px, 포인터 없음)
   긴급만    : 같은 칩에 점만 .dental-chip-dot-error (#b42318), 이모지 없음
   선택(aria-pressed="true")은 기공소(Phoenix) 화면에서 기존 파랑, 치과 화면(.dental-page)에서 로즈. */
.dental-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    max-width: 100%;
    padding: 0 12px;
    box-sizing: border-box;
    border: 1px solid #d0d4dc;
    border-radius: 8px;
    background: #fff;
    color: #52525b;
    font: inherit;
    font-size: 13px;
    line-height: 16px;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.dental-chip:hover {
    border-color: #aeb4bf;
    color: #18181b;
}

.dental-chip:focus-visible {
    outline: 2px solid var(--phoenix-primary, #3874ff);
    outline-offset: -2px;
}

.dental-page .dental-chip:focus-visible {
    outline-color: #ad6672;
}

.dental-chip:disabled,
.dental-chip[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
}

.dental-chip:disabled:hover,
.dental-chip[aria-disabled="true"]:hover {
    border-color: #d0d4dc;
    color: #52525b;
}

.dental-chip .dental-chip-n {
    font-weight: 600;
    color: #18181b;
    font-variant-numeric: tabular-nums;
}

.dental-chip-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 16px;
}

.dental-chip-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tag-color, #7d7066);
    box-shadow: inset 0 0 0 1px rgba(24, 24, 27, 0.14);
}

.dental-chip-dot.dental-chip-dot-error {
    background: #b42318;
}

/* 선택 — 기공소 화면(Phoenix): 기존 파랑 */
.dental-chip[aria-pressed="true"] {
    background: var(--phoenix-primary-bg-subtle, #e5edff);
    border-color: var(--phoenix-primary, #3874ff);
    color: var(--phoenix-primary-text-emphasis, #003cc7);
}

.dental-chip[aria-pressed="true"] .dental-chip-n {
    color: inherit;
}

/* 선택 — 치과 화면: 로즈 */
.dental-page .dental-chip[aria-pressed="true"] {
    background: #f7ecee;
    border-color: #963f4b;
    color: #873744;
}

/* 보여주기만 하는 칩 — 누르는 칩보다 작고 각진 모양, 포인터·hover 없음 */
.dental-chip.dental-chip-static,
.dental-chip.dental-chip-static:hover {
    height: 24px;
    padding: 0 8px;
    gap: 5px;
    border-color: #d0d4dc;
    border-radius: 4px;
    background: #fff;
    color: #3f3f46;
    font-size: 12px;
    cursor: default;
}

/* 태그 색 고르기 — 동그라미 하나가 색 하나. role="radio" + aria-checked, 이름은 aria-label */
.dental-swatch {
    flex: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--tag-color, #7d7066);
    box-shadow: inset 0 0 0 1px rgba(24, 24, 27, 0.14);
    cursor: pointer;
}

.dental-swatch[aria-checked="true"] {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #963f4b;
}

.dental-swatch:focus-visible {
    outline: 2px solid #ad6672;
    outline-offset: 4px;
}

/* 기공소 화면 어두운 테마(Phoenix — html[data-bs-theme="dark"], 상단 '밝게/어둡게' 전환). 치과 화면은 늘 밝은 업무 면이라 제외한다.
   칩은 어두운 면 위의 어두운 칩, 차트는 밝은 치아는 그대로 두고 글자·선만 어두운 바탕에서 읽히게 */
[data-bs-theme="dark"] body:not(.dental-page) .dental-chip,
[data-bs-theme="dark"] body:not(.dental-page) .dental-chip.dental-chip-static {
    background: var(--phoenix-emphasis-bg, #0f111a);
    border-color: var(--phoenix-border-color, #373e53);
    color: var(--phoenix-body-color, #9fa6bc);
}

[data-bs-theme="dark"] body:not(.dental-page) .dental-chip:hover {
    border-color: var(--phoenix-secondary-color, #8a94ad);
    color: var(--phoenix-emphasis-color, #fff);
}

[data-bs-theme="dark"] body:not(.dental-page) .dental-chip .dental-chip-n {
    color: var(--phoenix-emphasis-color, #fff);
}

[data-bs-theme="dark"] body:not(.dental-page) .dental-chip[aria-pressed="true"] {
    background: var(--phoenix-primary-bg-subtle, #1c2231);
    border-color: var(--phoenix-primary, #3874ff);
    color: var(--phoenix-primary-text-emphasis, #85a9ff);
}

[data-bs-theme="dark"] body:not(.dental-page) .tooth-chart-svg .tooth-label,
[data-bs-theme="dark"] body:not(.dental-page) .jaw-label,
[data-bs-theme="dark"] body:not(.dental-page) .tooth-chart-legend {
    fill: #9fa6bc;
}

[data-bs-theme="dark"] body:not(.dental-page) .tooth-chart-svg .tooth-g.selected .tooth-label {
    fill: #a9c3e6;
}

[data-bs-theme="dark"] body:not(.dental-page) .tooth-chart-side {
    fill: #8fb0d6;
}

[data-bs-theme="dark"] body:not(.dental-page) .tooth-chart-jawline {
    stroke: #4b5468;
}

[data-bs-theme="dark"] body:not(.dental-page) .tooth-chart-midline {
    stroke: #5e6575;
}

/* 치식 번호 칩도 어두운 칩 — 밝은 #eef1f5 칩이 어두운 카드 위에서 떠 보였다. 글자는 차트의 고른 치아 번호와 같은 파랑 */
[data-bs-theme="dark"] body:not(.dental-page) .tooth-chip {
    background: rgba(133, 169, 255, .14);
    color: #a9c3e6;
}

[data-bs-theme="dark"] body:not(.dental-page) .tooth-chip.tooth-chip-invalid {
    background: rgba(239, 68, 68, .2);
    color: #fca5a5;
}

/* 움직임 줄이기 설정이면 색 전환도 끈다 */
@media (prefers-reduced-motion: reduce) {
    .tooth-chart-svg.is-select .tooth-g .tooth-crown,
    .tooth-chart-svg.is-select .tooth-g .tooth-root,
    .dental-chip,
    .shade-btn {
        transition: none;
    }
}

/* ===== 치과 화면 휴대폰 ===== */

/* 치과 화면 입력칸 글자 크기 (휴대폰) — mobile-custom.css 의 공용 규칙(input[type=text]·textarea 20px)이
   치과 화면의 40px 입력칸에서는 셀렉트와 크기가 어긋나고, 기간 입력("2026-09-30 ~ 2026-11-06")이 잘렸다.
   16px 은 iOS 확대를 막는 최소 크기다 — 입력·글상자·셀렉트가 같은 크기를 쓴다. */
@media (max-width: 767.98px) {
    .dental-page input.dental-input,
    .dental-page textarea.dental-input,
    .dental-page select.dental-select {
        font-size: 16px;
    }
}

/* ===== 달력(flatpickr) — 치과 화면: 흰 바탕, 로즈 선택 =====
   theme.css 의 월 고르기 디버그 빨강, 회색 바탕·25px 월 글자, 파란 '오늘' 원, user.css 의 옛 민트 선택색을 덮는다.
   달력은 body 끝에 붙으므로 body.dental-page 아래에서 잡힌다. */
body.dental-page {
    --phoenix-flatpickr-calendar-bg: #fff;
    --phoenix-flatpickr-current-month-color: #18181b;
}

body.dental-page .flatpickr-calendar {
    border: 1px solid #d0d4dc !important;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(24, 24, 27, 0.12) !important;
}

body.dental-page .flatpickr-months .flatpickr-month .flatpickr-current-month {
    font-size: 15px;
}

body.dental-page .flatpickr-months .flatpickr-month .flatpickr-current-month .flatpickr-monthDropdown-months {
    background-color: transparent;
    color: #18181b;
}

body.dental-page .flatpickr-day.today {
    background: transparent !important;
    color: #873744;
    box-shadow: inset 0 0 0 1px #dec5ca;
}

body.dental-page .flatpickr-day.today:hover,
body.dental-page .flatpickr-day.today:focus {
    background: #f7ecee !important;
    color: #873744;
}

body.dental-page .flatpickr-day.inRange {
    background: #f7ecee !important;
    border-color: #f7ecee !important;
    box-shadow: -5px 0 0 #f7ecee, 5px 0 0 #f7ecee !important;
    color: #18181b !important;
}

body.dental-page .flatpickr-day.selected,
body.dental-page .flatpickr-day.startRange,
body.dental-page .flatpickr-day.endRange,
body.dental-page .flatpickr-day.selected.inRange,
body.dental-page .flatpickr-day.startRange.inRange,
body.dental-page .flatpickr-day.endRange.inRange,
body.dental-page .flatpickr-day.selected:hover,
body.dental-page .flatpickr-day.selected:focus {
    background: #963f4b !important;
    border-color: #963f4b !important;
    box-shadow: none !important;
    color: #fff !important;
}

body.dental-page .flatpickr-day.flatpickr-disabled,
body.dental-page .flatpickr-day.flatpickr-disabled:hover {
    background: transparent !important;
    box-shadow: none !important;
    color: #a1a1aa !important;
    cursor: not-allowed;
}
