/* ==========================================================================
   Kiosk CMS - Bootstrap 5 기반 테마
   ========================================================================== */
:root {
  --kc-sidebar-w: 248px;
  --kc-radius: 14px;
  --kc-bg: #f4f6fa;
  --kc-surface: #ffffff;
  --kc-border: #e6e9f0;
  --kc-muted: #6b7280;
  --kc-text: #1f2937;
  --kc-primary: #3b5bdb;
  --kc-primary-soft: #edf2ff;
  --kc-sidebar-bg: #111827;
  --kc-sidebar-text: #9ca3af;
  --kc-sidebar-active: #ffffff;
  --kc-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --kc-online: #12b886;
  --kc-offline: #fa5252;
  --kc-shutdown: #868e96;
  --kc-pending: #f59f00;
  --bs-primary: #3b5bdb;
  --bs-primary-rgb: 59, 91, 219;
  --bs-link-color: #3b5bdb;
  --bs-link-color-rgb: 59, 91, 219;
  --bs-body-font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
}

[data-bs-theme="dark"] {
  --kc-bg: #0f1218;
  --kc-surface: #171b23;
  --kc-border: #262c38;
  --kc-muted: #9aa3b2;
  --kc-text: #e5e7eb;
  --kc-primary-soft: rgba(91, 124, 250, .15);
  --kc-sidebar-bg: #0b0e13;
  --kc-shadow: none;
  --bs-body-bg: #0f1218;
}

[data-bs-theme="dark"] .btn-light {
  --bs-btn-bg: #222834; --bs-btn-border-color: #2c3340; --bs-btn-color: #e5e7eb;
  --bs-btn-hover-bg: #2c3340; --bs-btn-hover-border-color: #363e4d; --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #363e4d;
}

body {
  background: var(--kc-bg);
  color: var(--kc-text);
  font-size: .925rem;
  letter-spacing: -.01em;
}

.btn-primary {
  --bs-btn-bg: var(--kc-primary);
  --bs-btn-border-color: var(--kc-primary);
  --bs-btn-hover-bg: #3249c2;
  --bs-btn-hover-border-color: #3249c2;
  --bs-btn-active-bg: #2b40ad;
}
.btn { border-radius: 10px; font-weight: 500; }
.btn-sm { border-radius: 8px; }
.form-control, .form-select { border-radius: 10px; border-color: var(--kc-border); }
.form-control:focus, .form-select:focus { border-color: #91a7ff; box-shadow: 0 0 0 .2rem rgba(59, 91, 219, .15); }
.form-label { font-weight: 600; font-size: .85rem; color: var(--kc-muted); margin-bottom: .3rem; }

/* ---------- 레이아웃 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--kc-sidebar-w);
  background: var(--kc-sidebar-bg);
  color: var(--kc-sidebar-text);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 1040;
  transition: transform .2s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.25rem 1.25rem 1rem;
  color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none;
}
.sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #4c6ef5, #15aabf);
  display: grid; place-items: center; font-size: 1.05rem;
}
.sidebar .nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; padding: 1rem 1.4rem .4rem; color: #6b7280; }
.sidebar .nav-link {
  color: var(--kc-sidebar-text);
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; margin: .1rem .75rem;
  border-radius: 10px; font-weight: 500;
}
.sidebar .nav-link i { font-size: 1.1rem; width: 1.2rem; text-align: center; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.sidebar .nav-link.active { color: var(--kc-sidebar-active); background: rgba(91, 124, 250, .22); }
.sidebar .nav-link .badge { margin-left: auto; }
.sidebar .sidebar-footer { margin-top: auto; padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .06); }
.sidebar .user-chip { display: flex; align-items: center; gap: .6rem; color: #e5e7eb; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #364fc7; color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}

.main { flex: 1; margin-left: var(--kc-sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 1.75rem;
  background: color-mix(in srgb, var(--kc-bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--kc-border);
}
.topbar h1 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.topbar .subtitle { color: var(--kc-muted); font-size: .85rem; }
.content { padding: 1.5rem 1.75rem 3rem; }

.live-indicator { font-size: .8rem; color: var(--kc-muted); display: flex; align-items: center; gap: .4rem; }
.live-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kc-shutdown); }
.live-indicator.connected .dot { background: var(--kc-online); box-shadow: 0 0 0 3px rgba(18, 184, 134, .2); }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .main { margin-left: 0; }
  .content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; }
}

/* ---------- 카드 ---------- */
.card {
  border: 1px solid var(--kc-border);
  border-radius: var(--kc-radius);
  background: var(--kc-surface);
  box-shadow: var(--kc-shadow);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--kc-border);
  padding: 1rem 1.25rem; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.card-body { padding: 1.25rem; }
.card-title-sm { font-size: .8rem; color: var(--kc-muted); font-weight: 600; }

.stat-card { padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.3rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { color: var(--kc-muted); font-size: .82rem; font-weight: 500; }
.bg-soft-primary { background: var(--kc-primary-soft); color: var(--kc-primary); }
.bg-soft-success { background: rgba(18, 184, 134, .12); color: #0ca678; }
.bg-soft-danger { background: rgba(250, 82, 82, .12); color: #e03131; }
.bg-soft-warning { background: rgba(245, 159, 0, .14); color: #e67700; }
.bg-soft-secondary { background: rgba(134, 142, 150, .14); color: #868e96; }

/* ---------- 상태 배지 ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .22rem .65rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-online { background: rgba(18, 184, 134, .12); color: #0ca678; }
.status-online::before { animation: pulse 2s infinite; }
.status-offline { background: rgba(250, 82, 82, .12); color: #e03131; }
.status-shutdown { background: rgba(134, 142, 150, .15); color: #6b7280; }
.status-pending { background: rgba(245, 159, 0, .15); color: #e67700; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(18, 184, 134, .5); } 70% { box-shadow: 0 0 0 6px rgba(18, 184, 134, 0); } 100% { box-shadow: 0 0 0 0 rgba(18, 184, 134, 0); } }

.badge-soft { font-weight: 600; padding: .35em .65em; border-radius: 6px; }

/* ---------- 기기 카드 (대시보드) ---------- */
.device-card { overflow: hidden; transition: transform .15s ease, box-shadow .15s ease; height: 100%; }
.device-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 24, 40, .08); }
.device-card .shot {
  position: relative; height: 190px;
  background: #0b0e13 repeating-linear-gradient(45deg, #11151c 0 10px, #0d1117 10px 20px);
  display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--kc-border);
}
.device-card .shot img { max-width: 100%; max-height: 100%; object-fit: contain; }
.device-card .shot .placeholder-icon { color: #4b5563; font-size: 2.2rem; }
.device-card .shot .status-pill { position: absolute; top: .65rem; left: .65rem; backdrop-filter: blur(6px); }
.device-card .device-name { font-weight: 700; font-size: 1rem; }

.meter { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--kc-muted); }
.meter .progress { flex: 1; height: 6px; border-radius: 99px; background: var(--kc-border); }
.meter .label { width: 34px; }
.meter .value { width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 테이블 ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .8rem 1rem; border-bottom-color: var(--kc-border); vertical-align: middle; }
.table thead th { font-size: .78rem; font-weight: 600; color: var(--kc-muted); text-transform: none; background: transparent; white-space: nowrap; }
.table-hover tbody tr:hover > * { background: var(--kc-primary-soft); }
.table .cell-main { font-weight: 600; }
.table .cell-sub { font-size: .8rem; color: var(--kc-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; }

.progress-thin { height: 6px; border-radius: 99px; background: var(--kc-border); }

/* ---------- 탭 ---------- */
.nav-tabs-clean { border-bottom: 1px solid var(--kc-border); gap: .25rem; }
.nav-tabs-clean .nav-link {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--kc-muted); font-weight: 600; padding: .75rem 1rem;
}
.nav-tabs-clean .nav-link.active { color: var(--kc-primary); border-bottom-color: var(--kc-primary); background: transparent; }

/* ---------- 기타 ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--kc-muted); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .75rem; opacity: .6; }

.dropzone {
  border: 2px dashed var(--kc-border); border-radius: var(--kc-radius);
  padding: 2rem 1rem; text-align: center; color: var(--kc-muted);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--kc-primary); background: var(--kc-primary-soft); color: var(--kc-primary); }
.dropzone i { font-size: 2rem; }

.screenshot-viewer {
  background: #0b0e13; border-radius: var(--kc-radius);
  min-height: 360px; display: grid; place-items: center; overflow: hidden; position: relative;
}
.screenshot-viewer img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.screenshot-viewer .overlay-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #adb5bd; background: rgba(11, 14, 19, .6); }
.shot-thumb { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; border: 2px solid transparent; cursor: pointer; background: #0b0e13; }
.shot-thumb.active, .shot-thumb:hover { border-color: var(--kc-primary); }

.info-list { display: grid; grid-template-columns: 140px 1fr; row-gap: .65rem; column-gap: 1rem; margin: 0; }
.info-list dt { color: var(--kc-muted); font-weight: 500; font-size: .85rem; }
.info-list dd { margin: 0; font-weight: 500; word-break: break-all; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(76, 110, 245, .18), transparent), radial-gradient(900px 500px at 110% 110%, rgba(21, 170, 191, .15), transparent), var(--kc-bg); }
.auth-card { width: 100%; max-width: 410px; padding: 2.25rem; }
.auth-card .logo { width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, #4c6ef5, #15aabf); color: #fff; display: grid; place-items: center; font-size: 1.4rem; }

.copy-box { display: flex; gap: .5rem; }
.copy-box code { flex: 1; padding: .55rem .8rem; background: var(--kc-bg); border: 1px solid var(--kc-border); border-radius: 10px; color: var(--kc-text); word-break: break-all; }

pre.code { background: #0f1218; color: #e5e7eb; border-radius: 10px; padding: 1rem; font-size: .82rem; white-space: pre-wrap; word-break: break-all; }
