/* Conference Room Booking — styles. Mobile-first, big touch targets. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1a2333;
  --muted: #68748c;
  --line: #e2e7f0;
  --accent: #2f6fed;
  --accent-dark: #2058c9;
  --mine: #e8f0ff;
  --danger: #d64545;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 18px; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.linkbtn {
  background: none; border: none; color: var(--accent); font-size: 14px;
  cursor: pointer; padding: 8px; min-height: 44px;
}

/* ---------- cards / forms ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px;
  box-shadow: 0 2px 10px rgba(20, 40, 90, .06);
}
.auth-card { max-width: 420px; margin: 8vh auto 0; }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.tabs { display: flex; gap: 8px; margin: 18px 0 14px; }
.tab {
  flex: 1; padding: 12px; min-height: 44px; border: 1px solid var(--line);
  background: #f8fafd; border-radius: 10px; font-size: 15px; cursor: pointer;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

label { display: block; margin: 12px 0; font-size: 14px; font-weight: 600; }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px;
  font-size: 16px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); min-height: 48px;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

button.primary, button.ghost, button.danger {
  width: 100%; margin-top: 10px; padding: 13px; min-height: 48px;
  font-size: 16px; font-weight: 600; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:active { background: var(--accent-dark); }
button.primary:disabled { opacity: .6; }
button.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
button.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
button.small-btn { width: auto; padding: 8px 14px; min-height: 40px; font-size: 14px; margin-top: 0; }

.msg { margin-top: 12px; font-size: 14px; padding: 10px 12px; border-radius: 8px; background: #eef4ff; color: #274b8f; }
.msg.err { background: #fdecec; color: #a02c2c; }

/* password visibility + auth helpers */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1;
  padding: 6px; margin: 0; width: auto; min-height: 0;
}
.auth-alt { text-align: center; margin: 10px 0 0; }
.link-btn {
  background: none; border: none; color: var(--accent); font-size: 14px; font-weight: 600;
  cursor: pointer; padding: 4px; margin: 0; width: auto; text-decoration: underline;
}

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.week-nav { display: flex; gap: 6px; align-items: center; }
.week-nav button {
  min-width: 48px; min-height: 44px; padding: 8px 14px; font-size: 17px;
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; cursor: pointer;
}
.week-label { font-weight: 700; font-size: 16px; flex: 1; min-width: 140px; }
#room-select { width: auto; min-width: 170px; margin: 0; }

/* ---------- week grid ---------- */
.grid-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.grid { min-width: 950px; }
.grid.workweek { min-width: 690px; }
.grid-head, .grid-body { display: grid; grid-template-columns: 56px repeat(7, minmax(128px, 1fr)); }
.grid.workweek .grid-head, .grid.workweek .grid-body { grid-template-columns: 56px repeat(5, minmax(128px, 1fr)); }
.grid.dayview { min-width: 0; }
.grid.dayview .grid-head, .grid.dayview .grid-body { grid-template-columns: 56px 1fr; }
.view-toggle { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.view-toggle button {
  border: none; background: var(--card); padding: 10px 12px; font-size: 14px;
  min-height: 44px; cursor: pointer; color: inherit;
}
.view-toggle button.active { background: var(--accent); color: #fff; }
.grid-head { border-bottom: 1px solid var(--line); background: #f8fafd; position: sticky; top: 57px; z-index: 10; }
.gh-corner { border-right: 1px solid var(--line); }
.gh-day { padding: 10px 6px; text-align: center; border-right: 1px solid var(--line); }
.gh-day:last-child { border-right: none; }
.gh-day .dow { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.gh-day .dnum { font-size: 16px; font-weight: 700; }
.gh-day.today .dnum, .day-col.today { color: var(--accent-dark); }
.gh-day.today { background: #eef4ff; }

.gutter { position: relative; border-right: 1px solid var(--line); background: #f8fafd; }
.g-label {
  position: absolute; right: 6px; font-size: 11px; color: var(--muted);
  transform: translateY(-2px);
}
.day-col {
  position: relative; border-right: 1px solid var(--line); cursor: pointer;
  background-image:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, #eef1f7 1px, transparent 1px);
  background-size: 100% 92px, 100% 46px;
}
.day-col:last-child { border-right: none; }
.day-col.today { background-color: #f5f9ff; }

.now-line {
  position: absolute; left: 0; right: 0; height: 2px; background: #e5484d; z-index: 5;
  pointer-events: none;
}
.now-line::before {
  content: ""; position: absolute; left: -1px; top: -4px;
  border: 5px solid transparent; border-left-color: #e5484d;
}

.booking {
  position: absolute; left: 4px; right: 4px; z-index: 4;
  background: #dbe7ff; border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 4px 6px; overflow: hidden; cursor: pointer;
}
.booking.mine { background: var(--mine); border-left-color: var(--accent-dark); }
.b-time { font-size: 11px; font-weight: 700; color: #274b8f; white-space: nowrap; }
.b-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-who { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hint { color: var(--muted); font-size: 13px; margin: 8px 2px 20px; }

/* ---------- small screens: fit the week to the screen, one page scroll ---------- */
@media (max-width: 640px) {
  .grid-scroll { overflow-x: visible; }
  .grid { min-width: 0; }
  .grid.workweek { min-width: 0; }
  .grid-head, .grid-body { grid-template-columns: 44px repeat(7, 1fr); }
  .grid.workweek .grid-head, .grid.workweek .grid-body { grid-template-columns: 44px repeat(5, 1fr); }
  .grid.dayview .grid-head, .grid.dayview .grid-body { grid-template-columns: 44px 1fr; }
}

/* ---------- my bookings ---------- */
h2 { font-size: 18px; margin: 8px 0 10px; }
.booking-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 40px; }
.my-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 25, 45, .5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal {
  background: var(--card); border-radius: 16px 16px 0 0; padding: 22px;
  width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
}
@media (min-width: 640px) { .modal { border-radius: 16px; } }
.modal h3 { margin: 0 0 4px; font-size: 20px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.error { color: #a02c2c; font-size: 14px; margin: 8px 0 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px);
  background: #1a2333; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 15px; opacity: 0; transition: all .25s ease; z-index: 100;
  max-width: calc(100vw - 40px); text-align: center; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #a02c2c; }

/* ---------- setup notice ---------- */
.setup-notice {
  max-width: 520px; margin: 10vh auto; padding: 32px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.setup-notice code { background: #eef1f7; padding: 2px 8px; border-radius: 6px; }

/* team access list */
.team-box { margin: 18px 0 8px; border: 1px solid #e2e2e2; border-radius: 10px; padding: 10px 14px; background: #fafafa; }
.team-box summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.team-count { color: #666; font-weight: 400; }
.team-list { list-style: none; margin: 10px 0 4px; padding: 0; }
.team-list li { padding: 6px 0; border-top: 1px solid #eee; font-size: 15px; }
.team-list li:first-child { border-top: none; }
.admin-tag { font-size: 12px; color: #fff; background: #444; border-radius: 8px; padding: 1px 7px; margin-left: 6px; }
