/* =============================================
   이루어GYM 예약 매니저 — Design System
   Mobile First | Deep Blue Theme
============================================= */

/* ── 0. Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-950 : #040f2d;
  --blue-900 : #071440;
  --blue-800 : #0d1f5c;
  --blue-700 : #1a2f7a;
  --blue-600 : #1e3a9e;
  --blue-500 : #2563eb;
  --blue-400 : #3b82f6;
  --blue-300 : #93c5fd;
  --blue-100 : #dbeafe;

  --available : #38bdf8;
  --avail-bg  : #0c4a6e;
  --avail-text: #e0f2fe;

  --booked    : #f97316;
  --booked-bg : #431407;
  --booked-text: #ffedd5;

  --closed-c  : #64748b;
  --closed-bg : #1e293b;

  --danger    : #ef4444;
  --danger-dk : #b91c1c;

  --surface-0 : #060d24;
  --surface-1 : #0b1535;
  --surface-2 : #111f4a;
  --surface-3 : #1a2d60;

  --text-primary  : #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted    : #475569;

  --border     : rgba(59,130,246,.18);
  --border-soft: rgba(59,130,246,.08);

  --radius-sm : 8px;
  --radius-md : 14px;
  --radius-lg : 20px;
  --radius-xl : 28px;

  --shadow-card: 0 4px 32px rgba(0,0,0,.55);
  --shadow-btn : 0 2px 12px rgba(37,99,235,.4);

  --font: 'Noto Sans KR', system-ui, sans-serif;
  --transition: .18s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background : var(--surface-0);
  color      : var(--text-primary);
  min-height : 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── 1. Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, var(--blue-900) 0%, rgba(7,20,64,.92) 100%);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: 640px;
  margin: 0 auto;
}
.header-brand { display: flex; align-items: center; gap: 10px; transition: var(--transition); }
.header-brand:hover { opacity: 0.8; }
.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-icon {
  max-height: 42px;
  width: auto;
}
.brand-name { font-size: 1.15rem; font-weight: 800; line-height: 1; letter-spacing: -.3px; }
.brand-sub  { font-size: 1.0rem; color: var(--blue-300); font-weight: 500; }
.admin-badge {
  background: linear-gradient(90deg,#f59e0b,#ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}
.btn-admin-link {
  font-size: .8rem; font-weight: 600;
  color: var(--blue-300);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  margin-left: 6px;
}
.btn-admin-link:hover { background: var(--blue-700); color: #fff; }

.btn-homepage-link {
  display: inline-block;
  font-size: .8rem; font-weight: 600;
  color: #fff !important;
  background: var(--blue-500);
  border: 1px solid var(--blue-400);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  margin-left: 6px;
  line-height: 1.4;
}
.btn-homepage-link:hover { background: var(--blue-600); box-shadow: var(--shadow-btn); }

/* ── 2. Main Layout ── */
.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 12px 80px;
}

/* ── 3. Calendar ── */
.calendar-section {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cal-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.2px;
}
.cal-nav-btn {
  width: 38px; height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
  display: grid; place-items: center;
  transition: var(--transition);
}
.cal-nav-btn:hover { background: var(--blue-700); border-color: var(--blue-500); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-dayname {
  text-align: center;
  font-size: .72rem;
  font-weight: 800;
  color: #a0b4e0;
  padding: 4px 0 8px;
  letter-spacing: .02em;
}
.cal-dayname.sun { color: #fca5a5; }
.cal-dayname.sat { color: #93c5fd; }

.cal-cell {
  background: #1c2f6b;
  border: 1px solid rgba(100,130,220,.2);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  font-family: var(--font);
}
.cal-cell:not(.empty):not(:disabled):hover {
  background: #263e8a;
  border-color: var(--blue-400);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59,130,246,.25);
}
.cal-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.past  { opacity: .35; pointer-events: none; }
.cal-cell.today .cal-day-num {
  background: var(--blue-500);
  color: #fff;
  border-radius: 50%;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-weight: 800;
  box-shadow: 0 0 8px rgba(37,99,235,.6);
}
.cal-cell.selected {
  background: #1e3a9e;
  border-color: var(--blue-300);
  box-shadow: 0 0 0 2px rgba(147,197,253,.4);
}
.cal-cell.closed { opacity: .4; pointer-events: none; }
.cal-cell:disabled { cursor: not-allowed; }

.cal-cell.sun { background: rgba(239, 68, 68, .15); border-color: rgba(239, 68, 68, .3); }
.cal-cell.sun .cal-day-num { color: #ff5c5c; font-weight: 900; }
.cal-cell.sat .cal-day-num { color: #93c5fd; font-weight: 800; }

.cal-day-num {
  font-size: .88rem;
  font-weight: 700;
  line-height: 1;
  color: #e8eeff;
}
.cal-count {
  font-size: .62rem;
  background: var(--booked);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  line-height: 1.4;
}
.cal-closed-badge {
  font-size: .68rem;
  font-weight: 900;
  background: #ef4444;
  color: #ffffff;
  border: 1px solid #b91c1c;
  border-radius: 6px;
  padding: 2px 6px;
  letter-spacing: .02em;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* ── 4. Timeslot Section ── */
.timeslot-section {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  scroll-margin-top: 75px; /* 헤더 높이만큼 여백 확보 */
}
.timeslot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.timeslot-date {
  font-size: 1rem;
  font-weight: 700;
}
.legend-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: var(--text-secondary);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.dot-available { background: var(--available); }
.dot-booked    { background: var(--booked); }
.dot-closed    { background: var(--closed-c); }

.timeslot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.timeslot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  font-family: var(--font);
  height: 96px;          /* 고정 높이 — 2명 이름 2줄 수용 */
  overflow: hidden;       /* 내용 넘침 방지 */
  box-sizing: border-box;
}
.timeslot.past-disabled {
  opacity: 0.35;
  filter: grayscale(0.8);
  pointer-events: none;
  cursor: not-allowed;
}
.timeslot.available {
  background: var(--avail-bg);
  border-color: var(--available);
  color: var(--avail-text);
}
.timeslot.available:hover {
  background: #0c5a80;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(56,189,248,.3);
}
.timeslot.booked {
  background: var(--booked-bg);
  border-color: var(--booked);
  color: var(--booked-text);
}
.timeslot.booked:hover {
  background: #5a1a05;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(249,115,22,.3);
}
.slot-time   { font-size: 1rem; font-weight: 900; letter-spacing: -.5px; line-height: 1; flex-shrink: 0; }
.slot-status {
  font-size: 0.9rem;
  font-weight: 800;
  word-break: keep-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip; /* 말줄임표 대신 자르거나 그대로 노출 */
  max-width: 100%;
  padding: 1px 3px; /* 좌우 여백 축소 */
  border-radius: 4px;
  background: rgba(255, 127, 0, 0.6); /* 더 투명한 오렌지 배경 */
  color: #fff; /* 흰색 글자 */
  margin: 2px 0;
  display: inline-block;
  min-width: 40px;
  position: relative;
}
.slot-status::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: rgba(230, 115, 0, 0.4); /* 진한 오렌지 강조 (투명도 추가 조절) */
  border-radius: 2px 0 0 2px;
}
.slot-status:empty { display: none; }
.slot-badge {
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.available .slot-badge { background: rgba(56,189,248,.3); color: #7dd3fc; }
.booked    .slot-badge { background: rgba(249,115,22,.3); color: #fdba74; }

/* ── 5. Admin Slot Grid ── */
.slot-phone {
  font-size: .65rem;
  color: var(--text-secondary);
  opacity: .8;
}
.btn-slot-delete {
  background: rgba(255, 127, 0, 0.6); /* 더 투명한 오렌지 배경 */
  color: #fff; /* 흰색 텍스트 */
  border: 1px solid rgba(230, 115, 0, 0.4); /* 테두리 투명도 추가 조절 */
  border-radius: var(--radius-sm);
  padding: 2px 3px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  width: calc(100% - 4px);
  flex-shrink: 0;
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.btn-slot-delete:hover { background: var(--danger); color: #fff; }

/* 내 예약 강조 애니메이션 */
@keyframes me-glow {
  0%, 100% {
    background-color: rgba(245, 158, 11, 0.6); /* 투명한 진한 노란색 */
    color: #fff;
  }
  50% {
    background-color: var(--blue-700); /* 진한 파란색 */
    color: #fff;
  }
}

.btn-slot-delete.is-me {
  animation: me-glow 2s infinite;
  border-color: rgba(251, 191, 36, 0.5);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

/* ── 6. Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; }
.empty-msg  { font-size: .9rem; text-align: center; line-height: 1.7; }

/* ── 7. Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 24px;
  border-radius: var(--radius-md);
  font-size: .95rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  min-height: 48px;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue-500), var(--blue-400));
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover { background: linear-gradient(135deg,#1d4ed8,#2563eb); transform: translateY(-1px); }
.btn-danger  { background: linear-gradient(135deg,var(--danger),#dc2626); color:#fff; }
.btn-danger:hover { background: linear-gradient(135deg,#b91c1c,#dc2626); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text-primary); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: .82rem; min-height: 36px; border-radius: var(--radius-sm); }

/* ── 8. Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: .82rem; font-weight: 600; color: var(--text-secondary); }
.form-input {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  padding: 13px 14px;
  min-height: 48px;
  transition: var(--transition);
  outline: none;
  width: 100%;
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: var(--blue-400); background: var(--surface-3); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

select.form-input { cursor: pointer; }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-unit { font-size: .88rem; color: var(--text-secondary); white-space: nowrap; }

/* ── 9. Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 20px 36px;
  width: 100%;
  max-width: 440px;
  position: relative;
  animation: zoomIn .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes zoomIn { from { transform: scale(0.9); opacity:0; } to { transform: scale(1); opacity:1; } }

.modal-close {
  position: absolute;
  top: 14px; right: 16px;
  width: 32px; height: 32px;
  background: var(--surface-2);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: grid; place-items: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--surface-3); color: var(--text-primary); }
.modal-icon     { font-size: 2.2rem; text-align: center; margin-bottom: 8px; }
.modal-title    { font-size: 1.2rem; font-weight: 800; text-align: center; margin-bottom: 4px; }
.modal-subtitle { font-size: .88rem; color: var(--blue-300); text-align: center; margin-bottom: 18px; font-weight: 600; }

.modal-actions  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.modal-open     { overflow: hidden; }

/* ── 9.1 Reservation & Cancellation Modal Custom Styles ── */
#modal-reserve .modal-subtitle,
#modal-cancel .modal-subtitle {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--blue-300);
}
#modal-reserve .form-label,
#modal-cancel .form-label {
  font-size: 0.95rem;
  font-weight: 800;
}
#modal-reserve .form-input,
#modal-cancel .form-input {
  font-size: 1.1rem;
  font-weight: 700;
}
#modal-confirm-msg {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.6;
}
#modal-confirm .modal-title {
  color: #ef4444;
}

/* ── 10. Toast ── */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  background: rgba(11, 21, 53, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 48px;
  display: flex;
  flex-direction: column; /* 아이콘과 텍스트 세로 배치 */
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  white-space: pre-wrap;
  text-align: center;
  animation: toastPopIn .3s cubic-bezier(.34,1.56,.64,1);
  min-width: 280px;
  max-width: 90vw;
}
@keyframes toastPopIn { from { opacity:0; transform: translate(-50%, -50%) scale(0.8); } to { opacity:1; transform: translate(-50%, -50%) scale(1); } }

.toast-icon { font-size: 2.8rem; line-height: 1; }
.toast-msg  { line-height: 1.5; color: #fff; }

.toast.toast-success { border-color: var(--available); box-shadow: 0 0 30px rgba(56,189,248,0.2); }
.toast.toast-error   { border-color: var(--danger); box-shadow: 0 0 30px rgba(239,68,68,0.2); }
.toast.toast-info    { border-color: var(--blue-400); box-shadow: 0 0 30px rgba(59,130,246,0.2); }

/* ── 11. Loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4,15,45,.6);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: grid;
  place-items: center;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(59,130,246,.2);
  border-top-color: var(--blue-400);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 12. Hidden utility ── */
.hidden { display: none !important; }

/* ── 13. Admin Login Gate ── */
.login-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 0%, rgba(37,99,235,.18) 0%, transparent 70%),
              var(--surface-0);
}
.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-card);
  text-align: center;
}
.login-logo  { font-size: 3rem; margin-bottom: 12px; }
.login-title { font-size: 1.35rem; font-weight: 900; margin-bottom: 4px; }
.login-sub   { font-size: .85rem; color: var(--text-secondary); margin-bottom: 24px; }
.login-back  { display: block; margin-top: 18px; font-size: .82rem; color: var(--text-muted); text-decoration: none; }
.login-back:hover { color: var(--blue-300); }

/* ── 14. Admin Tabs ── */
.admin-tabs {
  display: flex;
  max-width: 640px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  gap: 4px;
}
.admin-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  padding: 14px 18px 11px;
  cursor: pointer;
  transition: var(--transition);
}
.admin-tab:hover  { color: var(--text-secondary); }
.admin-tab.active { color: var(--blue-400); border-bottom-color: var(--blue-400); }

.admin-panel {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 12px 80px;
}

/* ── 15. Settings Cards ── */
.settings-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 14px;
}
.settings-section-title { font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.settings-desc { font-size: .83rem; color: var(--text-secondary); margin-bottom: 14px; line-height: 1.6; }

.closed-list { list-style: none; margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.closed-empty { font-size: .85rem; color: var(--text-muted); text-align: center; padding: 8px 0; }
.closed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.closed-day-label { font-size: .9rem; font-weight: 600; }
.btn-remove-closed {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}
.btn-remove-closed:hover { background: rgba(239,68,68,.15); }

/* ── 16. Admin body bg ── */
.admin-body {
  background: radial-gradient(ellipse at 50% 0%, rgba(239,68,68,.07) 0%, transparent 60%),
              var(--surface-0);
}

/* ── 17. Responsive tweaks (≥480px) ── */
@media (min-width: 480px) {
  .header-inner   { padding: 14px 20px; }
  .cal-cell       { min-height: 58px; }
  .timeslot       { grid-template-columns: 72px 1fr auto; }
  .admin-slot-grid .timeslot { grid-template-columns: 72px 1fr auto auto; }
}

@media (min-width: 640px) {
  .app-main, .admin-panel { padding: 20px 20px 80px; }
  .calendar-section, .timeslot-section { padding: 20px; }
  .cal-cell  { padding: 8px 6px; }
  .cal-day-num { font-size: .95rem; }
}

/* ============================================================
   STATS SECTION (Admin)
============================================================ */
.stats-section {
  margin-top: 2rem;
  padding: 0 1rem 2rem;
}
.stats-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}
.chart-container {
  margin-top: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 1rem;
  padding: 1rem;
}
@media (max-width: 768px) {
  .stats-section {
    padding: 0 0.5rem 1.5rem;
  }
}

