/* Meiko 管理系統 — Claymorphism 暖色系（沿用 pet-grooming STYLE-GUIDE） */

:root {
  --c-bg:        #FFF8F0;
  --c-primary:   #FF6B47;
  --c-primary-d: #E8502F;
  --c-secondary: #FFB84D;
  --c-green:     #4DC88A;
  --c-red:       #F0563A;
  --c-blue:      #5AA9E6;
  --c-pink:      #FF7BAC;
  --c-purple:    #A78BFA;
  --c-text:      #2A1800;
  --c-mid:       #7C5B3F;
  --c-light:     #B89B80;
  --c-white:     #FFFFFF;
  --radius-card: 24px;
  --radius-xl:   34px;
  --clay-sm: 6px 6px 18px rgba(0,0,0,.08), -3px -3px 10px rgba(255,255,255,.85), inset 0 1px 2px rgba(255,255,255,.9);
  --clay:    8px 8px 24px rgba(0,0,0,.10), -5px -5px 14px rgba(255,255,255,.90), inset 0 1px 3px rgba(255,255,255,.9);
  --clay-lg: 12px 16px 36px rgba(0,0,0,.13), -6px -6px 18px rgba(255,255,255,.95), inset 0 2px 4px rgba(255,255,255,.95);
  --trans: all .3s cubic-bezier(.34,1.56,.64,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Nunito', 'Noto Sans TC', system-ui, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; }
.hidden { display: none !important; }

/* ───────── 登入頁 ───────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(155deg, #FFF0E6 0%, #FFF8F0 60%, #FFE9D6 100%);
}
.login-card {
  width: 100%; max-width: 420px; padding: 44px 38px;
  background: var(--c-white); border-radius: var(--radius-xl);
  box-shadow: var(--clay-lg); border: 2px solid rgba(255,255,255,.8);
}
.login-logo {
  width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--c-primary), #FF8C42);
  display: flex; align-items: center; justify-content: center; font-size: 2.2rem;
  box-shadow: 0 8px 22px rgba(255,107,71,.4);
}
.login-card h1 { text-align: center; font-size: 1.5rem; font-weight: 900; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--c-mid); font-weight: 600; font-size: .9rem; margin-bottom: 28px; }

/* ───────── 表單欄位（共用） ───────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .85rem; font-weight: 800; color: var(--c-mid); margin-bottom: 7px; }
.form-input, .form-select {
  width: 100%; padding: 12px 15px; border-radius: 14px;
  border: 2px solid rgba(255,107,71,.15); background: rgba(255,248,240,.6);
  font-family: inherit; font-size: 1rem; font-weight: 600; color: var(--c-text);
  transition: var(--trans); outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--c-primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(255,107,71,.1);
}
.form-select { cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--c-light); font-weight: 600; margin-top: 6px; }

/* ───────── 按鈕 ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px 24px; border-radius: 50px; font-weight: 800; font-size: .95rem;
  transition: var(--trans);
}
.btn-primary { background: linear-gradient(135deg, var(--c-primary), #FF8C42); color: #fff; box-shadow: 0 6px 20px rgba(255,107,71,.35); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(255,107,71,.45); }
.btn-block { width: 100%; }
.btn-ghost { background: rgba(255,107,71,.08); color: var(--c-mid); border: 2px solid rgba(255,107,71,.15); }
.btn-ghost:hover { background: rgba(255,107,71,.15); }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-danger { background: rgba(240,86,58,.1); color: var(--c-red); border: 2px solid rgba(240,86,58,.2); }
.btn-danger:hover { background: var(--c-red); color: #fff; }

/* ───────── App Shell ───────── */
.app { display: none; min-height: 100vh; }
.app.active { display: grid; grid-template-columns: 248px 1fr; }

.sidebar {
  background: var(--c-white); border-right: 1.5px solid rgba(255,184,77,.18);
  box-shadow: 4px 0 24px rgba(0,0,0,.04);
  display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.sb-logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.15rem; color: var(--c-primary); margin-bottom: 6px; padding: 0 8px; }
.sb-logo .ic { width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(135deg, var(--c-primary), #FF8C42); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; box-shadow: 0 5px 14px rgba(255,107,71,.35); }
.sb-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; overflow-y: auto; }
.sb-link {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 14px;
  font-weight: 700; font-size: .95rem; color: var(--c-mid); transition: var(--trans);
}
.sb-link .ic { font-size: 1.15rem; width: 22px; text-align: center; }
.sb-link:hover { background: rgba(255,107,71,.08); color: var(--c-primary); }
.sb-link.active { background: linear-gradient(135deg, var(--c-primary), #FF8C42); color: #fff; box-shadow: 0 5px 16px rgba(255,107,71,.35); }
.sb-foot { margin-top: auto; padding: 12px 8px 0; }
.sb-user { font-size: .85rem; font-weight: 700; color: var(--c-text); }
.sb-role { font-size: .75rem; color: var(--c-light); font-weight: 700; margin-bottom: 10px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 16px 28px;
  background: rgba(255,248,240,.88); backdrop-filter: blur(20px);
  border-bottom: 1.5px solid rgba(255,184,77,.18); position: sticky; top: 0; z-index: 40;
}
.topbar .hamb { display: none; font-size: 1.5rem; background: none; color: var(--c-primary); }
.topbar h2 { font-size: 1.25rem; font-weight: 900; }
.content { padding: 28px; max-width: 1280px; width: 100%; }
.maint-banner { margin: 16px 28px 0; padding: 12px 18px; border-radius: 14px; font-weight: 800; font-size: .9rem;
  background: linear-gradient(135deg, #FFE9C7, #FFD79B); color: #8A5A00; border: 1.5px solid rgba(255,184,77,.5); }

/* ───────── 卡片 / 區塊 ───────── */
.panel { background: var(--c-white); border-radius: var(--radius-card); box-shadow: var(--clay); border: 1.5px solid rgba(255,255,255,.7); padding: 22px 24px; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head h3 { font-size: 1.1rem; font-weight: 900; }
.badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 50px; font-weight: 800; font-size: .76rem; }
.badge-orange { background: rgba(255,107,71,.1); color: var(--c-primary); }
.badge-green { background: rgba(77,200,138,.14); color: #1A8A50; }
.badge-grey { background: rgba(124,91,63,.1); color: var(--c-mid); }
.badge-blue { background: rgba(90,169,230,.14); color: #2B7CC0; }

/* 統計卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-card { background: var(--c-white); border-radius: var(--radius-card); box-shadow: var(--clay); border: 1.5px solid rgba(255,255,255,.7); padding: 22px; transition: var(--trans); }
.stat-card:hover { transform: translateY(-6px); box-shadow: var(--clay-lg); }
.stat-ic { width: 52px; height: 52px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; margin-bottom: 14px; }
.si-orange { background: linear-gradient(135deg, #FFE4DA, #FFCFB8); }
.si-green { background: linear-gradient(135deg, #D4F5E4, #A8EAC8); }
.si-pink { background: linear-gradient(135deg, #FFE0EE, #FFB8D4); }
.si-purple { background: linear-gradient(135deg, #E4E0FF, #C8C0FF); }
.stat-num { font-size: 2rem; font-weight: 900; line-height: 1; }
.stat-label { font-size: .85rem; color: var(--c-mid); font-weight: 700; margin-top: 6px; }

/* ───────── 表格（桌面） ───────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data thead th {
  text-align: left; font-size: .8rem; font-weight: 800; color: var(--c-mid);
  padding: 11px 14px; border-bottom: 2px solid rgba(255,107,71,.12); white-space: nowrap;
}
table.data tbody td { padding: 12px 14px; font-weight: 600; font-size: .92rem; border-bottom: 1px solid rgba(124,91,63,.08); }
table.data tbody tr { transition: background .2s; }
table.data tbody tr:hover { background: rgba(255,107,71,.04); }
.col-actions { text-align: right; white-space: nowrap; }
.col-actions .btn { margin-left: 6px; }
.empty { text-align: center; color: var(--c-light); font-weight: 700; padding: 36px 0; }

/* ───────── Modal ───────── */
.modal-mask { position: fixed; inset: 0; background: rgba(42,24,0,.4); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-mask.show { display: flex; }
.modal { width: 100%; max-width: 480px; background: var(--c-white); border-radius: var(--radius-xl); box-shadow: var(--clay-lg); padding: 28px 30px; max-height: 90vh; overflow-y: auto; animation: pop .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal.modal-wide { max-width: 780px; }
.modal h3 { font-size: 1.25rem; font-weight: 900; margin-bottom: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.form-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* 多選 chips（指派公司） */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 50px; font-weight: 700; font-size: .85rem; border: 2px solid rgba(255,107,71,.15); background: rgba(255,248,240,.5); color: var(--c-mid); cursor: pointer; transition: var(--trans); }
.chip.on { background: rgba(255,107,71,.1); border-color: var(--c-primary); color: var(--c-primary); }

/* ───────── Toast ───────── */
.toast-box { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 13px 20px; border-radius: 16px; font-weight: 800; font-size: .9rem; color: #fff; box-shadow: var(--clay); animation: slidein .3s ease; }
.toast.ok { background: linear-gradient(135deg, var(--c-green), #2DB870); }
.toast.err { background: linear-gradient(135deg, var(--c-red), #C8341C); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ───────── 問題回報 ───────── */
.issue-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.issue-time { color: var(--c-light); font-weight: 600; font-size: .78rem; }
.issue-msg { background: rgba(255,248,240,.6); border: 2px solid rgba(255,107,71,.12); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.issue-msg.reporter { background: rgba(255,107,71,.07); }
.issue-msg.handler { background: rgba(64,160,255,.08); border-color: rgba(64,160,255,.18); }
.issue-msg-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.issue-body { font-weight: 600; color: var(--c-text); line-height: 1.7; white-space: normal; word-break: break-word; }
.issue-change { font-weight: 800; color: var(--c-mid); font-size: .85rem; margin: 4px 0; }
.issue-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.issue-thread { margin: 6px 0 4px; max-height: 42vh; overflow-y: auto; }
.issue-manage { background: rgba(255,248,240,.7); border-radius: 14px; padding: 12px 14px; margin: 14px 0 6px; }
.issue-manage-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.issue-manage-row select { max-width: 160px; }
.issue-manage-row input { flex: 1; min-width: 160px; }
.issue-reply { margin-top: 14px; }

/* ───────── 手機 RWD（表格→卡片式） ───────── */
.scrim { display: none; }
@media (max-width: 920px) {
  .app.active { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 260px; transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; }
  .topbar .hamb { display: block; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-row2 { grid-template-columns: 1fr; }

  /* 表格改卡片式：每列一張卡，欄名:值直式堆疊 */
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr {
    background: var(--c-white); border-radius: 16px; box-shadow: var(--clay-sm);
    border: 1.5px solid rgba(255,255,255,.7); padding: 8px 14px; margin-bottom: 12px;
  }
  table.data tbody td { border: none; padding: 7px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  table.data tbody td::before {
    content: attr(data-label); font-weight: 800; color: var(--c-mid); font-size: .8rem; flex-shrink: 0;
  }
  table.data tbody tr:hover { background: var(--c-white); }
  .col-actions { text-align: right; justify-content: flex-end; }
  .col-actions::before { content: '' !important; }
  .modal { padding: 22px 18px; }

  /* 問題回報：處理列全寬堆疊，回覆區好操作 */
  .issue-manage-row { flex-direction: column; align-items: stretch; }
  .issue-manage-row select, .issue-manage-row input { max-width: none; width: 100%; }
  .issue-thread { max-height: none; }
}
