/* ================================================
   알라딘박스 총관리자 - admin2 스타일시트
   ================================================ */

:root {
  --primary:    #2563eb;
  --primary-dk: #1d4ed8;
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --info:       #06b6d4;
  --sidebar-bg: #1a1a2e;
  --sidebar-w:  240px;
  --header-h:   56px;
  --text-muted: #6b7280;
  --border:     #e5e7eb;
  --card-r:     12px;
}

*, *::before, *::after { box-sizing: border-box; }

/* ★ 스크롤바 폭 항상 예약 — 페이지별 스크롤바 유무로 컨텐츠 폭이 점프(메뉴 간격 들쭉날쭉)하던 것 방지 */
html { overflow-y: scroll; }

/* ★ 폼 컨트롤 라이트 강제 — Windows 다크모드에서 select 팝업이 다크로 렌더돼 옵션 글씨가
   흰색(흰 배경에 안 보임)이던 전 페이지 공통 버그 방지. color-scheme:light + 명시 색상. */
:root { color-scheme: light; }
select, option,
input, textarea,
.form-control, .form-select {
  color: #111827;
  background-color: #fff;
}
select option { color: #111827; background-color: #fff; }

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1rem;
  background: #f3f4f6;
  color: #111827;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ─── Sidebar ─── */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  transition: width .25s ease;
  z-index: 1000;
  overflow: hidden;
}
#sidebar.collapsed { width: 60px; }
#sidebar.collapsed .sidebar-label,
#sidebar.collapsed .sidebar-section-title { display: none; }
#sidebar.collapsed .nav-link { justify-content: center; padding: .55rem .6rem; }
#sidebar.collapsed .nav-icon { margin: 0; }

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: var(--header-h);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem; flex-shrink: 0;
}
.sidebar-logo-text { color: #fff; font-weight: 700; font-size: .95rem; white-space: nowrap; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.sidebar-section-title {
  color: rgba(255,255,255,.35);
  font-size: .65rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase;
  padding: 14px 18px 4px;
}
#sidebar .nav-link {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.65) !important;
  padding: .6rem 1.1rem; border-radius: 0;
  transition: background .15s, color .15s;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  font-size: .92rem;
}
#sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff !important; }
#sidebar .nav-link.active { background: rgba(37,99,235,.35); color: #fff !important; border-right: 3px solid var(--primary); }
.nav-icon { font-size: 1.05rem; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--danger);
  color: #fff; font-size: .65rem; padding: 1px 6px; border-radius: 10px;
}

/* ─── Header ─── */
#header {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--header-h);
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
  z-index: 999; transition: left .25s ease;
}
#sidebar.collapsed ~ #header { left: 60px; }
.header-title { font-weight: 700; font-size: 1.05rem; flex: 1; }

/* ─── Main ─── */
#main {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 24px;
  min-height: calc(100vh - var(--header-h));
  transition: margin-left .25s ease;
}
#sidebar.collapsed ~ #header ~ #main { margin-left: 60px; }

/* ─── Stat Cards ─── */
.stat-card {
  background: #fff; border-radius: var(--card-r);
  padding: 20px 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  display: flex; flex-direction: column; gap: 6px;
  border-left: 4px solid transparent;
}
.stat-card.c-primary  { border-color: var(--primary); }
.stat-card.c-success  { border-color: var(--success); }
.stat-card.c-warning  { border-color: var(--warning); }
.stat-card.c-danger   { border-color: var(--danger); }
.stat-card.c-info     { border-color: var(--info); }
.stat-card.c-purple   { border-color: #8b5cf6; }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-sub   { font-size: .72rem; color: var(--text-muted); }

/* ─── Section Cards ─── */
.section-card {
  background: #fff; border-radius: var(--card-r);
  box-shadow: 0 1px 4px rgba(0,0,0,.07); overflow: hidden;
}
.section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 1rem;
}
.section-header .badge { font-size: .7rem; font-weight: 500; }

/* ─── Tables ─── */
.compact-table th, .compact-table td {
  padding: .6rem 1rem; font-size: .95rem; vertical-align: middle;
  color: #111; white-space: nowrap;
}
.compact-table thead th {
  background: #f9fafb; color: #1f2937;
  font-weight: 700; font-size: .85rem; letter-spacing: .02em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.compact-table tbody tr { border-bottom: 1px solid #f3f4f6; }
.compact-table tbody tr:hover { background: #f0f7ff; }
.compact-table { table-layout: auto; }
.compact-table tbody tr:hover {
  background: #f8fafc;
}

/* ─── Status Badge ─── */
.badge-online  { background: #dcfce7; color: #15803d; }
.badge-offline { background: #fee2e2; color: #b91c1c; }
.badge-warn    { background: #fef3c7; color: #92400e; }
.badge-pill { border-radius: 20px; padding: 2px 8px; font-size: .7rem; font-weight: 600; }

/* ─── Pulse dot ─── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: var(--success); box-shadow: 0 0 0 3px #dcfce7; animation: pulse 1.5s infinite; }
.dot-red   { background: var(--danger); }
.dot-gray  { background: #9ca3af; }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 3px #dcfce7; } 50%{ box-shadow: 0 0 0 6px rgba(16,185,129,.1); } }

/* ─── Chart placeholder ─── */
.chart-ph {
  height: 180px; background: #f9fafb; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--text-muted);
}
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 80px; }
.chart-bar { width: 22px; background: var(--primary); border-radius: 4px 4px 0 0; opacity: .8; }

/* ─── Tabs (main nav) ─── */
.main-tabs .nav-link {
  color: #6b7280 !important; padding: .45rem 1rem; border-radius: 0;
  border-bottom: 2px solid transparent;
  background: transparent !important;
}
.main-tabs .nav-link.active { color: var(--primary) !important; border-bottom-color: var(--primary); }
.main-tabs .nav-link:hover { color: #111827 !important; background: transparent !important; }

/* ─── Toolbar ─── */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar .form-control,
.toolbar .form-select {
  font-size: .95rem; padding: .45rem .75rem;
  max-width: 260px; height: 40px;
}
.toolbar .btn {
  font-size: .9rem; padding: .4rem .85rem; height: 40px;
}

/* ─── Pagination ─── */
.pagination-wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: .8rem;
}
.pagination-wrap .page-info {
  color: var(--text-muted);
}
.pagination-wrap .btn-group .btn {
  font-size: .78rem; padding: .25rem .5rem;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.modal-overlay.show {
  opacity: 1; pointer-events: auto;
}
.modal-box {
  background: #fff; border-radius: var(--card-r);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 540px; max-width: 95vw; max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .92rem;
}
.modal-header .btn-close {
  background: none; border: none; font-size: 1.1rem; cursor: pointer;
  color: var(--text-muted);
}
.modal-body {
  padding: 20px;
}
.modal-body label {
  font-size: .78rem; font-weight: 600; color: #374151;
  margin-bottom: 3px; display: block;
}
.modal-body .form-control,
.modal-body .form-select {
  font-size: .82rem; padding: .4rem .6rem;
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ─── Toast ─── */
#toastContainer {
  position: fixed; top: 70px; right: 20px;
  z-index: 3000; display: flex; flex-direction: column; gap: 8px;
}
.toast-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px;
  font-size: .82rem; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  animation: toastIn .3s ease;
  min-width: 260px;
}
.toast-item.toast-success { background: #dcfce7; color: #15803d; border-left: 4px solid var(--success); }
.toast-item.toast-error   { background: #fee2e2; color: #b91c1c; border-left: 4px solid var(--danger); }
.toast-item.toast-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--primary); }
.toast-item.toast-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Login page ─── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.login-card {
  background: #fff; border-radius: 16px;
  padding: 40px 36px; width: 380px; max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card h3 { font-weight: 700; margin-bottom: 6px; }
.login-card .subtitle { color: var(--text-muted); font-size: .85rem; margin-bottom: 28px; }
.login-card .form-control {
  font-size: .88rem; padding: .5rem .75rem;
}
.login-card .btn-primary {
  width: 100%; padding: .55rem; font-size: .9rem; font-weight: 600;
}

/* ─── Sidebar Bottom / Field Mode ─── */
.sidebar-bottom {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.field-mode-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.55);
  border-radius: 8px;
  padding: .45rem .85rem;
  font-size: .8rem; font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.field-mode-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.field-mode-btn.active {
  background: rgba(16,185,129,.2);
  border-color: rgba(16,185,129,.5);
  color: #6ee7b7;
}
#sidebar.collapsed .field-mode-btn { justify-content: center; padding: .45rem .6rem; }
#sidebar.collapsed .field-mode-btn .sidebar-label { display: none; }

/* ─── Sidebar Overlay (mobile) ─── */
#sidebarOverlay {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
#sidebarOverlay.show { display: block; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  #sidebar { width: 0 !important; }
  #header, #main { left: 0 !important; margin-left: 0 !important; }
  #sidebar.mobile-open { width: var(--sidebar-w) !important; }
  #main { padding: 14px 12px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 14px; }
  .toolbar .form-control,
  .toolbar .form-select { max-width: 100%; font-size: .9rem; }
  .toolbar .ms-auto { margin-left: 0 !important; width: 100%; }
  .toolbar .ms-auto .d-flex { flex-direction: column; gap: 6px !important; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: .8rem; }
  .section-header { padding: 12px 14px; font-size: .9rem; }
  .modal-box { width: 95vw; margin: 0 auto; }
  .modal-body .col-6 { flex: 0 0 100%; max-width: 100%; }
}

/* ─── Card View (mobile list) ─── */
.card-list { display: none; }
@media (max-width: 767px) {
  .table-view { display: none !important; }
  .card-list { display: block; }
}
.mobile-card {
  background: #fff; border-radius: var(--card-r);
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  margin-bottom: 12px;
  cursor: pointer;
  transition: box-shadow .15s;
  border-left: 3px solid var(--primary);
}
.mobile-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.mobile-card:active { transform: scale(.99); }
.mobile-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mobile-card-title { font-weight: 600; font-size: .95rem; color: #1f2937; }
.mobile-card-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: .84rem; color: #4b5563; }
.mobile-card-row span { display: flex; align-items: center; gap: 5px; }
.mobile-card-row i { font-size: .85rem; color: #9ca3af; }

/* ─── Cabinet Layout ─── */
.cabinet-layout {
  display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap;
}
.cabinet-column {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 80px;
}
.cabinet-column-title {
  font-size: .68rem; font-weight: 600; color: var(--text-muted);
  text-align: center; padding: 2px 0;
}
.box-cell {
  border-radius: 8px; padding: 10px 14px;
  font-size: .82rem; font-weight: 600;
  text-align: center; cursor: pointer;
  transition: opacity .15s, transform .1s;
  border: 1px solid transparent;
  white-space: nowrap;
  min-width: 70px;
}
.box-cell:hover { opacity: .85; transform: scale(1.03); }
.box-cell.box-empty        { background: #dcfce7; color: #15803d; border-color: #86efac; }
.box-cell.box-in-use       { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.box-cell.box-maintenance  { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.box-cell.box-disabled     { background: #f3f4f6; color: #9ca3af; border-color: #d1d5db; }
.box-cell.box-unknown      { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

.cabinet-stats-bar {
  display: flex; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
}
.cabinet-stats-bar .stat-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-weight: 600;
}
.stat-chip.chip-total       { background: #e0e7ff; color: #3730a3; }
.stat-chip.chip-empty       { background: #dcfce7; color: #15803d; }
.stat-chip.chip-in-use      { background: #dbeafe; color: #1e40af; }
.stat-chip.chip-maintenance { background: #fee2e2; color: #b91c1c; }
.stat-chip.chip-disabled    { background: #f3f4f6; color: #6b7280; }

/* ─── Tree nav ─── */
.kiosk-tree { font-size: .82rem; }
.kiosk-tree .tree-group {
  font-weight: 600; color: #374151;
  padding: 6px 8px; cursor: pointer;
  border-radius: 6px;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 2px;
}
.kiosk-tree .tree-group:hover { background: #f3f4f6; }
.kiosk-tree .tree-kiosk {
  padding: 5px 8px 5px 28px;
  border-radius: 6px; cursor: pointer;
  color: #6b7280;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 1px;
}
.kiosk-tree .tree-kiosk:hover { background: #f3f4f6; color: #111; }
.kiosk-tree .tree-kiosk.active { background: #dbeafe; color: #1e40af; font-weight: 600; }

/* ─── Misc ─── */
.clickable { cursor: pointer; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
code { font-size: .75rem; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
