/**
 * 门店配送协同系统 - 样式表
 */

/* ============================================================
   变量定义
   ============================================================ */
:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --soft: #f4f7fb;
  --panel: #ffffff;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #b42318;
  --purple: #6d28d9;
  --green: #059669;
  --green-light: #10b981;
  --shadow: 0 16px 42px rgba(16, 24, 40, 0.08);
}

/* ============================================================
   基础重置
   ============================================================ */
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ============================================================
   布局
   ============================================================ */
.app { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
.hidden { display: none !important; }

/* ============================================================
   加载状态
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--soft);
  z-index: 9999;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============================================================
   登录页
   ============================================================ */
.login-page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a365d 0%, #2d3748 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .brand-mark {
  display: inline-flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  color: #fff;
  font-size: 32px;
  font-weight: 900;
  border-radius: 16px;
  margin-bottom: 16px;
}

.login-header h1 { font-size: 24px; margin: 0 0 8px; }
.login-header p { color: var(--muted); margin: 0; font-size: 14px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--ink); }
.form-group input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
}

.login-btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.login-btn:hover { background: var(--blue-strong); }
.login-tip { text-align: center; color: var(--muted); font-size: 13px; margin-top: 16px; }

/* ============================================================
   侧边栏
   ============================================================ */
.side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: #101828;
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  font-size: 24px;
  font-weight: 900;
}

.brand h1 { font-size: 22px; margin: 0; }
.brand p { margin: 3px 0 0; color: #cbd5e1; font-size: 13px; }

.login-card { display: flex; flex-direction: column; gap: 12px; }
.user-info { display: flex; flex-direction: column; gap: 4px; }
.user-name { font-size: 16px; font-weight: 700; }
.user-store { font-size: 13px; color: #a0aec0; }

.logout-btn {
  height: 36px;
  border: 1px solid #475467;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 14px;
}

.logout-btn:hover { background: rgba(255,255,255,0.1); }

.side-nav { display: grid; gap: 8px; }

.side-tab {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: #d8e1ef;
  text-align: left;
  font-size: 15px;
}

.side-tab.active, .side-tab:hover {
  border-color: #344054;
  background: #1d2939;
  color: #fff;
}

.voice-box { margin-top: auto; }
.switch-row { display: flex; align-items: center; gap: 9px; color: #e5e7eb; }
.switch-row input { width: 18px; height: 18px; }

/* ============================================================
   主内容区
   ============================================================ */
.main { min-width: 0; padding: 28px; }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar p { margin: 0 0 6px; color: var(--muted); }
.topbar h2 { font-size: 30px; margin: 0; }

.clock { text-align: right; color: var(--muted); }
.clock strong { display: block; margin-top: 3px; color: var(--ink); font-size: 23px; }

/* 指标卡片 */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.05);
}

.metric-grid span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-grid strong { display: block; margin-top: 8px; font-size: 30px; }

/* 角色视图 */
.role-view { display: none; }
.role-view.active { display: block; }

/* 工作区网格 */
.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 16px;
  margin-bottom: 16px;
}

.work-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 { font-size: 21px; margin: 0; }
.panel-head p { margin: 5px 0 0; color: var(--muted); line-height: 1.45; }

/* ============================================================
   表单
   ============================================================ */
.flow-form { display: grid; gap: 14px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend, label > span { display: block; margin-bottom: 7px; color: #344054; font-weight: 800; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input, select { height: 42px; padding: 0 11px; }
textarea { min-height: 96px; resize: vertical; padding: 11px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid rgba(37,99,235,0.14); }

.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: 1.1fr 1fr 1fr; }

.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span {
  display: grid;
  min-height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344054;
  font-weight: 900;
}

.segmented input:checked + span {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue-strong);
}

.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.check-grid label {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fafbff;
}
.check-grid input { width: auto; height: auto; }

.primary-button {
  min-height: 40px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}
.primary-button:hover { background: var(--blue-strong); }

/* ============================================================
   列表卡片
   ============================================================ */
.item-list { display: grid; gap: 12px; }

.work-item {
  display: grid;
  gap: 11px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.delivery-item { border-left-color: var(--teal); }

.work-item header, .work-item footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.work-item h4, .work-item p { margin: 0; }
.work-item h4 { font-size: 20px; }
.work-item time { color: var(--muted); font-size: 13px; }

.pill, .status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 900;
}

.department { background: #dbeafe; color: #1e40af; }
.kind { background: #ede9fe; color: var(--purple); }
.direction { background: #ccfbf1; color: #115e59; }
.carrier { background: #fef3c7; color: var(--amber); }
.status { background: #f2f4f7; color: #344054; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  font-size: 13px;
}

.actions button:hover { border-color: var(--blue); color: var(--blue-strong); }
.actions button.danger { color: var(--red); }
.actions button.danger:hover { border-color: var(--red); }

/* ============================================================
   公示大屏
   ============================================================ */
.board-list { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }

.board-delivery-item {
  border-left: 6px solid var(--teal);
  padding: 20px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fffe 100%);
}

.board-delivery-item .board-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.board-delivery-item .board-store-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.board-delivery-item .board-store { font-size: 26px; font-weight: 900; color: var(--ink); }
.board-delivery-item .board-direction {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 900;
  background: #ccfbf1;
  color: #115e59;
}

.board-code-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 50%, var(--green) 100%);
  border-radius: 16px;
  padding: 24px 32px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.3);
}

.board-code-label { font-size: 28px; font-weight: 700; color: rgba(255,255,255,0.9); }
.board-code {
  font-size: 72px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 2px 4px 8px rgba(0,0,0,0.2);
  letter-spacing: 8px;
  line-height: 1;
}

.board-delivery-item .board-info { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.board-delivery-item .board-carrier {
  display: inline-flex;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 900;
  background: #fef3c7;
  color: var(--amber);
}

.board-delivery-item .board-status {
  display: inline-flex;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 900;
  background: #f2f4f7;
  color: #344054;
}

.board-delivery-item .board-content-wrap { border-top: 1px solid var(--line); padding-top: 12px; }
.board-delivery-item .board-content { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0 0 8px; }
.board-delivery-item .board-details { font-size: 14px; color: var(--muted); margin: 0; line-height: 1.5; }

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

/* ============================================================
   Toast 通知
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: #1a365d;
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; }
  .work-grid, .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .main, .side { padding: 18px; }
  .topbar, .panel-head, .work-item header, .work-item footer { align-items: stretch; flex-direction: column; }
  .clock { text-align: left; }
  .work-grid, .metric-grid, .form-grid.two, .form-grid.three, .segmented, .check-grid, .board-list { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
  .board-delivery-item .board-code { font-size: 56px; }
  .board-delivery-item .board-code-wrap { padding: 18px 24px; }
  .board-delivery-item .board-store { font-size: 22px; }
}
