/* ── G-Scan Custom Styles ── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-bg: #eff6ff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #ca8a04;
}

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

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header / Nav ── */
.header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo { display: flex; flex-direction: column; margin-right: 40px; cursor: pointer; }
.logo-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.logo-sub { font-size: 11px; color: var(--text-light); margin-top: -2px; }

.nav-tabs { display: flex; gap: 0; height: 56px; align-items: stretch; }
.nav-tab {
  padding: 0 18px;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}
.nav-tab:hover { color: var(--primary); }
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gear-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: #fff;
  color: var(--text-light);
  font-size: 16px;
  transition: all 0.2s;
}
.gear-btn:hover { background: var(--primary-bg); color: var(--primary); }

/* ── Main Content ── */
.main-content { padding: 24px 32px; max-width: 1440px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Dashboard Cards ── */
.metric-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  transition: box-shadow 0.2s;
}
.metric-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.metric-label { font-size: 13px; color: var(--text-light); margin-bottom: 6px; }
.metric-value { font-size: 32px; font-weight: 700; color: var(--text); }

/* ── Chart Containers ── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.chart-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.chart-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.chart-canvas-wrap { position: relative; width: 100%; height: 400px; }
.chart-canvas-wrap canvas { width: 100% !important; height: 100% !important; }

.chart-full {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

/* ── Two Column Layout (조직도, 통계) ── */
.two-col { display: grid; grid-template-columns: 340px 1fr; gap: 20px; min-height: 600px; }

.side-list {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow-y: auto;
  max-height: 700px;
}

.side-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  outline: none;
}
.side-search:focus { border-color: var(--primary-light); }

.gov-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.gov-item:hover { background: var(--primary-bg); }
.gov-item .arrow { color: var(--primary); font-size: 12px; margin-right: 6px; }
.gov-item .count { color: var(--text-light); font-size: 13px; }
.gov-item.expanded .arrow { transform: rotate(90deg); }

.gov-children { display: none; padding-left: 20px; }
.gov-children.show { display: block; }
.gov-child {
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}
.gov-child:hover { background: var(--primary-bg); color: var(--primary); }

.right-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-msg {
  text-align: center;
  color: var(--text-light);
}
.placeholder-msg .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.placeholder-msg h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.placeholder-msg p { font-size: 13px; line-height: 1.6; }

/* ── Search Tab ── */
.search-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; }

.filter-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.filter-panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.filter-group { margin-bottom: 16px; }
.filter-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: block; }

.filter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.filter-input:focus { border-color: var(--primary-light); }

.filter-row { display: flex; align-items: center; gap: 6px; }
.filter-row input[type="number"] { width: 80px; }
.filter-row span { color: var(--text-light); font-size: 13px; }

.checkbox-row { display: flex; gap: 16px; }
.checkbox-row label { font-size: 13px; display: flex; align-items: center; gap: 4px; cursor: pointer; }

.btn-primary {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: #1e3a8a; }

.export-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-export {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.btn-export.xlsx { background: var(--primary); color: #fff; border: none; }
.btn-export.hwpx { background: #fff; color: var(--text); border: 1px solid var(--border); }

.result-table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-table thead { background: var(--primary); color: #fff; }
.result-table th { padding: 12px 14px; text-align: left; font-weight: 500; white-space: nowrap; }
.result-table td { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; }
.result-table tbody tr:hover { background: var(--primary-bg); }
.result-placeholder {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
}

/* ── Comparison Tab ── */
.compare-header { margin-bottom: 20px; }
.compare-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.compare-bar label { font-size: 13px; color: var(--text-light); white-space: nowrap; }

.compare-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.btn-outline {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.tag-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tag {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.tag.base { background: var(--primary); color: #fff; }
.tag.target { background: #fff; border: 1px solid var(--border); color: var(--text); }
.tag .remove { margin-left: 6px; opacity: 0.5; }
.tag .remove:hover { opacity: 1; }

.compare-filters { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.filter-chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  transition: all 0.15s;
}
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.compare-keyword {
  flex: 1;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

.compare-table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  margin-bottom: 20px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  padding: 14px 16px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title .toggle { cursor: pointer; }

.cmp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp-table thead th {
  background: #f9fafb;
  padding: 10px 14px;
  text-align: right;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.cmp-table thead th:first-child { text-align: left; }
.cmp-table td {
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid #f3f4f6;
}
.cmp-table td:first-child { text-align: left; font-weight: 500; }
.cmp-table .up { color: var(--danger); font-size: 11px; margin-left: 4px; }
.cmp-table .down { color: var(--primary-light); font-size: 11px; margin-left: 4px; }
.sparkline { display: inline-block; width: 40px; height: 16px; vertical-align: middle; margin-right: 4px; }

.ai-report-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.count-badge {
  font-size: 12px;
  background: #f0f4f8;
  color: var(--text-light);
  padding: 2px 10px;
  border-radius: 10px;
  margin-left: auto;
}

/* ── Data Management Tab ── */
.data-mgmt-header {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.data-mgmt-header h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.data-mgmt-header p { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.data-mgmt-layout { display: grid; grid-template-columns: 280px 1fr 280px; gap: 16px; min-height: 550px; }

.dept-list {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-y: auto;
  max-height: 550px;
}
.dept-list-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.dept-list-header input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}
.dept-list-header button {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.dept-item {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.15s;
}
.dept-item:hover { background: var(--primary-bg); }
.dept-item .name { font-weight: 600; font-size: 14px; }
.dept-item .sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.iframe-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}
.iframe-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.iframe-bar button {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}
.iframe-url {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-light);
}
.btn-go {
  padding: 5px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.iframe-body { flex: 1; padding: 20px; color: var(--text-light); font-size: 13px; }

.ai-crawl-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.btn-crawl {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-crawl:hover { opacity: 0.9; }

/* ── Chat Widget ── */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(30,64,175,0.3);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.chat-toggle:hover { transform: scale(1.08); }
.chat-toggle.hidden { display: none; }

.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 540px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 200;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.chat-widget.open { display: flex; }

.chat-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-header .avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.chat-header .info { flex: 1; }
.chat-header .info h4 { font-size: 14px; font-weight: 600; }
.chat-header .info p { font-size: 11px; opacity: 0.8; }
.chat-header-actions { display: flex; gap: 8px; }
.chat-header-actions button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.chat-header-actions button:hover { opacity: 1; }

.chat-body {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.chat-welcome { text-align: center; }
.chat-welcome .bubble { font-size: 36px; margin-bottom: 12px; opacity: 0.6; }
.chat-welcome h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.chat-welcome p { font-size: 12px; color: var(--text-light); line-height: 1.6; margin-bottom: 16px; }

.chat-suggestions { width: 100%; }
.chat-suggestion {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.15s;
  color: var(--text);
}
.chat-suggestion:hover { border-color: var(--primary-light); background: var(--primary-bg); }

.chat-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  resize: none;
  outline: none;
  font-family: inherit;
}
.chat-input:focus { border-color: var(--primary-light); }
.chat-send {
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.chat-send:hover { background: #1e3a8a; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-box h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-box p { font-size: 13px; color: var(--text-light); margin-bottom: 20px; }
.modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 20px;
  outline: none;
}
.modal-input:focus { border-color: var(--primary-light); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-cancel {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.btn-confirm {
  padding: 8px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

/* ── Info box ── */
.info-box {
  background: #eff6ff;
  border-left: 4px solid var(--primary-light);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
  color: #1e40af;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .metric-cards { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 280px 1fr; }
  .data-mgmt-layout { grid-template-columns: 240px 1fr 240px; }
}

@media (max-width: 768px) {
  .header { padding: 0 16px; }
  .main-content { padding: 16px; }
  .metric-cards { grid-template-columns: repeat(2, 1fr); }
  .two-col, .search-layout { grid-template-columns: 1fr; }
  .data-mgmt-layout { grid-template-columns: 1fr; }
  .nav-tabs { overflow-x: auto; }
  .chat-widget { width: calc(100vw - 32px); right: 16px; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Utility ── */
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-light); }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
