/* =====================================================
   Monitor Platform - Main Stylesheet
   ===================================================== */

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

:root {
  --sidebar-w: 240px;
  --topbar-h:  60px;

  --bg-body:    #f0f2f5;
  --bg-sidebar: #1a1f2e;
  --bg-card:    #ffffff;
  --bg-hover:   #252d40;

  --accent:     #4f7ef8;
  --accent-dk:  #3a66e0;
  --success:    #22c55e;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --unknown:    #6b7280;

  --text-primary:   #1e293b;
  --text-secondary: #64748b;
  --text-sidebar:   #94a3b8;
  --text-sidebar-active: #ffffff;

  --border:     #e2e8f0;
  --radius:     10px;
  --shadow:     0 1px 4px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.12);
}

html, body { height: 100%; font-family: 'Pretendard', 'Noto Sans KR', -apple-system, sans-serif; font-size: 14px; color: var(--text-primary); background: var(--bg-body); }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.sidebar-logo span {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: #4b5563;
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  cursor: pointer;
}

.nav-item:hover { background: var(--bg-hover); color: #d1d5db; }
.nav-item.active { background: var(--bg-hover); color: var(--text-sidebar-active); border-left: 3px solid var(--accent); }

.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name  { font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 7px;
  color: #9ca3af;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #e2e8f0; }

/* ── Main Content ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 { font-size: 18px; font-weight: 700; color: var(--text-primary); }

.page-content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }

/* ── Stat Cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* 서버 상태 카드 전용 3열 그리드 */
.server-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 768px) {
  .server-stat-grid { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.green  { background: #dcfce7; }
.stat-icon.red    { background: #fee2e2; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.yellow { background: #fef9c3; }

.stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); }

/* ── Status Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

.badge-up      { background: #dcfce7; color: #166534; }
.badge-down    { background: #fee2e2; color: #991b1b; }
.badge-unknown { background: #f1f5f9; color: #475569; }

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.dot-up      { background: var(--success); box-shadow: 0 0 0 2px rgba(34,197,94,.25); }
.dot-down    { background: var(--danger);  box-shadow: 0 0 0 2px rgba(239,68,68,.25); }
.dot-unknown { background: var(--unknown); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead tr { background: #f8fafc; }
th { padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
td { padding: 13px 14px; border-top: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tr:hover td { background: #fafafa; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-secondary { background: #f1f5f9; color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-icon { padding: 6px 10px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,126,248,.15); }

.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle {
  position: relative;
  width: 40px; height: 22px;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #d1d5db;
  border-radius: 99px;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.empty-state p  { font-size: 13.5px; }

/* ── Service Cards (Dashboard) ── */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow .2s;
}
.service-card:hover { box-shadow: var(--shadow-md); }

.service-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.service-card-title { font-size: 15px; font-weight: 700; }
.service-card-url   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; word-break: break-all; }

.endpoint-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

.endpoint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 7px;
  font-size: 13px;
}
.endpoint-row .ep-name { font-weight: 500; }
.endpoint-row .ep-ms   { font-size: 11.5px; color: var(--text-secondary); }

/* ── Log Table ── */
.log-status-up   { color: var(--success); font-weight: 600; }
.log-status-down { color: var(--danger);  font-weight: 600; }

/* ── Auth Layout ── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1f2e 0%, #252d40 100%);
}

.auth-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  justify-content: center;
}
.auth-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.auth-logo span { font-size: 20px; font-weight: 800; }

.auth-title    { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.auth-subtitle { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 28px; }
.auth-footer   { margin-top: 20px; text-align: center; font-size: 13px; color: var(--text-secondary); }
.auth-footer a { color: var(--accent); font-weight: 600; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; }

/* ── Utility ── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 6px; font-size: 13px;
  border: 1px solid var(--border); color: var(--text-primary); text-decoration: none;
}
.pagination a:hover { background: var(--bg-body); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .disabled { color: var(--text-secondary); pointer-events: none; }
.pagination-info { text-align: center; font-size: 12px; color: var(--text-secondary); margin-top: 8px; }

/* ── Admin ── */
.admin-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.checklist li:last-child { border: none; }
.code-block { background: #1a1f2e; color: #e2e8f0; padding: 16px; border-radius: 8px; font-size: 12px; overflow-x: auto; white-space: pre; font-family: monospace; position: relative; margin: 12px 0; }
.copy-btn { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .1); color: #fff; border: none; padding: 4px 10px; border-radius: 4px; font-size: 11px; cursor: pointer; }
.copy-btn:hover { background: rgba(255, 255, 255, .2); }
.guide-section { margin-bottom: 28px; }
.guide-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: var(--text-primary); }

/* ── Stat Icon Purple ── */
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 16px; background: var(--bg-body); border-radius: 8px; margin-bottom: 4px; }
.filter-bar select, .filter-bar input[type=date] { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff; color: var(--text-primary); }
