/* ============================================
   法律事務所 KM 系統樣式
   Design System v2 — 精緻化視覺升級
   ============================================ */
:root {
  --brand-900: #1a150c;
  --shadow-soft: 0 1px 2px rgba(26, 21, 12, 0.04), 0 2px 8px rgba(26, 21, 12, 0.04);
  --shadow-card: 0 1px 3px rgba(26, 21, 12, 0.06), 0 4px 16px rgba(26, 21, 12, 0.05);
  --shadow-card-hover: 0 4px 12px rgba(26, 21, 12, 0.08), 0 12px 28px rgba(26, 21, 12, 0.10);
  --shadow-modal: 0 20px 60px rgba(26, 21, 12, 0.25), 0 8px 24px rgba(26, 21, 12, 0.15);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  scrollbar-width: thin;
  scrollbar-color: #c2ab7d #ece6d8;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.doc-preview {
  white-space: pre-wrap;
  font-family: "Noto Serif TC", serif;
  line-height: 2;
  letter-spacing: 0.02em;
}

.doc-textarea {
  white-space: pre-wrap;
  font-family: "Noto Serif TC", serif;
  line-height: 2;
  letter-spacing: 0.02em;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d9cbae;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #ad8f5a;
}

/* ---------- Tags & Badges ---------- */
.tag-chip {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 9999px;
  font-size: 0.75rem;
  background: #ece6d8;
  color: #4a3c22;
  margin: 2px 4px 2px 0;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px 3px 9px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: currentColor;
  flex-shrink: 0;
}
.status-諮詢中 { background: #e0e7ff; color: #3730a3; }
.status-委任中 { background: #fef3c7; color: #92400e; }
.status-進行中 { background: #dbeafe; color: #1e40af; }
.status-上訴中 { background: #fce7f3; color: #9d174d; }
.status-已結案 { background: #d1fae5; color: #065f46; }
.status-暫停 { background: #f3f4f6; color: #374151; }

/* Status accent bar color (used as left border on cards) */
.status-accent-諮詢中 { background: #6366f1; }
.status-accent-委任中 { background: #d97706; }
.status-accent-進行中 { background: #3b82f6; }
.status-accent-上訴中 { background: #db2777; }
.status-accent-已結案 { background: #10b981; }
.status-accent-暫停 { background: #9ca3af; }

/* ---------- Sidebar / Nav ---------- */
.nav-link {
  position: relative;
  transition: background-color 0.18s var(--ease-out), color 0.18s var(--ease-out);
}
.nav-link .nav-icon {
  transition: background-color 0.18s var(--ease-out), color 0.18s var(--ease-out);
}
.nav-link.active {
  background: rgba(247, 245, 240, 0.08);
  color: #f7f5f0;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 0 4px 4px 0;
  background: #c2ab7d;
}
.nav-link.active .nav-icon {
  background: rgba(194, 171, 125, 0.22);
  color: #e8d9b8;
}
.nav-link:not(.active) {
  color: #c9bfa8;
}
.nav-link:not(.active):hover {
  background: rgba(247, 245, 240, 0.06);
  color: #f7f5f0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.6rem;
  padding: 0.6rem 1.25rem;
  transition: background-color 0.15s var(--ease-out), border-color 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out), transform 0.1s var(--ease-out), opacity 0.15s;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(180deg, #362c1a, #241d11);
  color: #f7f5f0;
  box-shadow: 0 1px 2px rgba(26,21,12,0.15), 0 2px 8px rgba(45, 39, 22, 0.18);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4a3c22, #2f2716);
  box-shadow: 0 2px 6px rgba(26,21,12,0.2), 0 6px 16px rgba(45, 39, 22, 0.22);
}

.btn-secondary {
  background: #fff;
  color: #4a3c22;
  border: 1px solid #d9cbae;
}
.btn-secondary:hover:not(:disabled) {
  background: #f7f5f0;
  border-color: #c2ab7d;
}

.btn-danger-outline {
  background: #fff;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.btn-danger-outline:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fca5a5;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 1px 2px rgba(220,38,38,0.2), 0 2px 8px rgba(220,38,38,0.18);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-icon {
  padding: 0.5rem 0.65rem;
  border-radius: 0.5rem;
}

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; border-radius: 0.5rem; }

/* ---------- Inputs ---------- */
.input-field {
  width: 100%;
  border: 1px solid #d9cbae;
  border-radius: 0.6rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  background: #fff;
  color: #2f2716;
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}
.input-field::placeholder { color: #a89a7d; }
.input-field:focus {
  outline: none;
  border-color: #ad8f5a;
  box-shadow: 0 0 0 3.5px rgba(173, 143, 90, 0.16);
}
.input-field:hover:not(:focus) { border-color: #c2ab7d; }
select.input-field { cursor: pointer; }
textarea.input-field { resize: vertical; }

label.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #6b5732;
  margin-bottom: 0.3rem;
}

/* ---------- Cards ---------- */
.surface-card {
  background: #fff;
  border-radius: 0.85rem;
  border: 1px solid #ece6d8;
  box-shadow: var(--shadow-soft);
}

.fade-in {
  animation: fadeIn 0.3s var(--ease-out);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-hover {
  transition: box-shadow 0.22s var(--ease-out), transform 0.22s var(--ease-out), border-color 0.22s var(--ease-out);
}
.card-hover:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  border-color: #d9cbae;
}

.stat-card {
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.22s var(--ease-out), transform 0.22s var(--ease-out);
}
.stat-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 120px;
  height: 120px;
  border-radius: 9999px;
  background: radial-gradient(circle, currentColor 0%, transparent 70%);
  opacity: 0.06;
  pointer-events: none;
}

/* accent left bar on list-item cards */
.accent-card {
  position: relative;
  border-left: 3px solid transparent;
}

/* progress bars */
.progress-track {
  height: 7px;
  background: #ece6d8;
  border-radius: 9999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s var(--ease-out);
}

/* ---------- Result banner ---------- */
.result-banner {
  position: relative;
  background: linear-gradient(135deg, #ecfdf5, #f0fdf9);
  border: 1px solid #a7f3d0;
  border-radius: 0.85rem;
  overflow: hidden;
}
.result-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: #10b981;
}

/* ---------- Timeline ---------- */
.timeline-row { position: relative; }
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: #ad8f5a;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #ece6d8;
  flex-shrink: 0;
  margin-top: 4px;
}
.timeline-line {
  width: 1px;
  flex: 1;
  background: #ece6d8;
  margin-top: 4px;
}

/* ---------- Doc row ---------- */
.doc-row {
  transition: background-color 0.15s var(--ease-out), border-color 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}
.doc-row:hover {
  background: #f7f5f0;
  border-color: #d9cbae;
  transform: translateX(2px);
}
.doc-icon {
  width: 36px;
  height: 36px;
  border-radius: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #ece6d8;
  color: #8f7443;
}

/* ---------- Modal ---------- */
.modal-overlay {
  background: rgba(26, 21, 12, 0.55);
  backdrop-filter: blur(3px);
  animation: overlayIn 0.2s var(--ease-out);
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-panel {
  animation: modalIn 0.28s var(--ease-out);
  box-shadow: var(--shadow-modal);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Toast ---------- */
.toast-item {
  animation: toastIn 0.32s var(--ease-out);
  box-shadow: var(--shadow-modal);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
.toast-item.toast-out {
  animation: toastOut 0.22s var(--ease-out) forwards;
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(24px) scale(0.95); }
}

/* ---------- Spinner / Skeleton ---------- */
.spinner {
  border: 3px solid #ece6d8;
  border-top: 3px solid #8f7443;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: #ece6d8;
  border-radius: 0.5rem;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  100% { transform: translateX(100%); }
}

/* ---------- Misc ---------- */
.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  background: #ece6d8;
  color: #6b5732;
}

.segmented-tab {
  transition: background-color 0.2s var(--ease-out), color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.segmented-tab.active {
  background: #fff;
  color: #2f2716;
  box-shadow: 0 1px 3px rgba(26,21,12,0.1), 0 2px 6px rgba(26,21,12,0.06);
}
.segmented-tab:not(.active) {
  color: #8f7443;
}
.segmented-tab:not(.active):hover {
  color: #4a3c22;
}

a, button {
  -webkit-tap-highlight-color: transparent;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
