/* ===== 기본 리셋 & 변수 ===== */
:root {
  --primary: #8B6F8B;
  --primary-light: #B89AB8;
  --primary-dark: #6B4F6B;
  --bg: #FAFAFA;
  --white: #FFFFFF;
  --gray-100: #F5F5F5;
  --gray-200: #EEEEEE;
  --gray-300: #DDDDDD;
  --gray-500: #999999;
  --gray-700: #555555;
  --text: #333333;
  --danger: #E74C3C;
  --success: #27AE60;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }

/* ===== 스플래시 ===== */
.splash {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s;
}
.splash.fade-out { opacity: 0; pointer-events: none; }
.splash-content { text-align: center; color: white; }
.splash-logo {
  width: 80px; height: auto; margin-bottom: 16px;
  filter: brightness(0) invert(1);
}
.logo-text { font-size: 2rem; font-weight: 700; letter-spacing: 2px; }
.splash-sub { margin-top: 8px; font-size: 0.95rem; opacity: 0.8; }

/* ===== 페이지 공통 ===== */
.page { min-height: 100vh; padding: 20px; display: flex; flex-direction: column; }
.hidden { display: none !important; }

.page-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 1.2rem; }

/* ===== 버튼 ===== */
.btn {
  display: inline-block; padding: 12px 24px; border: none;
  border-radius: var(--radius); font-size: 1rem; cursor: pointer;
  transition: background 0.2s;
}
.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200); color: var(--text); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; width: auto; }
.btn-danger { background: var(--danger); color: white; }
.btn-back {
  background: none; border: none; font-size: 1.3rem;
  cursor: pointer; color: var(--primary); padding: 4px 8px;
}
.btn-icon {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--gray-700); padding: 4px 8px;
}

/* ===== 로그인 ===== */
.login-container {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; max-width: 360px;
  margin: 0 auto; width: 100%;
}
.login-logo-img {
  display: block; width: 70px; height: auto; margin: 0 auto 16px;
  filter: brightness(0) saturate(100%) invert(47%) sepia(10%) saturate(1000%) hue-rotate(250deg);
}
.login-logo {
  text-align: center; font-size: 1.8rem; color: var(--primary);
  margin-bottom: 40px; letter-spacing: 2px;
}
.login-form input {
  width: 100%; padding: 14px 16px; border: 1px solid var(--gray-300);
  border-radius: var(--radius); font-size: 1rem; margin-bottom: 12px;
  outline: none; transition: border 0.2s;
}
.login-form input:focus { border-color: var(--primary); }
.login-form .btn { margin-top: 8px; }
.login-links {
  display: flex; justify-content: center; gap: 20px;
  margin-top: 20px; font-size: 0.9rem;
}

/* ===== 회원가입 폼 ===== */
.form-content {
  padding: 0 4px;
}
.form-content input, .form-content select, .form-content textarea {
  width: 100%; padding: 14px 16px; border: 1px solid var(--gray-300);
  border-radius: var(--radius); font-size: 1rem; margin-bottom: 12px;
  outline: none; font-family: inherit;
}
.form-content input:focus, .form-content select:focus, .form-content textarea:focus {
  border-color: var(--primary);
}
.form-content .btn { margin-top: 8px; }

/* ===== 앱 레이아웃 ===== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--white); padding: 14px 20px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--gray-200);
}
.header-brand { display: flex; align-items: center; gap: 8px; }
.header-auth { display: flex; gap: 6px; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.header-logo {
  width: 24px; height: auto;
  filter: brightness(0) saturate(100%) invert(47%) sepia(10%) saturate(1000%) hue-rotate(250deg);
}
.app-header h1 { font-size: 1.15rem; color: var(--primary); letter-spacing: 1px; }

.app-main {
  margin-top: 52px; margin-bottom: 64px;
  padding: 16px; min-height: calc(100vh - 116px);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== 하단 탭바 ===== */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--white); display: flex;
  border-top: 1px solid var(--gray-200);
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
}
.tab-btn {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 0; color: var(--gray-500); transition: color 0.2s;
}
.tab-btn.active { color: var(--primary); }
.tab-icon { font-size: 1.3rem; }
.tab-label { font-size: 0.7rem; margin-top: 2px; }

/* ===== 학원 소개 ===== */
.intro-hero {
  height: 200px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
}
.intro-hero-overlay { text-align: center; color: white; }
.hero-logo {
  width: 60px; height: auto; margin-bottom: 12px;
  filter: brightness(0) invert(1);
}
.intro-hero-overlay h2 { font-size: 1.6rem; letter-spacing: 2px; }
.intro-hero-overlay p { margin-top: 8px; opacity: 0.9; }

.intro-section {
  background: var(--white); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.intro-section h3 {
  font-size: 1.05rem; color: var(--primary); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--gray-200);
}
.intro-section p { line-height: 1.7; color: var(--gray-700); font-size: 0.95rem; }

.instructor-list { display: flex; gap: 12px; flex-wrap: wrap; }
.instructor-card {
  flex: 1; min-width: 140px; text-align: center;
  padding: 16px; background: var(--gray-100); border-radius: var(--radius);
}
.instructor-avatar { font-size: 2.5rem; margin-bottom: 8px; }
.instructor-card h4 { font-size: 0.95rem; margin-bottom: 4px; }
.instructor-card p { font-size: 0.8rem; color: var(--gray-500); line-height: 1.5; }

.facility-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.facility-item {
  padding: 14px; background: var(--gray-100); border-radius: var(--radius);
  text-align: center; font-size: 0.95rem;
}
.contact-info p { margin-bottom: 8px; font-size: 0.95rem; line-height: 1.6; }

/* ===== 달력 (공통) ===== */
.calendar-container {
  background: var(--white); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.calendar-header {
  display: flex; align-items: center; justify-content: center;
  gap: 20px; margin-bottom: 12px; font-weight: 600; font-size: 1.05rem;
}
.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 0.8rem; color: var(--gray-500);
  margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--gray-200);
}
.calendar-weekdays span:first-child { color: var(--danger); }
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.calendar-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 0.9rem; position: relative;
}

/* 예약하기 탭 달력 */
.calendar-small {
  max-width: 440px; margin: 0 auto 12px; padding: 12px;
}
.calendar-small .calendar-header { font-size: 0.95rem; gap: 16px; margin-bottom: 10px; }
.calendar-small .calendar-weekdays { font-size: 0.75rem; margin-bottom: 6px; padding-bottom: 6px; }
.calendar-small .calendar-grid { gap: 3px; }
.calendar-small .calendar-day { font-size: 0.85rem; aspect-ratio: 1; position: relative; }

/* 내 예약 탭 달력: 날짜 아래 시간 표시 */
.calendar-booking .calendar-day {
  aspect-ratio: auto; border-radius: 8px; min-height: 44px;
  flex-direction: column; font-size: 0.8rem; padding: 4px 2px;
}
.calendar-booking .calendar-day.empty { min-height: 0; }
.calendar-booking .calendar-day .day-bookings {
  display: flex; flex-direction: column; gap: 1px; margin-top: 2px;
}
.calendar-booking .calendar-day .day-booking-time {
  font-size: 0.6rem; background: var(--primary); color: white;
  border-radius: 3px; padding: 1px 3px; white-space: nowrap;
}
.calendar-booking .calendar-day.today::after { display: none; }
.calendar-booking .calendar-day.has-booking { background: var(--gray-100); font-weight: 600; }
.calendar-day.empty { visibility: hidden; }
.calendar-day.past { color: var(--gray-300); }
.calendar-day.sunday { color: var(--danger); opacity: 0.4; }
.calendar-day.selectable { cursor: pointer; font-weight: 500; }
.calendar-day.selectable:hover { background: var(--gray-100); }
.calendar-day.selected {
  background: var(--primary); color: white; font-weight: 700;
}
.calendar-day.today::after {
  content: ''; position: absolute; bottom: 2px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--primary);
}
.calendar-day.selected.today::after { background: white; }
.calendar-day.holiday { color: var(--danger); }
.calendar-day.holiday.selected { color: white; }
.calendar-day.holiday.past { color: var(--gray-300); }
.holiday-name {
  font-size: 0.45rem; color: var(--danger); position: absolute;
  bottom: 1px; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
}
.calendar-day.selected .holiday-name { color: white; }

/* ===== 시간 슬롯 ===== */
.timeslot-section {
  margin-bottom: 16px;
}
.timeslot-section h3 {
  font-size: 1rem; color: var(--primary); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--gray-200);
}
.timeslot-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
}
.timeslot {
  padding: 7px 4px; border-radius: 8px; text-align: center;
  font-size: 0.75rem; font-weight: 500; display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.timeslot .slot-status { font-size: 0.6rem; font-weight: 400; }
.timeslot.available {
  background: var(--white); border: 1px solid var(--primary);
  color: var(--primary); cursor: pointer;
}
.timeslot.available:hover { background: var(--primary); color: white; }
.timeslot.booked {
  background: var(--gray-200); color: var(--gray-500);
  border: 1px solid var(--gray-300); cursor: default;
}
.timeslot.my-booking {
  background: var(--primary); color: white;
  border: 1px solid var(--primary-dark); cursor: pointer;
}
.timeslot.past {
  background: var(--gray-100); color: var(--gray-300);
  border: 1px solid var(--gray-200); cursor: default;
}
.timeslot.selected-slot {
  background: var(--primary); color: white;
  border: 2px solid var(--primary-dark); cursor: pointer;
}

/* ===== 예약 확인 영역 ===== */
.booking-confirm {
  margin-top: 16px; padding: 16px; background: var(--white);
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 2px solid var(--primary);
}
.booking-confirm-info {
  display: flex; justify-content: center; gap: 16px;
  margin-bottom: 12px; font-size: 1.05rem; font-weight: 600;
  color: var(--primary);
}

/* ===== 섹션 타이틀 ===== */
.section-title {
  font-size: 1.1rem; color: var(--primary); margin-bottom: 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--gray-200);
}

.my-bookings { margin-top: 24px; }
.my-bookings h3 {
  font-size: 1rem; color: var(--primary); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--gray-200);
}
.my-booking-card {
  background: var(--white); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center;
}
.my-booking-card .booking-info p { font-size: 0.85rem; color: var(--gray-500); }

/* ===== 날짜 네비게이션 (관리자) ===== */
.booking-date-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 20px; padding: 12px; background: var(--white);
  border-radius: var(--radius); margin-bottom: 16px;
  box-shadow: var(--shadow); font-weight: 600;
}

/* ===== 공지사항 ===== */
.notice-list { display: flex; flex-direction: column; gap: 10px; }
.notice-card {
  background: var(--white); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.15s;
}
.notice-card:active { transform: scale(0.98); }
.notice-card h4 { font-size: 1rem; margin-bottom: 6px; }
.notice-card .notice-date { font-size: 0.8rem; color: var(--gray-500); }
.notice-card .notice-preview {
  font-size: 0.9rem; color: var(--gray-700); margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.notice-detail { padding: 0 4px; }
.notice-detail h3 { font-size: 1.15rem; margin: 16px 0 8px; }
.notice-date { font-size: 0.85rem; color: var(--gray-500); }
.notice-body { margin-top: 16px; line-height: 1.8; font-size: 0.95rem; white-space: pre-wrap; }

/* ===== 관리자 ===== */
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto;
}
.admin-tab {
  padding: 8px 14px; border: 1px solid var(--gray-300);
  border-radius: 20px; background: var(--white); font-size: 0.85rem;
  cursor: pointer; white-space: nowrap;
}
.admin-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.admin-panel { display: none; }
.admin-panel.active { display: block; }

.admin-card {
  background: var(--white); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center;
}
.admin-card-info h4 { font-size: 0.95rem; }
.admin-card-info p { font-size: 0.8rem; color: var(--gray-500); margin-top: 2px; }
.admin-card-actions { display: flex; gap: 6px; }
.admin-card-actions button { padding: 6px 10px; font-size: 0.8rem; }

/* ===== 모달 ===== */
.modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--white); width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0; padding: 24px;
  max-height: 80vh; overflow-y: auto;
}
.modal-content h3 { margin-bottom: 16px; color: var(--primary); }
.modal-content input, .modal-content select, .modal-content textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--gray-300);
  border-radius: var(--radius); font-size: 0.95rem; margin-bottom: 10px;
  outline: none; font-family: inherit;
}
.modal-content input:focus, .modal-content select:focus, .modal-content textarea:focus {
  border-color: var(--primary);
}
.form-buttons { display: flex; gap: 10px; margin-top: 8px; }
.form-buttons .btn { flex: 1; }

/* ===== 빈 상태 ===== */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--gray-500);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ===== 토스트 ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 12px 24px;
  border-radius: 24px; font-size: 0.9rem; z-index: 200;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ===== 회원 관리 ===== */
.member-role {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 10px;
  display: inline-block; margin-left: 8px;
}
.member-role.admin { background: var(--primary-light); color: white; }
.member-role.user { background: var(--gray-200); color: var(--gray-700); }

/* ===== 상담 ===== */
.consult-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.consult-header .section-title { margin-bottom: 0; padding-bottom: 0; border: none; }
.consult-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.consult-badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 10px;
  white-space: nowrap;
}
.consult-badge.replied { background: var(--success); color: white; }
.consult-badge.waiting { background: var(--gray-300); color: var(--gray-700); }
.consult-badge.secret { background: var(--gray-700); color: white; }
.secret-card { opacity: 0.6; cursor: default; }
.secret-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.9rem; margin-bottom: 10px; cursor: pointer;
}
.secret-check input { width: 18px; height: 18px; accent-color: var(--primary); }
.consult-meta {
  display: flex; gap: 10px; margin-bottom: 8px;
}
.consult-detail h4 { font-size: 1.15rem; margin-bottom: 8px; }
.consult-replies { margin-top: 20px; }
.reply-card {
  background: #f5f0f5; border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 16px; margin-bottom: 10px;
}
.reply-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.reply-author { font-size: 0.85rem; font-weight: 600; color: var(--primary); }
.reply-date { font-size: 0.8rem; color: var(--gray-500); }
.reply-body { font-size: 0.95rem; line-height: 1.7; white-space: pre-wrap; }
.consult-reply-form {
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}
.consult-reply-form textarea {
  width: 100%; padding: 12px; border: 1px solid var(--gray-300);
  border-radius: var(--radius); font-size: 0.95rem; font-family: inherit;
  outline: none; margin-bottom: 8px;
}
.consult-reply-form textarea:focus { border-color: var(--primary); }

/* ===== 운영시간 설정 ===== */
.schedule-tabs {
  display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto;
}
.schedule-day-tab {
  padding: 6px 12px; border: 1px solid var(--gray-300);
  border-radius: 16px; background: var(--white); font-size: 0.85rem;
  cursor: pointer; white-space: nowrap;
}
.schedule-day-tab.active {
  background: var(--primary); color: white; border-color: var(--primary);
}
.schedule-controls { margin-bottom: 10px; }
.schedule-slots-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.slot-toggle {
  display: flex; align-items: center; justify-content: center;
  padding: 8px 4px; border: 1px solid var(--gray-300);
  border-radius: 8px; font-size: 0.8rem; cursor: pointer;
  background: var(--white); transition: all 0.15s;
}
.slot-toggle input { display: none; }
.slot-toggle.active {
  background: var(--primary); color: white; border-color: var(--primary);
}

/* ===== 이미지 관련 ===== */
.content-images {
  display: flex; flex-direction: column; gap: 10px; margin-top: 12px;
}
.content-img {
  width: 100%; border-radius: var(--radius); cursor: pointer;
}
.card-thumb {
  width: 100%; max-height: 160px; object-fit: cover;
  border-radius: 8px; margin-bottom: 8px;
}
.detail-img {
  width: 100%; border-radius: var(--radius); margin: 12px 0;
}
.file-label {
  display: block; padding: 10px 14px; border: 1px dashed var(--gray-300);
  border-radius: var(--radius); text-align: center; cursor: pointer;
  font-size: 0.9rem; color: var(--gray-500); margin-bottom: 10px;
}
.file-label input[type="file"] { display: none; }
.image-preview { margin-bottom: 10px; }
.existing-img-wrap { margin-bottom: 10px; }

/* ===== 관리자 달력 ===== */
.calendar-admin {
  max-width: 280px; margin: 0 auto 16px; padding: 10px;
}
.calendar-admin .calendar-header { font-size: 0.9rem; gap: 14px; margin-bottom: 8px; }
.calendar-admin .calendar-weekdays { font-size: 0.7rem; margin-bottom: 4px; padding-bottom: 4px; }
.calendar-admin .calendar-grid { gap: 3px; }
.calendar-admin .calendar-day { font-size: 0.75rem; }
.admin-cal-day {
  aspect-ratio: 1; cursor: pointer; position: relative;
}
.admin-cal-day:hover { background: var(--gray-100); }
.admin-cal-day.has-booking { background: #f0e8f0; font-weight: 600; }
.admin-booking-count {
  position: absolute; top: 1px; right: 1px;
  background: var(--primary); color: white;
  font-size: 0.55rem; width: 14px; height: 14px;
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
}
