/**
 * style.css
 * 伊尚校服 - 蓝白主题样式（v2.0 扩展版）
 * 主色 #2563eb / 背景 #f8fafc / 卡片白底带阴影
 *
 * v2.0 新增：收款状态三色徽标 / 收款弹窗 / 价格学校管理 / 订单详情 / 登录遮罩 / 小孩块
 */

/* ═══════════════ Reset & Base ═══════════════ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-bg: #f8fafc;
  --color-card: #ffffff;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-border: #e2e8f0;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-success: #22c55e;
  --color-success-hover: #16a34a;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-info: #3b82f6;
  --color-info-light: #dbeafe;
  --color-orange: #f97316;
  --color-orange-light: #ffedd5;
  --sidebar-width: 240px;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --transition: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════ Layout ═══════════════ */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e3a5f 0%, #1e293b 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1001;
  transition: transform 0.3s ease;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ═══════════════ Sidebar ═══════════════ */

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo h1 {
  font-size: 20px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 24px;
}

.sidebar-logo .version {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 14px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(37, 99, 235, 0.25);
  color: #fff;
  border-left-color: var(--color-primary);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.merchant-info {
  margin-bottom: 8px;
}

.merchant-label {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 2px;
}

.merchant-phone {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
}

.brand-tag {
  font-size: 11px;
  color: #64748b;
  text-align: center;
  margin-top: 8px;
}

/* ═══════════════ Top Bar (mobile) ═══════════════ */

.top-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

#menu-toggle {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--color-text);
  padding: 4px 8px;
}

.top-bar-title {
  font-size: 16px;
  font-weight: 600;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

/* ═══════════════ Page ═══════════════ */

.page {
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

/* ═══════════════ Stat Cards ═══════════════ */

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

.stat-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition);
  border: 1px solid var(--color-border);
  cursor: default;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-icon {
  font-size: 32px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light);
  border-radius: 12px;
  flex-shrink: 0;
}

.stat-icon.warning {
  background: var(--color-warning-light);
}

.stat-icon.orange {
  background: var(--color-orange-light);
}

.stat-icon.success {
  background: #d1fae5;
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  word-break: break-all;
}

/* ═══════════════ Toolbar ═══════════════ */

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.search-box:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.filter-select {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  background: #fff;
  cursor: pointer;
  min-width: 120px;
}

.filter-select:focus {
  border-color: var(--color-primary);
}

/* ═══════════════ Table ═══════════════ */

.table-wrapper {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  border: 1px solid var(--color-border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.data-table thead {
  background: #f1f5f9;
}

.data-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--color-text-secondary);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

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

.data-table tbody tr:hover {
  background: #f8fafc;
}

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

.data-table small {
  color: var(--color-text-secondary);
  font-size: 12px;
}

/* ═══════════════ Status Badges ═══════════════ */

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* 旧版状态（保留兼容） */
.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-settled {
  background: #d1fae5;
  color: #065f46;
}

/* v2.0 收款状态三色徽标 */
.status-awaiting {
  background: #f1f5f9;
  color: #475569;
}

.status-partial {
  background: var(--color-orange-light);
  color: #9a3412;
}

.status-paid {
  background: #d1fae5;
  color: #065f46;
}

/* ═══════════════ Buttons ═══════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--color-text);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

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

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

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover {
  background: var(--color-success-hover);
}

.btn-warning {
  background: var(--color-warning);
  color: #fff;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* ═══════════════ Forms ═══════════════ */

.form-section {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.form-section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-primary);
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row > .form-group {
  flex: 1;
  min-width: 180px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.required {
  color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: #fff;
  color: var(--color-text);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input[readonly] {
  background: #f1f5f9;
  color: var(--color-text-secondary);
  cursor: default;
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
}

.form-select {
  cursor: pointer;
  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 fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.radio-group {
  display: flex;
  gap: 20px;
  padding-top: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
}

.radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 0;
}

/* ═══════════════ Order Item Rows ═══════════════ */

.order-items {
  margin-bottom: 12px;
}

.item-row-header {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr 1fr 70px;
  gap: 8px;
  padding: 0 8px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.item-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr 1fr 70px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.item-row .form-input,
.item-row .form-select {
  padding: 7px 10px;
  font-size: 13px;
}

.item-amount {
  background: #f1f5f9 !important;
  font-weight: 600;
  color: var(--color-primary) !important;
  text-align: right;
}

.total-amount-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px;
  background: var(--color-primary-light);
  border-radius: var(--radius);
  margin-top: 8px;
}

.total-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.total-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-primary);
}

/* ═══════════════ Child Block (多小孩) ═══════════════ */

.child-block {
  background: #f8fafc;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
}

.child-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--color-border);
}

.child-block-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-primary);
}

.child-block-subtotal {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.child-block-subtotal .amount {
  color: var(--color-primary);
  font-size: 16px;
}

/* ═══════════════ Modal ═══════════════ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background var(--transition);
}

.modal-close:hover {
  background: #f1f5f9;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ═══════════════ Payment Modal Specifics ═══════════════ */

.payment-summary {
  background: var(--color-primary-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.payment-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  margin-bottom: 6px;
}

.payment-summary-row:last-child {
  margin-bottom: 0;
}

.payment-summary-row .label {
  color: var(--color-text-secondary);
}

.payment-summary-row .value {
  font-weight: 600;
  color: var(--color-text);
}

.payment-summary-row .value.highlight {
  color: var(--color-primary);
  font-size: 18px;
}

.payment-summary-row .value.danger {
  color: var(--color-danger);
}

/* ═══════════════ Order Detail Page ═══════════════ */

.order-detail-section {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.order-detail-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-primary);
}

.order-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.order-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-info-label {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.order-info-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.payment-record-list {
  list-style: none;
}

.payment-record-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.payment-record-item:last-child {
  border-bottom: none;
}

.payment-record-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.payment-record-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-success);
}

.payment-record-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ═══════════════ Login Overlay ═══════════════ */

.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 32px;
  width: 90%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

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

.login-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 12px;
}

.login-header p {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-top: 6px;
}

.login-form .form-group {
  margin-bottom: 16px;
}

.login-form .btn {
  margin-top: 8px;
}

/* ═══════════════ Toast ═══════════════ */

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(100px);
  transition: all 0.3s ease;
  max-width: 360px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: var(--color-success);
}

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

.toast-info {
  background: var(--color-primary);
}

.toast-warning {
  background: var(--color-warning);
}

/* ═══════════════ Empty State ═══════════════ */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-secondary);
}

.empty-state p {
  font-size: 15px;
  margin-bottom: 16px;
}

.empty-state td {
  text-align: center;
  color: var(--color-text-secondary);
  padding: 40px 14px;
  font-size: 14px;
}

/* ═══════════════ Merchant Page ═══════════════ */

.merchant-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  max-width: 500px;
}

.merchant-card .form-group {
  margin-bottom: 20px;
}

.merchant-card .btn {
  margin-top: 8px;
}

/* ═══════════════ Loading ═══════════════ */

.loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--color-text-secondary);
}

.loading-spinner::after {
  content: "";
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* ═══════════════ Responsive ═══════════════ */

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

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .top-bar {
    display: flex;
  }

  .page {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row > .form-group {
    min-width: 100%;
  }

  .item-row,
  .item-row-header {
    grid-template-columns: 1fr 70px 80px 90px 56px;
  }

  .item-row-header {
    display: none;
  }

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

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .btn {
    width: 100%;
  }

  .order-info-grid {
    grid-template-columns: 1fr;
  }

  #toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 18px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-icon {
    font-size: 24px;
    width: 44px;
    height: 44px;
  }
}
