/* 관리자 페이지 전용 스타일 (style.css의 토큰을 재사용) */

.admin-body { background: var(--bg-soft); }
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 240px; flex-shrink: 0; background: var(--ink); color: #C9D3D8;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  overflow: hidden; /* 하위 요소가 넘칠 때 사이드바 자체가 늘어나 하단 링크가 밀려나는 것을 방지 */
}
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px; border-bottom: 1px solid #333E44; flex-shrink: 0; }
.admin-brand img { width: 36px; height: 36px; border-radius: 9px; }
.admin-brand strong { display: block; color: #fff; font-size: 14.5px; }
.admin-brand small { font-size: 11px; color: #8996A0; }

.admin-nav {
  flex: 1; min-height: 0; /* flex 자식이 내용물 크기만큼 무한정 늘어나지 않고 부모 높이 안에서 스크롤되도록 */
  padding: 14px 12px; display: flex; flex-direction: column; gap: 3px;
  overflow-y: auto; /* 메뉴 항목이 많아져도 이 영역만 스크롤되고, 하단 사이트보기/로그아웃은 항상 보임 */
}
.admin-nav a {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 10px;
  font-size: 13.8px; font-weight: 600; color: #C9D3D8; transition: all .15s ease;
  flex-shrink: 0;
}
.admin-nav a:hover { background: #2A343A; color: #fff; }
.admin-nav a.active { background: var(--primary); color: #fff; }
.admin-nav-badge {
  margin-left: auto; background: #E4483C; color: #fff; font-size: 11px; font-weight: 800;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* 스크롤바를 얇고 눈에 덜 띄게 (웹킷 기반 브라우저) */
.admin-nav::-webkit-scrollbar { width: 6px; }
.admin-nav::-webkit-scrollbar-thumb { background: #3A454C; border-radius: 4px; }
.admin-nav::-webkit-scrollbar-track { background: transparent; }

.admin-sidebar-foot { padding: 16px; border-top: 1px solid #333E44; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.admin-view-site, .admin-logout { font-size: 12.5px; text-align: center; padding: 9px; border-radius: 8px; border: 1px solid #3A454C; color: #C9D3D8; }
.admin-view-site:hover, .admin-logout:hover { background: #2A343A; color: #fff; }

.admin-content { flex: 1; min-width: 0; }
.admin-topbar {
  height: 68px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.admin-topbar h1 { font-size: 18px; font-weight: 800; margin: 0; }
.admin-topbar-right { display: flex; align-items: center; gap: 18px; }
.admin-user { font-size: 13px; color: var(--gray); font-weight: 600; }

/* 알림 벨 */
.notif-bell-wrap { position: relative; }
.notif-bell {
  position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: #fff; color: var(--gray); display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all .15s ease;
}
.notif-bell:hover { background: var(--bg-soft); color: var(--primary-deep); }
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  background: var(--live); color: #fff; font-size: 10.5px; font-weight: 800; align-items: center; justify-content: center;
  display: flex; border: 2px solid #fff;
}
.notif-badge.pulse { animation: notifPulse .5s ease; }
@keyframes notifPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); }
  100% { transform: scale(1); }
}
.notif-dropdown {
  position: absolute; top: calc(100% + 12px); right: 0; width: 360px; max-height: 460px; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 20px 50px rgba(20,30,35,.18);
  opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98); transform-origin: top right;
  transition: opacity .16s ease, transform .16s ease, visibility .16s; z-index: 60; overflow: hidden;
}
.notif-dropdown::before {
  content: ''; position: absolute; top: -6px; right: 14px; width: 12px; height: 12px; background: #fff;
  border-left: 1px solid var(--border); border-top: 1px solid var(--border); transform: rotate(45deg); border-radius: 2px 0 0 0;
}
.notif-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.notif-dropdown-head {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 14px 18px;
  background: linear-gradient(180deg, var(--bg-soft), #fff); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.notif-dropdown-head-title { display: flex; align-items: center; gap: 8px; }
.notif-dropdown-icon {
  width: 26px; height: 26px; border-radius: 8px; background: var(--primary-tint); color: var(--primary-deep);
  display: flex; align-items: center; justify-content: center;
}
.notif-dropdown-head strong { font-size: 14px; }
.notif-dropdown-head-actions { display: flex; align-items: center; gap: 4px; }
.notif-dropdown-head button#notifMarkAll { background: none; border: none; color: var(--primary-deep); font-size: 12px; font-weight: 700; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.notif-dropdown-head button#notifMarkAll:hover { background: var(--primary-tint); }
.notif-close-btn { background: none; border: none; color: var(--gray-soft); font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.notif-close-btn:hover { background: var(--bg-soft); color: var(--ink); }
.notif-list { display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
.notif-item { display: flex; gap: 11px; padding: 13px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.notif-item:hover { background: var(--bg-soft); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-tint); }
.notif-item.unread:hover { background: var(--primary-tint-2); }
.notif-item-icon {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); color: var(--gray-soft); margin-top: 1px;
}
.notif-item.unread .notif-item-icon { background: var(--primary); color: #fff; }
.notif-item-body { min-width: 0; flex: 1; overflow: hidden; }
.notif-msg {
  font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 3px; line-height: 1.4;
  overflow-wrap: break-word; word-break: break-word; white-space: normal;
}
.notif-time { font-size: 11px; color: var(--gray-soft); }
.notif-empty { padding: 32px 16px; text-align: center; font-size: 12.5px; color: var(--gray-soft); }
.admin-body-inner { padding: 28px; max-width: 1140px; }

.admin-flash { padding: 12px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; margin-bottom: 20px; }
.admin-flash-success { background: var(--primary-tint); color: var(--primary-deep); }
.admin-flash-error { background: #FFECEC; color: #C6303E; }

/* Cards / panels */
.admin-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 22px 24px; margin-bottom: 22px; }
.admin-panel-title { font-size: 15px; font-weight: 800; margin: 0 0 4px; }
.admin-panel-desc { font-size: 12.8px; color: var(--gray-soft); margin: 0 0 18px; }

.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 20px; }
.stat-card span { display: block; font-size: 12.5px; color: var(--gray-soft); font-weight: 600; margin-bottom: 8px; }
.stat-card strong { font-size: 26px; font-weight: 800; color: var(--ink); }

/* Table */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th, .admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--gray-soft); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.admin-table tr:hover td { background: var(--bg-soft); }
.admin-table img.thumb { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--bg-soft); }
.admin-table-actions { display: flex; gap: 6px; }

.badge { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge-on { background: var(--primary-tint); color: var(--primary-deep); }
.badge-off { background: var(--bg-soft); color: var(--gray-soft); }
.badge-live { background: #FFE7E9; color: var(--live); }
.badge-warn { background: #FFF1D6; color: #B7791F; }

/* Forms */
.form-grid { display: grid; gap: 18px; }
.form-row { display: flex; flex-direction: column; gap: 7px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-row label { font-size: 13px; font-weight: 700; color: var(--ink); }
.form-row .hint { font-size: 12px; color: var(--gray-soft); font-weight: 400; }
input[type=text], input[type=password], input[type=url], input[type=email], input[type=datetime-local], input[type=number], input[type=date], input[type=file], textarea, select {
  padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--border); font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); outline: none; }
textarea { resize: vertical; min-height: 100px; }
.file-drop {
  border: 1.5px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; font-size: 13px; color: var(--gray);
  background: var(--bg-soft);
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.form-actions { display: flex; gap: 10px; padding-top: 6px; }

/* Login page */
.admin-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--primary-tint); padding: 20px; }
.admin-login-card { background: #fff; padding: 40px 36px; border-radius: 20px; box-shadow: var(--shadow-md); width: 100%; max-width: 380px; }
.admin-login-card img { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px; }
.admin-login-card h1 { text-align: center; font-size: 19px; font-weight: 800; margin: 0 0 6px; }
.admin-login-card p { text-align: center; color: var(--gray-soft); font-size: 13px; margin: 0 0 26px; }

@media (max-width: 860px) {
  .admin-sidebar { position: fixed; left: -240px; z-index: 50; transition: left .2s ease; }
  .admin-sidebar.open { left: 0; }
  .admin-content { width: 100%; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .form-row.two-col { grid-template-columns: 1fr; }
  .admin-table { display: block; overflow-x: auto; }
}

/* 이 기기로 알림 받기 버튼 (관리자 상단바) */
.push-enable-btn {
  display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: #fff;
  color: var(--gray); font-size: 12.5px; font-weight: 700; padding: 8px 14px; border-radius: 999px;
  transition: all .15s ease;
}
.push-enable-btn:hover { background: var(--bg-soft); color: var(--primary-deep); }
.push-enable-btn.is-subscribed { background: var(--primary-tint); color: var(--primary-deep); border-color: var(--primary); }

/* VAPID 키 표시용 코드 박스 */
.code-box {
  background: #1E2429; color: #C9D6DD; padding: 16px 18px; border-radius: 12px; font-size: 12px;
  line-height: 1.7; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-family: 'SFMono-Regular', Consolas, monospace;
}

@media (max-width: 640px) {
  .push-enable-btn span { display: none; }
  .push-enable-btn { padding: 8px 10px; }
}

/* PWA 홈화면 앱(standalone)에서 iOS 노치/상태바 영역과 콘텐츠가 겹치지 않도록 여백 확보 */
.admin-topbar { padding-top: calc(0px + env(safe-area-inset-top)); }
.admin-sidebar { padding-top: env(safe-area-inset-top); }
