/* =========================================================
   思壯補習班 — 學生點餐 LIFF
   LINE 風格：白底、綠色主色 #06C755、圓角、卡片式區塊
   ========================================================= */

:root {
  --line-green: #06C755;
  --line-green-dark: #05b34b;
  --line-green-light: #e8f8ee;
  --text-main: #111111;
  --text-sub: #666666;
  --text-muted: #999999;
  --bg-page: #f7f8fa;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--bg-page);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Loading ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--line-green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.loading-text {
  margin-top: 16px;
  color: var(--text-sub);
}

/* ---------- Error screen ---------- */
.error-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  background: var(--bg-page);
}

.error-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.error-screen h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.error-screen p {
  margin: 0 0 24px;
  color: var(--text-sub);
  max-width: 320px;
}

/* ---------- Success screen ---------- */
.success-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  background: var(--bg-page);
}

.success-icon {
  font-size: 64px;
  margin-bottom: 12px;
}

.success-screen h2 {
  margin: 0 0 16px;
  color: var(--line-green);
  font-size: 22px;
}

.success-details {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  min-width: 260px;
}

.success-total {
  font-size: 20px;
  font-weight: 600;
  margin: 8px 0;
}

/* ---------- Main page ---------- */
.order-page {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 120px; /* 保留底部送出按鈕空間 */
}

/* ---------- Header ---------- */
.header {
  background: var(--line-green);
  color: #fff;
  padding: 20px 16px 16px;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.header-student {
  font-size: 15px;
  margin-bottom: 4px;
}

.header-meta {
  font-size: 13px;
  display: flex;
  gap: 12px;
  opacity: 0.95;
}

/* ---------- Deadline banner ---------- */
.deadline-banner {
  background: #fff7e6;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
  padding: 12px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

/* ---------- Store section ---------- */
.store-section {
  background: var(--bg-card);
  margin: 12px;
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.store-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.store-fee {
  color: var(--text-sub);
  font-size: 13px;
}

/* ---------- Sections ---------- */
.menu-section,
.summary-section {
  background: var(--bg-card);
  margin: 12px;
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.section-title {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--text-sub);
  font-weight: 600;
}

/* ---------- Menu items ---------- */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

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

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

.menu-item-name {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item-price {
  color: var(--text-sub);
  font-size: 13px;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--line-green-light);
  color: var(--line-green);
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: background 0.15s;
}

.qty-btn:active {
  background: var(--line-green);
  color: #fff;
}

.qty-btn:disabled {
  background: #f3f4f6;
  color: #cbd5e1;
  cursor: not-allowed;
}

.qty-value {
  min-width: 24px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

/* ---------- Summary ---------- */
.summary-items {
  margin-bottom: 8px;
}

.summary-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 8px 0;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.summary-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.summary-total {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

/* ---------- Submit ---------- */
.submit-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px 20px;
  background: linear-gradient(
    to top,
    rgba(247, 248, 250, 1) 60%,
    rgba(247, 248, 250, 0)
  );
  z-index: 100;
}

.submit-wrap .btn-primary {
  max-width: 480px;
  margin: 0 auto;
  display: block;
}

.btn-primary {
  background: var(--line-green);
  color: #fff;
  padding: 14px 24px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  transition: background 0.15s, transform 0.1s;
  box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
  background: var(--line-green-dark);
  transform: translateY(1px);
}

.btn-primary:disabled {
  background: #d1d5db;
  color: #f3f4f6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 15px;
}

.btn-ghost:active {
  background: #f3f4f6;
}

/* ---------- Footer ---------- */
.footer {
  padding: 16px;
  text-align: center;
}

/* ---------- Disabled overlay (deadline passed) ---------- */
.order-page.is-disabled .menu-section,
.order-page.is-disabled .submit-wrap {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Confirm dialog ---------- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 500;
}

.dialog {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.dialog h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.dialog-content {
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-sub);
}

.dialog-content .confirm-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.dialog-content .confirm-total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 8px;
  font-weight: 600;
  color: var(--text-main);
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.dialog-actions .btn-primary {
  width: auto;
  padding: 10px 20px;
  font-size: 15px;
}
