/* REX 練習室預約 — web (Traditional Chinese, mobile-first) */

:root {
  --accent: #1e5fd9;
  --bg: #f4f4f6;
  --card: #ffffff;
  --text: #1c1c1e;
  --secondary: #6e6e73;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC",
    "Microsoft JhengHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

/* ---- shared layout ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 0 6px;
}

.topbar h1 {
  font-size: 30px;
  margin: 0;
  letter-spacing: 0.5px;
}

.topbar .actions { display: flex; gap: 8px; }

.icon-btn {
  border: none;
  background: var(--card);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pill-btn {
  border: none;
  background: var(--card);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}

.pill-btn.destructive { color: var(--red); }

.demo-pill {
  position: fixed;
  top: 10px;
  right: 10px;
  background: var(--orange);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 50;
}

.center-screen {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--secondary);
  gap: 8px;
  padding: 24px 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d9d9de;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  overflow: hidden;
  margin-bottom: 14px;
}

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

/* ---- room cards ---- */

.room-card {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  padding: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  overflow: hidden;
  margin-bottom: 14px;
  cursor: pointer;
}

.room-photo {
  aspect-ratio: 16 / 9;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: linear-gradient(135deg, rgba(30,95,217,0.14), rgba(0,158,166,0.20));
}

.room-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.room-body { padding: 12px 14px 14px; }
.room-body h2 { margin: 0 0 6px; font-size: 17px; }
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* ---- room detail ---- */

.detail-photo {
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: linear-gradient(135deg, rgba(30,95,217,0.14), rgba(0,158,166,0.20));
}

.detail-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.desc { color: var(--secondary); font-size: 14px; margin: 12px 0 4px; }

.date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0 10px;
}

.date-row label { font-weight: 600; }

input[type="date"] {
  border: none;
  background: #e9e9ee;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 15px;
  font-family: inherit;
}

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--secondary); margin-bottom: 12px; }
.legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.slot {
  border: none;
  border-radius: 10px;
  padding: 10px 6px;
  cursor: pointer;
  font-family: inherit;
}

.slot .time { font-weight: 700; font-size: 15px; display: block; }
.slot .state { font-size: 12px; }

.slot-available { background: rgba(52,199,89,0.15); color: #1e8e3e; }
.slot-pending { background: rgba(255,149,0,0.15); color: #c46b00; cursor: default; }
.slot-booked { background: rgba(255,59,48,0.13); color: #d92c22; cursor: default; }
.slot:disabled { cursor: default; }

/* ---- forms ---- */

.form-card { padding: 4px 16px; }

.field { padding: 12px 0; border-bottom: 1px solid #ececf0; }
.field:last-child { border-bottom: none; }
.field label { display: block; font-size: 13px; color: var(--secondary); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 16px;
  font-family: inherit;
  padding: 2px 0;
  outline: none;
  color: var(--text);
}
.field textarea { resize: vertical; min-height: 44px; }

.primary-btn {
  width: 100%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  border-radius: 12px;
  padding: 13px;
  cursor: pointer;
  margin: 18px 0 4px;
}

.primary-btn:disabled { opacity: 0.4; cursor: default; }

.danger-btn {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--red);
  font-size: 16px;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
}

.section-title {
  font-size: 13px;
  color: var(--secondary);
  margin: 22px 4px 8px;
  text-transform: none;
}

/* ---- summary rows / success ---- */

.summary {
  background: var(--card);
  border-radius: 12px;
  padding: 4px 16px;
  margin: 10px 0;
}

.summary .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #ececf0;
  font-size: 15px;
}

.summary .row:last-child { border-bottom: none; }
.summary .row .k { color: var(--secondary); }
.summary .row .v { font-weight: 600; text-align: right; }

.success-wrap { text-align: center; padding-top: 48px; }
.success-wrap .check {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 44px;
  line-height: 84px;
}

/* ---- badges ---- */

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
}
.badge-pending { background: rgba(255,149,0,0.16); color: #c46b00; }
.badge-approved { background: rgba(52,199,89,0.18); color: #1e8e3e; }
.badge-rejected { background: rgba(255,59,48,0.14); color: #d92c22; }
.badge-inactive { background: rgba(120,120,128,0.16); color: var(--secondary); }

/* ---- admin list rows ---- */

.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: none;
  text-align: left;
  background: var(--card);
  padding: 14px 16px;
  border-bottom: 1px solid #ececf0;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}

.row-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.row-item:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
.row-item:only-child { border-radius: var(--radius); }
.row-item .sub { display: block; color: var(--secondary); font-size: 13px; margin-top: 3px; }
.list-stack { margin-top: 8px; }

.list-toolbar { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; align-items: center; }
.list-toolbar select, .list-toolbar input[type="date"] { background: #e9e9ee; border: none; border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit; }
.list-toolbar label { font-size: 14px; color: var(--secondary); display: flex; align-items: center; gap: 6px; }

.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
  pointer-events: none;
}

.tabs-inner {
  pointer-events: auto;
  display: flex;
  background: rgba(246,246,248,0.92);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.16);
  padding: 6px;
}

.tab-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
}

.tab-btn.active { background: var(--accent); color: #fff; }

/* ---- toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(28,28,30,0.92);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 88vw;
  z-index: 100;
  text-align: center;
}

.toast.error { background: rgba(217,44,34,0.95); }

.back-btn {
  border: none;
  background: var(--card);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}
