/* TimeBuddy - 모던 미니멀 테마 (딥 네이비 + 파우더 블루 + 웜 화이트) */

:root {
  --primary: #1e3a5f;        /* 딥 네이비 */
  --primary-light: #2d5186;  /* 미디엄 네이비 */
  --primary-dark: #142743;   /* 더 짙은 네이비 */
  --primary-bg: #f8f9fc;     /* 쿨한 오프화이트 */
  --accent: #4a90c4;         /* 스틸 블루 */
  --accent-light: #c8e3f5;   /* 파우더 블루 (이미지 색상) */
  --white: #ffffff;
  --border: #dde4ed;
  --text-dark: #111827;
  --text-mid: #4b5563;
  --text-light: #9ca3af;
  --shadow: 0 2px 12px rgba(30,58,95,0.10);
  --hour-height: 60px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: var(--primary-bg);
  color: var(--text-dark);
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* ─── 헤더 ─── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 54px;
  min-width: 0;
}

/* ─── 타임버디 글자 로고 ─── */
.header-title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo-time {
  color: #ffffff;
  font-style: normal;
}

.logo-buddy {
  color: var(--accent-light);
  font-style: normal;
}

/* ─── 온보딩 로고 ─── */
.onboarding-logo {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 8px;
  line-height: 1;
}

.onboarding-logo .logo-time {
  color: var(--primary);
}

.onboarding-logo .logo-buddy {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.header-icon-btn:hover { background: rgba(255,255,255,0.22); }

.header-text-btn {
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.header-text-btn:hover { background: rgba(255,255,255,0.22); }

/* ─── 탭 ─── */
.nav-tabs {
  display: flex;
  background: #ffffff;
  border-bottom: 2px solid var(--border);
}

.nav-tab {
  flex: 1;
  padding: 11px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  text-align: center;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--accent);
  background: #f0f5fc;
}

/* ─── 멤버 바 ─── */
.members-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 6px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
  background: var(--primary-bg);
  border: 1.5px solid var(--border);
  white-space: nowrap;
}
.member-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── 공유 패널 ─── */
.share-panel {
  background: #edf4fb;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.share-panel-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}
.share-panel-sub {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 10px;
}
.share-url-box {
  display: flex;
  gap: 8px;
}
.share-url-input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-mid);
  background: var(--white);
  outline: none;
}
.copy-btn {
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.copy-btn:hover { background: var(--primary-dark); }

/* ─── 날짜 네비게이션 ─── */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.date-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--primary-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mid);
  font-size: 12px;
  transition: all 0.2s;
}
.date-nav-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.date-nav-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-dark);
  min-width: 150px;
  text-align: center;
}
.today-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--accent);
  background: var(--white);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.today-btn:hover { background: var(--accent); color: #fff; }

/* ─── 탭 콘텐츠 ─── */
.tab-content { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; }

/* ─── 시간표 공통 ─── */
.timetable-wrapper {
  overflow-y: auto;
  overflow-x: auto;
  flex: 1;
  background: var(--white);
}
.time-slot {
  height: var(--hour-height);
  border-top: 1px solid #eaecf0;
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
  padding-right: 6px;
  justify-content: flex-end;
  color: #333333;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ─── 주간 뷰 ─── */
.weekly-header {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
}
.weekly-day-header {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 8px 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dark);
  border-left: 1px solid var(--border);
}
.weekly-day-header.sun { color: #c0392b; }
.weekly-day-header.sat { color: #2980b9; }
.weekly-day-header.today { color: var(--primary); }
.weekly-day-header .day-num {
  display: inline-flex;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}
.weekly-day-header.today .day-num {
  background: var(--primary);
  color: #fff;
}
.weekly-grid-body { display: flex; flex: 1; }
.weekly-time-col { width: 44px; flex-shrink: 0; }
.weekly-day-col {
  flex: 1;
  min-width: 0;
  position: relative;
  border-left: 1px solid var(--border);
}
.hour-line {
  height: var(--hour-height);
  border-top: 1px solid #eaecf0;
}
.hour-line:nth-child(even) { background: #f9fafb; }

/* ─── 일간 뷰 ─── */
.daily-hour-row {
  height: var(--hour-height);
  border-top: 1px solid #eaecf0;
}
.daily-hour-row:nth-child(even) { background: #f9fafb; }

/* ─── 월간 뷰 ─── */
.monthly-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 2px solid var(--border);
  background: #ffffff;
}
.monthly-day-name {
  text-align: center;
  padding: 8px 0;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dark);
}
.monthly-day-name:first-child { color: #c0392b; }
.monthly-day-name:last-child { color: #2980b9; }

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #ffffff;
}
.monthly-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 90px;
  padding: 4px;
  cursor: pointer;
  transition: background 0.15s;
  background: #ffffff;
}
.monthly-cell:nth-child(7n) { border-right: none; }
.monthly-cell:hover { background: #eef4fb; }
.monthly-cell.today { background: #dceef9; }
.monthly-cell.other-month .day-num-m { color: var(--text-light); }
.monthly-cell .day-num-m {
  display: inline-flex;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}
.monthly-cell.today .day-num-m {
  background: var(--primary);
  color: #fff;
}
.monthly-cell.sun .day-num-m { color: #c0392b; }
.monthly-cell.sat .day-num-m { color: #2980b9; }
.monthly-event {
  display: block;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0.9;
}

/* ─── 이벤트 블록 ─── */
.event-block {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dark);
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  z-index: 5;
  border-left: 3px solid rgba(0,0,0,0.18);
}
.event-block:hover { opacity: 0.85; transform: scaleY(1.02); z-index: 10; }
.event-block .event-title {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-block .event-time {
  font-size: 10px;
  opacity: 0.7;
  white-space: nowrap;
}

/* ─── 현재 시간선 ─── */
.current-time-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 20;
  pointer-events: none;
}
.current-time-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

/* ─── FAB ─── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 18px rgba(30,58,95,0.35);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 200;
}
.fab:hover { background: var(--primary-dark); transform: scale(1.07); }
.fab:active { transform: scale(0.96); }

/* ─── 모달 ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,15,30,0.50);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
}
.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 0 auto 20px;
}
.modal-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--text-dark);
}

/* ─── 폼 ─── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-mid);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  color: var(--text-dark);
  background: var(--primary-bg);
}
.form-input:focus { border-color: var(--accent); background: var(--white); }

/* ─── 색상 선택 ─── */
.color-picker-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.color-dot.selected {
  border-color: var(--primary-dark);
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ─── 버튼 ─── */
.btn {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef2f7; color: var(--text-mid); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #fef2f2; color: #991b1b; border: 1.5px solid #fecaca; }
.btn-danger:hover { background: #991b1b; color: #fff; }
.btn-row { display: flex; gap: 8px; margin-top: 20px; }

/* ─── 온보딩 ─── */
.onboarding-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--primary-bg);
  overflow-y: auto;
}
.onboarding-card {
  background: var(--white);
  border-radius: 24px;
  padding: 36px 28px 32px;
  box-shadow: 0 8px 40px rgba(30,58,95,0.10);
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.onboarding-emoji { font-size: 52px; margin-bottom: 10px; }
.onboarding-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 4px;
  letter-spacing: 1px;
  font-style: italic;
}
.onboarding-sub {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 28px;
  line-height: 1.5;
}
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--text-light);
  font-size: 11px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.token-row { display: flex; gap: 8px; }

/* ─── 토스트 ─── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ─── 설정 바텀시트 ─── */
.settings-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.settings-item:last-child { border-bottom: none; }
.settings-item:hover { background: #eef4fb; }
.settings-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.settings-label { font-size: 14px; font-weight: 700; color: var(--text-dark); }
.settings-sub { font-size: 11px; color: var(--text-light); margin-top: 1px; }

/* ─── 커스텀 시간 선택기 ─── */
.time-picker-wrap {
  position: relative;
  width: 100%;
}
.time-display {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  background: var(--primary-bg);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s;
  user-select: none;
  -webkit-user-select: none;
}
.time-display:focus,
.time-display.open {
  border-color: var(--accent);
  background: var(--white);
  outline: none;
}
.time-display-icon {
  color: var(--text-light);
  font-size: 13px;
}

.time-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(30,58,95,0.12);
  z-index: 600;
  overflow: hidden;
}
.time-dropdown.open { display: block; }

.time-scroll-row {
  display: flex;
  height: 200px;
}
.time-scroll-col {
  flex: 1;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid var(--border);
}
.time-scroll-col:last-child { border-right: none; }
.time-scroll-col::-webkit-scrollbar { display: none; }

.time-scroll-col .col-label {
  text-align: center;
  padding: 8px 0 4px;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--primary-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.time-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-mid);
  cursor: pointer;
  scroll-snap-align: start;
  transition: background 0.15s, color 0.15s;
}
.time-item:hover { background: var(--primary-bg); }
.time-item.selected {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.time-confirm-row {
  display: flex;
  border-top: 1px solid var(--border);
}
.time-confirm-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.time-confirm-btn:hover { background: var(--primary-dark); }
.time-cancel-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--primary-bg);
  color: var(--text-mid);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

/* ─── 스크롤바 ─── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── 반응형 ─── */
@media (max-width: 480px) {
  :root { --hour-height: 56px; }
  .weekly-day-header .day-num { width: 22px; height: 22px; font-size: 12px; }
  .weekly-day-header { font-size: 10px; }
  .modal-box { border-radius: 18px 18px 0 0; padding: 20px 14px 28px; }
  .form-input[type="date"] { font-size: 12px; padding: 9px 8px; }
  .time-display { font-size: 12px; padding: 9px 8px; }
  .time-display-icon { display: none; }
  .header-title { font-size: 18px; }
}
