/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fff;
  color: #000;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 390px;
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
}

/* ===== Colors ===== */
:root {
  --green:   #00E464;
  --green-light: rgba(0, 228, 100, 0.15);
  --black:   #000000;
  --white:   #ffffff;
  --gray:    #999999;
  --gray-dark: #4f4f4f;
  --gray-muted: #ababab;
  --gray-bg: #f5f5f5;
  --border:  #e0e0e0;
}

/* ===== Avatar ===== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  color: #000;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: default;
  user-select: none;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  height: 60px;
  padding: 0 28px;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.75; }
.btn-primary { background: #000; color: #fff; width: 100%; font-size: 16px; font-weight: 700; }
.btn-outline { background: transparent; border: 1.5px solid #000; color: #000; width: 100%; }
.btn-ghost { background: transparent; color: #000; padding: 8px 16px; font-weight: 500; }
.btn-sm { padding: 8px 20px; font-size: 13px; }

/* ===== Form ===== */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 13px; font-weight: 600; color: #000; }

.input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
}
.input:focus { border-color: #000; }
.input.error { border-color: #ff4444; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #000;
  cursor: pointer;
}

.error-msg { font-size: 13px; color: #ff4444; text-align: center; }

/* ===== Login Pages ===== */
.login-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 60px 24px 40px;
  gap: 32px;
  background: var(--gray-bg);
}
.login-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}
.login-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-top: 16px;
}
.login-logo span { color: var(--green); }
.login-form { display: flex; flex-direction: column; gap: 20px; }
.login-footer { margin-top: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.login-footer a { color: #000; font-size: 14px; text-decoration: underline; }
.forgot-link { font-size: 13px; color: var(--gray); text-align: center; cursor: default; }

/* ===== Welcome Page ===== */
.welcome-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--green);
  gap: 24px;
  padding: 40px;
}
.welcome-page .avatar.lg { background: #000; color: var(--green); }
.welcome-initials { font-size: 48px; font-weight: 800; color: #fff; text-align: center; }
.welcome-sub  { font-size: 15px; color: rgba(0,0,0,0.6); text-align: center; }
.welcome-dots { display: flex; gap: 8px; }
.welcome-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.6);
  animation: dotPulse 1.2s ease-in-out infinite;
}
.welcome-dots span:nth-child(2) { animation-delay: 0.2s; }
.welcome-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}
.top-bar .logo { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.top-bar .logo span { color: var(--green); }

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  align-items: center;
  border-bottom: 1.5px solid var(--border);
  margin: 0 20px;
  padding: 16px 0 0;
}
.tab-bar a {
  text-align: center;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 800;
  color: #d9d9d9;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1.5px;
}
.tab-bar a.active { color: #000; border-bottom-color: #000; }
.tab-avatar { margin-left: auto; margin-bottom: 8px; }

/* ===== Month / Week Nav ===== */
.period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}
.period-nav .period-label {
  font-size: 24px;
  font-weight: 800;
}
.nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #000;
  padding: 4px 8px;
}

/* ===== Monthly Calendar Grid ===== */
.cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 8px;
}
.cal-header span {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  padding: 4px 0;
}
/* Weekend headers use same gray as weekdays per Figma */

.cal-grid {
  display: flex;
  flex-direction: column;
  padding: 0 8px 8px;
}

.cal-week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  border-radius: 12px;
  padding: 2px 0;
}
.cal-week-row.current-week {
  border: 1.5px solid var(--border);
  border-radius: 12px;
}

.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px;
  min-height: 70px;
  cursor: pointer;
  border-radius: 8px;
  position: relative;
}
.cal-cell:hover { background: var(--gray-bg); }
.cal-cell.today .date-num {
  background: #000;
  color: #fff;
  border-radius: 10px;
}
.cal-cell.other-month .date-num { color: var(--gray); }
.date-num {
  font-size: 13px;
  font-weight: 500;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Vertical slot dots */
.slot-dots {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
}
.slot-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ddd;
}
.slot-dot.reserved { background: var(--green); }

/* Weekend vertical bar */
.slot-bar {
  width: 6px;
  flex: 1;
  min-height: 40px;
  border-radius: 3px;
  background: var(--border);
  margin-top: 4px;
}
.slot-bar.reserved {
  background: var(--green);
}

/* ===== Monthly Bottom ===== */
.cal-bottom {
  padding: 12px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.cal-bottom .summary { font-size: 14px; color: var(--gray); }
.cal-bottom .summary strong { color: #000; }

/* ===== Weekly Grid (CSS Grid based, mirrors Reservation layout) ===== */
.week-grid {
  display: grid;
  grid-template-columns: 24px repeat(7, 1fr);
  grid-template-rows: 63px 63px 129px 63px 63px;
  gap: 3px;
  padding: 0 4px 12px;
}
.week-cell {
  border: 2px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px;
  background: #fff;
  min-height: 0;
}
.week-cell.mine {
  background: var(--green);
  border-color: var(--green);
}
.week-cell.other {
  background: var(--gray-bg);
  border-color: var(--border);
}
.week-cell.empty {
  background: #fff;
  border-color: var(--border);
}
.week-cell .cell-initials {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-muted);
  line-height: 1;
}
.week-cell .cell-label {
  font-size: 12px;
  color: var(--gray-muted);
  font-weight: 600;
}
.week-cell.mine .cell-initials,
.week-cell.mine .cell-label { color: #fff; }
.week-cell.other .cell-initials,
.week-cell.other .cell-label { color: var(--gray-muted); }

/* Member status */
.member-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 500;
  color: var(--gray-dark);
  cursor: pointer;
}
.member-status .status-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--gray-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--gray-dark);
  font-weight: 700;
}
.member-status.on .status-icon {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.week-grid.member-hidden .week-cell.other .cell-initials,
.week-grid.member-hidden .week-cell.other .cell-label { visibility: hidden; }

/* ===== Reservation Grid ===== */
.res-day-header {
  display: grid;
  grid-template-columns: 24px repeat(7, 1fr);
  padding: 0 4px;
  gap: 3px;
  margin-bottom: 8px;
}
.res-day-header-label { }
.res-day-col-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
}
.res-day-col-header .day-name {
  font-size: 13px;
  font-weight: 500;
  color: #999;
}
.res-day-col-header .day-date {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-dark);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
.res-day-col-header.today .day-date {
  background: #000;
  color: #fff;
}

.res-grid {
  display: grid;
  grid-template-columns: 24px repeat(7, 1fr);
  grid-template-rows: 63px 63px 129px 63px 63px;
  gap: 3px;
  padding: 0 4px 12px;
}

.time-label {
  font-size: 13px;
  color: var(--gray-dark);
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding-left: 2px;
  position: relative;
}
/* Short tick mark at each row top boundary */
.time-label::after {
  content: '';
  position: absolute;
  right: 0;
  top: -2px;
  width: 6px;
  height: 1px;
  background: #999;
}
/* 10: full-width tick line */
.time-label.tick-start::after {
  width: 100%;
  left: 0;
  right: auto;
}
/* 22: line at top of row, text above the line */
.time-label.tick-end {
  align-items: flex-start;
  transform: translateY(-100%);
}
.time-label.tick-end::after {
  width: 100%;
  left: 0;
  right: auto;
  top: auto;
  bottom: -2px;
}

.res-cell {
  border: 2px solid var(--green);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  padding: 8px 2px 8px;
  background: #fff;
  min-height: 0;
}
.res-cell:hover { background: var(--gray-bg); }
.res-cell.mine {
  background: var(--green);
  border-color: var(--green);
}
.res-cell.mine:hover { background: #00cc55; }
.res-cell.other {
  background: var(--gray-bg);
  border: 2px solid var(--border);
  cursor: default;
}
.res-cell.other:hover { background: var(--gray-bg); }
.res-cell.other .cell-initials {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-muted);
  line-height: 1;
}
.res-cell.other .cell-label { color: var(--gray-muted); }
.res-cell.selected {
  background: var(--green-light);
  border-color: var(--green);
}
.res-cell.selected:hover { background: var(--green-light); }

.res-cell-allday {
  /* weekend all-day cell spans 5 rows via inline grid-row */
}

.cell-marker {
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
}
.res-cell.mine .cell-marker { color: #fff; }
.res-cell.selected .cell-marker { color: var(--green); }

.cell-label {
  font-size: 13px;
  color: var(--gray);
  font-weight: 600;
}
.res-cell.mine .cell-label { color: #fff; font-weight: 600; }

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  position: relative;
  padding: 20px 20px 18px;
}
.page-header .back-btn {
  background: none;
  border: none;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  padding: 0;
  line-height: 22px;
  position: absolute;
  left: 20px;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  width: 100%;
  text-align: center;
}

/* ===== Toggle Switch ===== */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 20px;
}
.toggle-label { font-size: 14px; font-weight: 600; }
.toggle { position: relative; width: 44px; height: 26px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 26px;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ===== Bottom Action Bar ===== */
.bottom-bar {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  width: 272px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.modal-card {
  background: var(--green);
  border-radius: 15px;
  width: 80px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.modal-card-date { font-size: 30px; font-weight: 800; color: #fff; line-height: 1; }
.modal-card-slot { font-size: 14px; font-weight: 800; color: #fff; }
.modal-title { font-size: 20px; font-weight: 800; text-align: center; }
.modal-desc { font-size: 16px; font-weight: 500; color: #000; text-align: center; line-height: 24px; }
.modal-actions {
  width: 100%;
}
.modal-actions form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}
.modal-btn {
  width: 220px;
  height: 44px;
  border: 1px solid var(--gray-dark);
  border-radius: 10px;
  background: transparent;
  color: #000;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
