/* 好預約：共用樣式 */
:root {
  --ink: #241d2c;
  --ink-2: #4a4152;
  --muted: #7a7084;
  --line: #ebe6f0;
  --line-2: #ddd6e4;
  --bg: #f7f5fa;
  --card: #ffffff;
  --brand: #7c5cff;
  --brand-ink: #ffffff;
  --brand-soft: #f0ecff;
  --accent: var(--brand);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --ok: #1f9d6a;
  --ok-soft: #e4f6ee;
  --warn: #c98a12;
  --warn-soft: #fdf3dc;
  --danger: #d64550;
  --danger-soft: #fde8ea;
  --info: #3b7ddd;
  --info-soft: #e6effc;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(36, 29, 44, 0.04), 0 4px 16px rgba(36, 29, 44, 0.06);
  --shadow-lg: 0 10px 40px rgba(36, 29, 44, 0.18);
  --font: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', 'Segoe UI', sans-serif;
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img, svg {
  vertical-align: middle;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.tiny {
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.wrap {
  flex-wrap: wrap;
}

.row.between {
  justify-content: space-between;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grow {
  flex: 1;
  min-width: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: #faf8fc;
  border-color: #cfc6d8;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, black);
}

.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, white);
}

.btn.danger:hover {
  background: var(--danger-soft);
}

.btn.danger.solid {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.ghost:hover {
  background: rgba(36, 29, 44, 0.05);
}

.btn.sm {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 8px;
}

.btn.lg {
  min-height: 50px;
  padding: 12px 22px;
  font-size: 16px;
  border-radius: 12px;
}

.btn.block {
  width: 100%;
}

.btn.icon {
  padding: 0;
  width: 40px;
}

.btn.sm.icon {
  width: 32px;
}

.btn .spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* ---------- 表單 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span,
.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.field .hint {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.req::after {
  content: ' *';
  color: var(--danger);
}

.input,
input[type='text'],
input[type='email'],
input[type='tel'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='time'],
input[type='search'],
input[type='url'],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237a7084' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

input[type='checkbox'],
input[type='radio'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
  flex-shrink: 0;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}

.check input {
  margin-top: 2px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 640px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* 開關 */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch .track {
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: #d6cfdd;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch .track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch input:checked + .track {
  background: var(--accent);
}

.switch input:checked + .track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.card-head h3 {
  font-size: 16px;
}

.card-body {
  padding: 16px 20px;
}

/* ---------- 標籤 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #f0edf3;
  color: var(--ink-2);
}

.badge.pending {
  background: var(--warn-soft);
  color: #8a5d00;
}

.badge.confirmed {
  background: var(--info-soft);
  color: #2359a8;
}

.badge.completed {
  background: var(--ok-soft);
  color: #137049;
}

.badge.cancelled {
  background: #f0edf3;
  color: #8a8090;
}

.badge.no_show {
  background: var(--danger-soft);
  color: #a8323b;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

/* ---------- 提示框 ---------- */
.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: #234a80;
  font-size: 14px;
  white-space: pre-line;
}

.notice.warn {
  background: var(--warn-soft);
  color: #7a5300;
}

.notice.danger {
  background: var(--danger-soft);
  color: #932a33;
}

.notice.ok {
  background: var(--ok-soft);
  color: #11603f;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
  font-size: 14px;
}

.empty .empty-icon {
  font-size: 34px;
  margin-bottom: 6px;
  opacity: 0.6;
}

/* ---------- 讀取中 ---------- */
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.loading {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 對話框 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 22, 38, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade 0.15s ease-out;
}

.modal {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  animation: pop 0.18s ease-out;
}

.modal.lg {
  max-width: 720px;
}

.modal.sm {
  max-width: 400px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}

.modal-head h3 {
  font-size: 18px;
}

.modal-body {
  padding: 4px 20px 16px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal,
  .modal.lg,
  .modal.sm {
    max-width: none;
    border-radius: 18px 18px 0 0;
    max-height: 92vh;
    animation: slideup 0.22s ease-out;
  }

  .modal-foot {
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(6px);
  }
}

@keyframes slideup {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

/* ---------- 浮動通知 ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}

.toast {
  background: #2a2232;
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.2s ease-out;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.error {
  background: var(--danger);
}

.toast.ok::before {
  content: '✓';
  font-weight: 700;
  color: #7ee2b5;
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: #fbfafc;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

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

.table tr.clickable {
  cursor: pointer;
}

.table tr.clickable:hover td {
  background: #faf8fc;
}

/* 分段選擇器 */
.segmented {
  display: inline-flex;
  background: #efebf3;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}

.segmented button.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 色票 */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line-2);
  cursor: pointer;
  padding: 0;
}

.swatch.on {
  box-shadow: 0 0 0 2px var(--ink);
}
