/* ==========================================================================
   학교생활 채움 — 배너 관리자 스타일
   공개용(style.css)을 먼저 불러온 뒤 이 파일이 관리자 화면 요소를 추가한다.
   ========================================================================== */

.admin-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  background: #fdf3e7; color: #a2691f;
  font-size: 10.5px; font-weight: 800;
}

/* ---------- 로그인 ---------- */

.login-wrap {
  min-height: calc(100vh - 60px);
  display: flex; align-items: center; justify-content: center; padding: 24px 16px;
}
/* display:flex 가 기본 [hidden] 을 덮어쓰므로 명시적으로 숨긴다.
   (이게 없으면 로그인 성공 후에도 로그인 폼이 화면에 그대로 남는다) */
.login-wrap[hidden] { display: none !important; }
.login-card {
  width: 100%; max-width: 380px; padding: 34px 28px;
  border: 1px solid var(--border); border-radius: 22px; background: #fff;
  box-shadow: 0 18px 50px rgba(20, 53, 76, .13); text-align: center;
}
.login-card .login-icon {
  width: 60px; height: 60px; margin: 0 auto 15px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 19px; background: var(--brand-light); font-size: 27px;
}
.login-card h1 { font-size: 20px; font-weight: 800; color: #12314b; }
.login-card > p { margin: 7px 0 22px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

.form-field { margin-bottom: 13px; text-align: left; }
.form-field label {
  display: block; margin-bottom: 6px;
  color: #6c7e8e; font-size: 11px; font-weight: 800;
}
.form-field .req { color: var(--danger); }
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="url"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="datetime-local"],
.form-field select,
.form-field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-field textarea { min-height: 74px; resize: vertical; line-height: 1.6; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(7, 151, 178, .12);
}
.form-field .hint { display: block; margin-top: 5px; color: var(--muted-light); font-size: 10.5px; line-height: 1.6; }
.form-field.invalid input, .form-field.invalid select { border-color: var(--danger); }
.form-error {
  min-height: 20px; margin: 4px 0 10px; text-align: left;
  color: var(--danger); font-size: 11.5px; font-weight: 700; line-height: 1.5;
}
.form-row { display: grid; gap: 0 11px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .form-row.two { grid-template-columns: 1fr 1fr; } }

.check-field {
  min-height: var(--tap); padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fbfcfd;
  cursor: pointer; margin-bottom: 13px;
}
.check-field input { width: 19px; height: 19px; flex: none; accent-color: var(--brand); }
.check-field span { color: var(--text-mid); font-size: 13px; font-weight: 700; }

/* ---------- 관리 콘솔 ---------- */

.admin-topbar {
  margin-bottom: 14px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.admin-user { min-width: 0; }
.admin-user strong { display: block; color: #16354e; font-size: 14px; font-weight: 800; }
.admin-user span { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }

.filter-bar {
  margin-bottom: 12px; padding: 11px 13px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  min-height: 40px; padding: 0 10px; flex: 1; min-width: 130px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: 13px; outline: none;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--brand); }
.filter-chip {
  min-height: 40px; padding: 0 13px; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 20px; background: #fff;
  color: var(--muted); font-size: 12px; font-weight: 700;
}
.filter-chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); }

/* 배너 목록 */
.banner-table { display: flex; flex-direction: column; gap: 10px; }

.banner-row {
  padding: 12px; display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.banner-row.inactive { background: #fafbfc; border-color: var(--border-soft); }
.banner-row.inactive .row-thumb { opacity: .45; }

.row-thumb {
  width: 74px; height: 74px; flex: none; overflow: hidden;
  border: 1px solid var(--border-soft); border-radius: 11px; background: #f2f6f9;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.row-body { min-width: 0; flex: 1; }
.row-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.row-title strong { color: #16354e; font-size: 14px; font-weight: 800; word-break: break-all; }
.row-meta { margin-top: 5px; color: var(--muted); font-size: 11.5px; line-height: 1.7; word-break: break-all; }
.row-meta b { color: var(--text-mid); font-weight: 700; }

.status-pill {
  padding: 3px 9px; border-radius: 20px; font-size: 10px; font-weight: 800; white-space: nowrap;
}
.pill-live { background: #e6f6ec; color: #217a4b; }
.pill-off { background: #eef1f4; color: #6b7f8e; }
.pill-wait { background: #fff6e8; color: #a2691f; }
.pill-end { background: #fdeeed; color: #b8443c; }
.pill-target { background: var(--brand-light); color: var(--brand-dark); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.row-actions .btn { min-height: 36px; padding: 0 11px; font-size: 11.5px; }
.btn-danger { border-color: #e6c3c0; background: #fff5f4; color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: #ffeceb; color: var(--danger); }

/* ---------- 모달 (배너 등록/수정) ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 900;
  display: none; align-items: flex-end; justify-content: center;
  padding: 0; background: rgba(15, 34, 49, .5); backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }

.modal-box {
  width: 100%; max-width: 640px; max-height: 94vh;
  display: flex; flex-direction: column;
  border-radius: 20px 20px 0 0; background: #fff; box-shadow: var(--shadow-lg);
}
.modal-head {
  padding: 18px 20px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--border-soft); flex: none;
}
.modal-head h2 { color: #17354d; font-size: 17px; font-weight: 800; }
.modal-head p { margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.modal-body { flex: 1; padding: 18px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot {
  padding: 13px 20px 20px; display: flex; gap: 8px; flex: none;
  border-top: 1px solid var(--border-soft);
}
.modal-foot .btn { flex: 1; min-height: 48px; font-size: 14px; }

@media (min-width: 700px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-box { border-radius: 20px; max-height: 90vh; }
}

.section-head {
  margin: 20px 0 11px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
  color: #2c4a60; font-size: 12px; font-weight: 800;
}
.section-head:first-child { margin-top: 0; }

/* 이미지 업로드 */
.upload-area {
  min-height: 120px; padding: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px dashed #cfdae1; border-radius: var(--radius); background: #fbfcfd;
  text-align: center; cursor: pointer;
}
.upload-area:hover { border-color: var(--brand); background: var(--brand-soft); }
.upload-area.has-image { padding: 10px; }
.upload-area .up-icon { font-size: 24px; }
.upload-area .up-text { color: var(--text-mid); font-size: 12.5px; font-weight: 700; }
.upload-area .up-spec { color: var(--muted-light); font-size: 10.5px; line-height: 1.6; }
.upload-preview {
  width: 128px; height: 128px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-actions { margin-top: 8px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
input[type="file"].hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-progress { margin-top: 8px; height: 6px; border-radius: 4px; background: #e7eef2; overflow: hidden; }
.upload-progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

/* 대상 학교 선택 */
.school-picker { margin-top: 8px; }
.school-search { display: flex; gap: 6px; }
.school-search input { flex: 1; min-width: 0; }
.school-search .btn { flex: none; min-height: 46px; }
.school-results {
  margin-top: 8px; max-height: 190px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.school-pick-item {
  padding: 9px 11px; display: flex; align-items: center; gap: 9px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff;
}
.school-pick-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.school-pick-item .pick-body { min-width: 0; flex: 1; }
.school-pick-item strong { display: block; color: #243b4e; font-size: 12.5px; font-weight: 800; }
.school-pick-item span { display: block; color: var(--muted); font-size: 10.5px; }

.chip-list { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 10px; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--brand); border-radius: 20px; background: var(--brand-light);
  color: var(--brand-dark); font-size: 11.5px; font-weight: 700;
}
.chip button { color: var(--brand-dark); font-size: 14px; line-height: 1; padding: 0 2px; }

/* 노출 지역 추가 — '＋ 지역 추가' 버튼을 입력칸 바닥에 맞춘다 */
.region-add-cell { justify-content: flex-end; }
.region-add-cell .btn { min-height: 46px; width: 100%; }
/* 지역을 아직 안 넣었을 때 안내 */
.chip-empty {
  margin-top: 9px; padding: 10px 12px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 11.5px; background: #fbfcfd;
}

/* 미리보기 */
.preview-wrap { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .preview-wrap { grid-template-columns: 1fr 1fr; } }
.preview-box {
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #fbfcfd;
}
.preview-box h4 {
  margin-bottom: 9px; color: var(--muted); font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: space-between;
}
.preview-frame { margin: 0 auto; }
.preview-frame.pc { max-width: 100%; }
.preview-frame.mobile { max-width: 190px; }
.preview-empty {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--muted-light); font-size: 11px; text-align: center; padding: 10px;
}

/* 안내 배너 */
.notice {
  margin-bottom: 14px; padding: 13px 15px;
  border: 1px solid #cfe7ec; border-radius: var(--radius);
  background: var(--brand-light); color: #215a68; font-size: 12px; line-height: 1.75;
}
.notice strong { color: #0b4a58; }
.notice.warn { border-color: #f0d9b8; background: #fdf6ec; color: #8a5c19; }
.notice.warn strong { color: #6d4712; }
.notice code {
  padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.7);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
}

/* ==========================================================================
   방문 통계 대시보드
   ========================================================================== */

/* ---------- 콘솔 상단 탭 ---------- */
.console-tabs {
  display: flex; gap: 6px; margin-bottom: 13px;
  padding: 5px; border: 1px solid var(--border); border-radius: 14px;
  background: #fff; box-shadow: var(--shadow);
}
.console-tab {
  flex: 1; min-height: 42px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; border-radius: 10px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 800; cursor: pointer;
  transition: background .15s, color .15s;
}
.console-tab:hover { background: var(--brand-soft); color: var(--brand-dark); }
.console-tab[aria-selected="true"] {
  background: var(--brand); color: #fff;
}
.console-tab[aria-selected="true"]:hover { background: var(--brand-dark); color: #fff; }
/* hidden 이 display 규칙에 지지 않게 명시적으로 막는다 */
.console-pane[hidden] { display: none !important; }

/* ---------- 통계 툴바 ---------- */
.stats-toolbar {
  margin-bottom: 13px; padding: 11px 13px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.stats-range { display: flex; gap: 5px; flex-wrap: wrap; }
.range-chip {
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 20px; background: #fff;
  color: var(--muted); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.range-chip:hover { border-color: #a5c7cf; color: var(--brand-dark); }
.range-chip.is-on {
  border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark);
}
.stats-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

/* 지금 접속중 표시 */
.stats-live {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 20px;
  background: #eaf9f0; color: #1d7a44; font-size: 11.5px; font-weight: 800;
}
.stats-live[hidden] { display: none !important; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #23a55a;
  animation: livePulse 1.8s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .45; transform: scale(.8); }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ---------- 구역 제목 ---------- */
.stats-caption {
  margin: 4px 0 9px; padding-left: 3px;
  color: #4d6478; font-size: 12px; font-weight: 800; letter-spacing: .2px;
}

/* ---------- KPI 카드 ---------- */
.kpi-grid {
  display: grid; gap: 10px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.kpi-card {
  position: relative; padding: 14px 15px 13px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--card); box-shadow: var(--shadow);
}
.kpi-card.is-primary {
  border-color: #a8dbe6;
  background: linear-gradient(160deg, #f4fcfd 0%, #ffffff 62%);
}
.kpi-label {
  display: block; color: var(--muted); font-size: 11px; font-weight: 800;
  letter-spacing: .2px;
}
.kpi-value {
  display: inline-block; margin-top: 6px;
  color: #10344c; font-size: 27px; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-card.is-primary .kpi-value { color: var(--brand-deep); font-size: 31px; }
.kpi-unit { margin-left: 3px; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi-delta {
  display: inline-block; margin-left: 7px; padding: 2px 7px;
  border-radius: 20px; font-size: 10.5px; font-weight: 800; vertical-align: 3px;
}
.kpi-delta.up   { background: #eaf9f0; color: #1d7a44; }
.kpi-delta.down { background: var(--danger-bg); color: var(--danger); }
.kpi-delta.flat { background: #f0f4f7; color: var(--muted); }
.kpi-hint {
  display: block; margin-top: 6px;
  color: var(--muted-light); font-size: 10.5px; line-height: 1.5;
}
/* 두 번째 줄(기간 요약)은 조금 작게 — 오늘 숫자가 주인공이다 */
.kpi-sub .kpi-value { font-size: 22px; }
.kpi-sub .kpi-card { padding: 12px 13px 11px; }

/* ---------- 통계 카드 ---------- */
.stats-card { margin-bottom: 13px; padding: 15px 16px 14px; }
.stats-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.stats-card-head strong { color: #12314b; font-size: 14px; font-weight: 800; }
.stats-2col { display: grid; gap: 13px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .stats-2col { grid-template-columns: 1.15fr 1fr; } }

/* 작은 토글 칩 */
.chart-toggle { display: flex; gap: 4px; flex-wrap: wrap; }
.mini-chip {
  min-height: 30px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 16px; background: #fff;
  color: var(--muted); font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.mini-chip:hover { border-color: #a5c7cf; color: var(--brand-dark); }
.mini-chip.is-on {
  border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark);
}

/* 그래프 */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { display: block; width: 100%; }
.chart-wrap rect { transition: opacity .12s; }
.chart-wrap rect:hover { opacity: .72; }
.chart-note {
  margin-top: 9px; color: var(--muted); font-size: 11px; line-height: 1.65;
  word-break: keep-all;
}
.chart-empty {
  padding: 28px 12px; text-align: center;
  color: var(--muted-light); font-size: 12px;
}

/* ---------- 기기 비중 ---------- */
.device-wrap { display: flex; flex-direction: column; gap: 11px; }
.device-row { display: flex; align-items: center; gap: 9px; }
.device-name {
  flex: none; width: 74px; color: #43596c; font-size: 12px; font-weight: 700;
}
.device-bar {
  flex: 1; height: 11px; border-radius: 20px; background: #eef3f7; overflow: hidden;
}
.device-fill { display: block; height: 100%; border-radius: 20px; }
.device-pct {
  flex: none; width: 48px; text-align: right;
  color: #12314b; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.device-num {
  flex: none; width: 62px; text-align: right;
  color: var(--muted-light); font-size: 10.5px; font-variant-numeric: tabular-nums;
}

/* ---------- 순위표 ---------- */
.rank-table { display: flex; flex-direction: column; }
.rank-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 4px; border-bottom: 1px solid var(--border-soft);
}
.rank-row:last-child { border-bottom: none; }
.rank-row.is-head {
  padding: 0 4px 7px;
  border-bottom: 1.5px solid var(--border);
  color: var(--muted); font-size: 10.5px; font-weight: 800;
}
.rank-no {
  flex: none; width: 22px; text-align: center;
  color: var(--muted-light); font-size: 11.5px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rank-no.is-top { color: var(--brand); }
.rank-cell {
  font-size: 12.5px; color: #33495c; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-cell.is-grow { flex: 1 1 auto; font-weight: 700; color: #12314b; }
.rank-cell.is-region {
  flex: none; width: 108px; color: var(--muted); font-size: 11.5px;
}
.rank-cell.is-num {
  flex: none; width: 128px;
  display: flex; align-items: center; gap: 7px; justify-content: flex-end;
}
.rank-cell.is-num.is-narrow { width: 60px; justify-content: flex-end; }
.rank-row.is-head .rank-cell.is-num { justify-content: flex-end; }
.rank-cell.is-num b {
  flex: none; min-width: 40px; text-align: right;
  color: #12314b; font-weight: 800; font-variant-numeric: tabular-nums;
}
.rank-bar {
  flex: 1 1 auto; min-width: 26px; height: 8px;
  border-radius: 20px; background: #eef3f7; overflow: hidden;
}
.rank-bar-fill {
  display: block; height: 100%; border-radius: 20px;
  background: linear-gradient(90deg, #56c0d6, var(--brand));
}

/* 좁은 화면에서는 지역/부가 열을 접는다 — 학교명과 숫자가 우선이다 */
@media (max-width: 620px) {
  .rank-cell.is-region { display: none; }
  .rank-cell.is-num { width: 96px; }
  .rank-cell.is-num.is-narrow { width: 50px; }
  .rank-bar { display: none; }
}

/* ---------- 하단 주석 ---------- */
.stats-footnote {
  margin: 6px 2px 22px; color: var(--muted-light);
  font-size: 10.5px; line-height: 1.75; word-break: keep-all;
}
