/*
 * wanchuang-fk Apple-minimal UI — responsive rewrite
 */

/* ── Design tokens ─────────────────────────────────── */
:root {
  --c-primary:   #007AFF;
  --c-danger:    #FF3B30;
  --c-success:   #34C759;
  --c-warning:   #FF9500;
  --c-bg:        #F5F5F7;
  --c-surface:   #FFFFFF;
  --c-border:    #E5E5E7;
  --c-text:      #1D1D1F;
  --c-muted:     #86868B;
  --r-card:      12px;
  --r-btn:       8px;
  --sidebar-w:   188px;
  --sidebar-compact: 52px;
  --nav-h:       56px;
  --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 0 0 1px var(--c-border);
  --shadow-float: 0 8px 32px rgba(0,0,0,.16);
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Helvetica Neue", Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Top nav ────────────────────────────────────────── */
.wc-nav {
  position: sticky; top: 0; z-index: 200;
  height: var(--nav-h);
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 10px;
}
.wc-nav-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 650; font-size: 15px; letter-spacing: -.01em;
  color: var(--c-text); text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.wc-nav-logo img { height: 26px; }
.wc-nav-badge {
  font-size: 10px; font-weight: 500; color: var(--c-muted);
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: 4px; padding: 1px 5px; margin-left: 2px;
}
.wc-nav-spacer { flex: 1; }
.wc-nav-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--c-muted);
}
.wc-nav-user a { color: var(--c-primary); text-decoration: none; }
.wc-nav-user a:hover { text-decoration: underline; }

/* Hamburger — hidden on desktop */
.wc-hamburger {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  border-radius: 8px; color: var(--c-text); flex-shrink: 0;
}
.wc-hamburger:hover { background: var(--c-bg); }
.wc-hamburger svg { width: 20px; height: 20px; display: block; }

/* ── Page layout ────────────────────────────────────── */
.wc-admin-body {
  display: flex;
  min-height: calc(100vh - var(--nav-h));
}

/* ── Sidebar ────────────────────────────────────────── */
.wc-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 10px 0 24px;
  border-right: 1px solid var(--c-border);
  background: var(--c-surface);
  overflow-y: auto;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  transition: width .2s ease, min-width .2s ease;
}
.wc-sidebar-section {
  font-size: 10px; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 14px 13px 7px;
  white-space: nowrap; overflow: hidden;
}
.wc-sidebar a {
  display: flex; align-items: center; justify-content: flex-start; gap: 11px;
  padding: 10px 10px 10px 12px; margin: 4px 7px;
  font-size: 16px; color: var(--c-text);
  text-decoration: none; border-radius: 8px;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.wc-sidebar a svg {
  width: 16px; height: 16px; flex-shrink: 0; opacity: .72;
  transition: opacity .12s;
}
.wc-sidebar a:hover { background: var(--c-bg); }
.wc-sidebar a:hover svg { opacity: 1; }
.wc-sidebar a.active {
  background: #E8F3FF; color: var(--c-primary); font-weight: 500;
}
.wc-sidebar a.active svg { opacity: 1; }

/* Backdrop for mobile drawer */
.wc-sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 149;
  background: rgba(0,0,0,.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.wc-sidebar-backdrop.open { display: block; }

/* ── Main content ───────────────────────────────────── */
.wc-admin-main {
  flex: 1; min-width: 0;
  padding: 32px 32px 80px;
}

/* ── Page wrapper (non-sidebar pages) ──────────────── */
.wc-wrap { max-width: 1100px; margin: 0 auto; padding: 32px 24px 80px; }

/* ── Page header ────────────────────────────────────── */
.wc-page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.wc-page-title {
  font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.wc-page-sub { font-size: 13px; color: var(--c-muted); margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────── */
.wc-card {
  background: var(--c-surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
}
.wc-card + .wc-card { margin-top: 20px; }
.wc-card-title {
  font-size: 16px; font-weight: 600; margin-bottom: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Stat tiles ─────────────────────────────────────── */
.wc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.wc-stat-tile {
  background: var(--c-surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
}
.wc-stat-tile .num {
  font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -.03em;
}
.wc-stat-tile .label { font-size: 12px; color: var(--c-muted); margin-top: 4px; }

/* ── Tables ─────────────────────────────────────────── */
.wc-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wc-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.wc-table th {
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--c-muted); text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 14px; border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.wc-table td {
  padding: 11px 14px; font-size: 14px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle; white-space: nowrap;
}
.wc-table tr:last-child td { border-bottom: none; }
.wc-table tbody tr:hover td { background: #F9F9FB; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 15px; border-radius: var(--r-btn);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: filter .12s; white-space: nowrap;
}
.btn:hover { filter: brightness(.95); }
.btn:active { filter: brightness(.9); }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-danger  { background: var(--c-danger);  color: #fff; }
.btn-success { background: var(--c-success); color: #fff; }
.btn-ghost   {
  background: var(--c-surface); color: var(--c-text);
  border-color: var(--c-border);
}
.btn-ghost:hover { background: var(--c-bg); filter: none; }
.btn-sm { padding: 4px 11px; font-size: 12px; border-radius: 6px; }
.btn[disabled], .btn:disabled { opacity: .45; pointer-events: none; }

/* ── Forms ──────────────────────────────────────────── */
.wc-form-group { margin-bottom: 16px; }
.wc-label {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 5px; color: var(--c-text);
}
.wc-input, .wc-select, .wc-textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--c-border); border-radius: var(--r-btn);
  font-size: 14px; color: var(--c-text); background: var(--c-surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.wc-input:focus, .wc-select:focus, .wc-textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(0,122,255,.12);
}
.wc-textarea { resize: vertical; min-height: 84px; }
.wc-hint { font-size: 12px; color: var(--c-muted); margin-top: 4px; }

/* ── Badges ─────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 20px; font-size: 11.5px; font-weight: 500;
}
.badge-blue   { background: #E5F0FF; color: #0062CC; }
.badge-green  { background: #E6F9EE; color: #1A7F3C; }
.badge-red    { background: #FFE9E9; color: #C0392B; }
.badge-orange { background: #FFF3E0; color: #B35900; }
.badge-gray   { background: #F0F0F2; color: #6E6E73; }

/* ── Alerts ─────────────────────────────────────────── */
.wc-alert {
  padding: 12px 16px; border-radius: var(--r-card);
  font-size: 13.5px; margin-bottom: 16px; line-height: 1.5;
}
.wc-alert-info    { background: #E5F0FF; color: #0051A8; }
.wc-alert-success { background: #E6F9EE; color: #1A7F3C; }
.wc-alert-warn    { background: #FFF3E0; color: #804000; }
.wc-alert-error   { background: #FFE9E9; color: #C0392B; }

/* ── Pagination ─────────────────────────────────────── */
.wc-pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 20px; }
.wc-pager a, .wc-pager span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 6px;
  border-radius: 8px; font-size: 13px;
  border: 1px solid var(--c-border); background: var(--c-surface);
  text-decoration: none; color: var(--c-text);
}
.wc-pager a:hover { background: #F0F6FF; border-color: var(--c-primary); color: var(--c-primary); }
.wc-pager span.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* ── Empty state ────────────────────────────────────── */
.wc-empty { text-align: center; padding: 56px 20px; color: var(--c-muted); }
.wc-empty .icon { font-size: 36px; margin-bottom: 12px; }
.wc-empty p { margin: 0; font-size: 14px; }

/* ── Login page ─────────────────────────────────────── */
.wc-login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--c-bg); padding: 24px;
}
.wc-login-box {
  width: 100%; max-width: 380px;
  background: var(--c-surface);
  border-radius: 18px; box-shadow: 0 4px 40px rgba(0,0,0,.1);
  padding: 40px 36px;
}
.wc-login-box h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.02em; }
.wc-login-box .sub { color: var(--c-muted); font-size: 13px; margin-bottom: 28px; }

/* ── Footer ─────────────────────────────────────────── */
.wc-footer { text-align: center; padding: 20px; font-size: 12px; color: var(--c-muted); }

/* ── Misc ───────────────────────────────────────────── */
.text-muted   { color: var(--c-muted); }
.text-danger  { color: var(--c-danger); }
.text-success { color: var(--c-success); }
.mono { font-family: "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 1024px) {
  .wc-card-title { font-size: 18px; }
  .wc-table th { font-size: 13px; }
  .wc-table td { font-size: 15px; }
}

/* ── Responsive: Tablet (768–1023 px) ──────────────── */
@media (max-width: 1023px) {
  .wc-sidebar {
    width: var(--sidebar-compact);
    min-width: var(--sidebar-compact);
  }
  .wc-sidebar-section { opacity: 0; height: 0; padding: 0; overflow: hidden; }
  .wc-sidebar a {
    justify-content: center;
    padding: 10px 0; margin: 1px 5px;
    gap: 0;
  }
  .wc-sidebar a .nav-label { display: none; }
  .wc-sidebar a svg { width: 17px; height: 17px; opacity: .68; }
  .wc-admin-main { padding: 24px 20px 60px; }
}

/* ── Responsive: Mobile (< 768 px) ─────────────────── */
@media (max-width: 767px) {
  .wc-hamburger { display: flex; }
  .wc-nav { padding: 0 12px; }
  .wc-nav-user .nav-user-name { display: none; }
  .wc-nav-badge { display: none; }

  /* sidebar becomes a fixed drawer */
  .wc-sidebar {
    position: fixed;
    top: var(--nav-h); left: 0;
    height: calc(100vh - var(--nav-h));
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    z-index: 150;
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-float);
  }
  .wc-sidebar.open { transform: translateX(0); }

  /* restore full layout inside the drawer */
  .wc-sidebar.open .wc-sidebar-section {
    opacity: 1; height: auto; padding: 14px 14px 7px; overflow: visible;
  }
  .wc-sidebar a {
    justify-content: flex-start;
    padding: 10px 10px 10px 12px; margin: 4px 4px; gap: 11px;
  }
  .wc-sidebar a .nav-label { display: inline; }
  .wc-sidebar a svg { opacity: .6; }

  .wc-admin-main { padding: 20px 16px 60px; }
  .wc-wrap { padding: 20px 16px 60px; }
  .wc-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .wc-stat-tile { padding: 14px 16px; }
  .wc-stat-tile .num { font-size: 26px; }
  .wc-card { padding: 18px 16px; }
  .wc-card { overflow-x: auto; }
  .wc-login-box { padding: 32px 24px; }
  .wc-page-header { flex-direction: column; gap: 10px; }
  .wc-page-title { font-size: 19px; }
}

/* ── Responsive: Small phones (< 420 px) ───────────── */
@media (max-width: 419px) {
  .wc-stats { grid-template-columns: 1fr; }
  .wc-pager a, .wc-pager span { min-width: 28px; height: 28px; font-size: 12px; }
}
