/* JGOS — 전남광주 통합특별시 시민 AI 포털 */
@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@300;400;500;600;700;800&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f7f8fa;                       /* 시민포털 light */
  --bg-2: #ffffff;
  --panel-glass: rgba(255, 255, 255, 0.78);
  --panel-glass-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(0, 31, 70, 0.08);
  --border-strong: rgba(0, 31, 70, 0.16);
  --text: #1a1f2e;
  --text-dim: #5b6677;
  --text-faint: #8a94a3;
  --gov-blue: #0052a4;                 /* 정부 메인 블루 */
  --gov-blue-dark: #003d80;
  --gov-blue-light: #e6f0fa;
  --gov-green: #006a4e;                /* 신뢰/sovereign 그린 */
  --gov-orange: #c8550f;
  --accent: #0052a4;
  --accent-2: #0066cc;
  --user-bg: #0052a4;
  --user-text: #ffffff;
  --assistant-bg: #ffffff;
  --warn-bg: #fff7ed;
  --warn-border: #f59e0b;
  --warn-text: #92400e;
  --shadow-1: 0 1px 2px rgba(0,31,70,0.06), 0 1px 3px rgba(0,31,70,0.04);
  --shadow-2: 0 2px 8px rgba(0,31,70,0.08), 0 1px 3px rgba(0,31,70,0.04);
  --shadow-3: 0 12px 40px rgba(0,31,70,0.10), 0 4px 12px rgba(0,31,70,0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --backdrop: saturate(180%) blur(20px);
}
html, body { height: 100%; }
body {
  background: linear-gradient(180deg, #f7f8fa 0%, #eef2f7 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "맑은 고딕", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }

#app { display: flex; height: 100vh; height: 100dvh; }

/* ===== 모바일 햄버거 ===== */
#hamburger-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 1000;
  width: 40px; height: 40px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-2);
}
#hamburger-btn svg { width: 22px; height: 22px; }

/* ===== 사이드바 ===== */
#sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--panel-glass);
  backdrop-filter: var(--backdrop); -webkit-backdrop-filter: var(--backdrop);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform 0.25s ease;
}
.sidebar-head { padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.brand-top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.emblem {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--gov-blue); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.brand-title { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

#new-chat-btn {
  width: 100%; padding: 10px 14px;
  background: var(--gov-blue); color: white;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13.5px; font-weight: 600;
  transition: background 0.15s ease;
}
#new-chat-btn:hover { background: var(--gov-blue-dark); }

.sidebar-section-label {
  padding: 14px 16px 6px; font-size: 11px; font-weight: 600;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em;
}
#chat-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; list-style: none; }
#chat-list li {
  padding: 9px 12px; margin-bottom: 3px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.15s ease;
}
#chat-list li:hover { background: rgba(0, 82, 164, 0.06); }
#chat-list li.active { background: rgba(0, 82, 164, 0.12); color: var(--gov-blue); font-weight: 600; }

.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--border); }
.brand-small { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-dim); }
.brand-small small { color: var(--text-faint); font-size: 10.5px; }

/* ===== 메인 ===== */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: transparent; }

/* ===== 상단 ===== */
#topbar {
  padding: 12px 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel-glass-strong);
  backdrop-filter: var(--backdrop); -webkit-backdrop-filter: var(--backdrop);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
#sidebar-toggle {
  display: none; width: 36px; height: 36px;
  background: transparent; border: none; cursor: pointer;
  font-size: 20px; color: var(--text);
}
.title-block { min-width: 0; }
.title-main {
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.title-sub {
  font-size: 11.5px; color: var(--text-dim); margin-top: 2px;
}
.status-pill {
  font-size: 11.5px; color: #006a4e; font-weight: 600;
  background: #e8f5ee; padding: 4px 10px; border-radius: 12px;
  white-space: nowrap;
}
.status-pill.error { color: #c8550f; background: #fdf0e6; }

/* ===== 메시지 영역 ===== */
#messages-wrap {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
}
#messages {
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
  max-width: 960px; width: 100%; margin: 0 auto;
}
#messages:empty { display: none; }

.msg { padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow-1); }
.msg.user {
  background: var(--user-bg); color: var(--user-text);
  align-self: flex-end; max-width: 60%; padding: 9px 14px;
  font-size: 14px; line-height: 1.5; border-radius: 18px 18px 4px 18px;
  box-shadow: 0 1px 3px rgba(0, 82, 164, 0.16);
}
.msg.assistant {
  background: var(--assistant-bg); color: var(--text);
  align-self: stretch; max-width: 100%;
  border: 1px solid var(--border);
  position: relative;
}

.msg.user a { color: #cfe4ff; }
.msg.user code, .msg.user pre { background: rgba(255,255,255,0.18); color: #fff; }

/* markdown */
.msg h1, .msg h2, .msg h3, .msg h4 { margin: 14px 0 8px; font-weight: 600; line-height: 1.3; }
.msg h1 { font-size: 1.45em; } .msg h2 { font-size: 1.25em; } .msg h3 { font-size: 1.1em; } .msg h4 { font-size: 1.02em; }
.msg p { margin: 7px 0; }
.msg ul, .msg ol { margin: 7px 0 7px 24px; }
.msg li { margin: 3px 0; }
.msg code {
  background: rgba(0,31,70,0.05); padding: 2px 6px; border-radius: 5px;
  font-family: 'SF Mono', 'JetBrains Mono', Consolas, monospace; font-size: 0.9em;
}
.msg pre {
  background: #fafbfc; padding: 12px 14px; border-radius: 10px;
  overflow-x: auto; margin: 10px 0; border: 1px solid var(--border); font-size: 13px;
}
.msg pre code { background: none; padding: 0; }
.msg table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: 14px; }
.msg th, .msg td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.msg th { background: var(--gov-blue-light); font-weight: 600; color: var(--gov-blue-dark); }
.msg tr:nth-child(even) td { background: #fafbfc; }
.msg a { color: var(--gov-blue); text-decoration: none; }
.msg a:hover { text-decoration: underline; }
.msg blockquote {
  border-left: 3px solid var(--gov-blue); padding: 6px 14px; color: var(--text-dim);
  margin: 8px 0; background: rgba(0, 82, 164, 0.04); border-radius: 0 6px 6px 0;
}
.msg hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ===== 답변 신뢰 배지 (assistant 메시지 하단) ===== */
.trust-badges {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex; flex-wrap: wrap; gap: 6px; font-size: 11.5px;
}
.trust-badges .tb {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 10px;
  background: var(--gov-blue-light); color: var(--gov-blue-dark);
  font-weight: 500;
}
.trust-badges .tb.warn { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }
.trust-badges .tb.green { background: #e8f5ee; color: #006a4e; }
.trust-badges .tb.gray { background: #eef0f4; color: var(--text-dim); }

/* ===== 첨부파일 카드 (user 메시지 안 분리) ===== */
.msg-attachments-card {
  margin-top: 10px; padding: 10px 12px;
  background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.28);
  border-radius: 8px; display: flex; flex-direction: column; gap: 6px;
}
.msg.assistant .msg-attachments-card {
  background: var(--gov-blue-light); border-color: rgba(0, 82, 164, 0.18);
}
.attach-card-item {
  display: flex; align-items: center; gap: 10px; font-size: 12.5px;
}
.attach-card-item .ext-icon {
  width: 32px; height: 32px; border-radius: 6px;
  background: rgba(255,255,255,0.2); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.msg.assistant .attach-card-item .ext-icon {
  background: var(--gov-blue); color: white;
}
.attach-card-item .meta { flex: 1; min-width: 0; }
.attach-card-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-card-item .info { font-size: 11px; opacity: 0.85; }
.attach-card-item .status { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: rgba(0,200,100,0.16); color: #fff; }
.msg.assistant .attach-card-item .status { background: #e8f5ee; color: #006a4e; }

/* ===== 시민포털 첫 화면 ===== */
.portal {
  max-width: 980px; width: 100%; margin: 0 auto;
  padding: 32px 24px 48px;
}
.portal-hero { text-align: center; margin-bottom: 32px; }
.hero-emblem {
  width: 72px; height: 72px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--gov-blue) 0%, var(--gov-blue-dark) 100%);
  border-radius: 18px; color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px;
  box-shadow: 0 8px 24px rgba(0, 82, 164, 0.22);
}
.hero-title {
  font-size: 26px; font-weight: 700; line-height: 1.3; color: var(--text);
  margin-bottom: 10px;
}
.hero-title strong { color: var(--gov-blue); }
.hero-sub { color: var(--text-dim); font-size: 14.5px; line-height: 1.6; }

/* 8개 카테고리 큰 카드 */
.cat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 30px;
}
.cat-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 14px;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; cursor: pointer; text-align: center;
  transition: all 0.18s ease;
  box-shadow: var(--shadow-1);
}
.cat-card:hover {
  transform: translateY(-2px);
  border-color: var(--gov-blue);
  box-shadow: var(--shadow-3);
  background: linear-gradient(180deg, #ffffff 0%, var(--gov-blue-light) 100%);
}
.cat-card .cat-emoji { font-size: 32px; }
.cat-card .cat-name { font-size: 14px; font-weight: 700; color: var(--text); }
.cat-card .cat-desc { font-size: 11.5px; color: var(--text-dim); }

/* 추천 질문 */
.quick-section { margin-bottom: 28px; }
.quick-label {
  font-size: 12.5px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 10px; padding-left: 4px;
}
.quick-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.quick-btn {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 14px;
  font-size: 13px; color: var(--text); cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-1);
}
.quick-btn:hover {
  background: var(--gov-blue-light); border-color: var(--gov-blue);
  color: var(--gov-blue-dark);
}

/* 포털 하단 신뢰 표시 + NIA 문구 */
.portal-foot {
  margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border);
}
.trust-line {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-bottom: 14px;
}
.trust-badge {
  font-size: 11.5px; color: var(--text-dim);
  background: var(--bg-2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 10px;
}
.trust-disclaimer {
  font-size: 11.5px; color: var(--text-faint); line-height: 1.65;
  text-align: center; max-width: 780px; margin: 0 auto;
}

/* ===== 입력 영역 ===== */
#composer {
  border-top: 1px solid var(--border); padding: 14px 20px 14px;
  background: var(--panel-glass-strong);
  backdrop-filter: var(--backdrop); -webkit-backdrop-filter: var(--backdrop);
}

/* NIA K-AI 1위 출처 문구 (모든 화면 영구 표시) */
.nia-disclaimer {
  max-width: 960px; margin: 10px auto 0;
  font-size: 10.5px; line-height: 1.55;
  color: var(--text-faint);
  text-align: center;
  padding: 0 12px;
  letter-spacing: -0.01em;
}
@media (max-width: 768px) {
  .nia-disclaimer { font-size: 10px; padding: 0 6px; }
}
.warn-bar {
  max-width: 960px; margin: 0 auto 10px;
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  color: var(--warn-text); padding: 9px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.attach-row {
  max-width: 960px; margin: 0 auto 10px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.attach-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 16px; font-size: 12.5px; color: var(--text);
  box-shadow: var(--shadow-1);
}
.attach-pill .remove {
  background: none; border: none; cursor: pointer; color: var(--text-dim);
  font-size: 16px; padding: 0; line-height: 1;
}
.attach-pill .remove:hover { color: #c8550f; }
.attach-pill.processing { color: var(--gov-blue); }
.attach-pill .ext { font-weight: 700; color: var(--gov-blue); font-size: 11px;
  background: var(--gov-blue-light); padding: 2px 6px; border-radius: 4px; }

.input-row {
  display: flex; gap: 10px; align-items: flex-end;
  max-width: 960px; margin: 0 auto;
  background: var(--bg-2); border: 1.5px solid var(--border-strong); border-radius: 18px;
  padding: 6px 8px 6px 14px; box-shadow: var(--shadow-2);
}
.input-row:focus-within { border-color: var(--gov-blue); box-shadow: 0 0 0 3px rgba(0,82,164,0.12), var(--shadow-2); }
#attach-btn, #send-btn {
  background: none; border: none; cursor: pointer;
  padding: 10px; border-radius: 50%; transition: background 0.15s ease;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#attach-btn { color: var(--text-dim); font-size: 22px; }
#attach-btn:hover { background: rgba(0,31,70,0.06); color: var(--gov-blue); }
#send-btn { background: var(--gov-blue); color: white; padding: 10px 14px; }
#send-btn:hover { background: var(--gov-blue-dark); }
#send-btn:disabled { background: #c7c7cc; cursor: not-allowed; }
#send-btn svg { width: 18px; height: 18px; }
#input {
  flex: 1; padding: 10px 4px;
  background: transparent; color: var(--text);
  border: none; resize: none;
  font-family: inherit; font-size: 15px; line-height: 1.5;
  max-height: 200px; overflow-y: auto;
}
#input:focus { outline: none; }
#input::placeholder { color: var(--text-faint); }

/* drag-over overlay */
#drag-overlay {
  position: fixed; inset: 0; background: rgba(0, 82, 164, 0.06);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
  border: 4px dashed var(--gov-blue);
  pointer-events: auto; cursor: pointer;
}
#drag-overlay[hidden] { display: none !important; }
#drag-overlay .drop-card {
  background: var(--bg-2); padding: 30px 50px; border-radius: 20px;
  box-shadow: var(--shadow-3); font-size: 18px; font-weight: 600; color: var(--gov-blue);
  pointer-events: none;
}
#drag-overlay .drop-card small {
  display: block; margin-top: 8px; font-size: 12px; color: var(--text-dim); font-weight: 400;
}

/* cursor blink */
.cursor {
  display: inline-block; width: 6px; height: 16px;
  background: var(--gov-blue); animation: blink 0.8s infinite; vertical-align: middle;
  margin-left: 2px; border-radius: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* "생각 중" 인디케이터 */
.thinking-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-dim); font-size: 14px; font-style: italic;
  padding: 4px 0;
  animation: thinking-pulse 1.8s ease-in-out infinite;
}
.thinking-indicator .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(0,82,164,0.22);
  border-top-color: var(--gov-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes thinking-pulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1.0; } }

/* loader spinner */
.spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid rgba(0,82,164,0.3); border-top-color: var(--gov-blue);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* mobile-only utility */
.mobile-only { display: none; }

/* ===== Sidebar backdrop (mobile) ===== */
#sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 90; cursor: pointer;
}
#sidebar-backdrop[hidden] { display: none; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  #hamburger-btn { display: flex; }
  .mobile-only { display: flex; }

  #sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    z-index: 100; transform: translateX(-100%);
    box-shadow: 8px 0 32px rgba(0,0,0,0.18);
  }
  #sidebar.open { transform: translateX(0); }

  #topbar { padding: 14px 16px 14px 64px; }
  .title-main { font-size: 14px; }
  .title-sub { font-size: 11px; }

  #messages { padding: 16px; gap: 12px; }
  .msg.user { max-width: 80%; font-size: 13.5px; }

  .portal { padding: 24px 16px 32px; }
  .hero-emblem { width: 60px; height: 60px; font-size: 30px; border-radius: 14px; }
  .hero-title { font-size: 20px; }
  .hero-sub { font-size: 13px; }

  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-card { padding: 14px 10px; }
  .cat-card .cat-emoji { font-size: 26px; }
  .cat-card .cat-name { font-size: 13px; }
  .cat-card .cat-desc { font-size: 11px; }

  .quick-btn { font-size: 12px; padding: 7px 12px; }
  .trust-line { gap: 6px; }
  .trust-badge { font-size: 10.5px; padding: 3px 8px; }
  .trust-disclaimer { font-size: 11px; padding: 0 6px; }

  #composer { padding: 10px 14px 14px; }
  .input-row { padding: 5px 6px 5px 12px; border-radius: 16px; }
  #input { font-size: 14.5px; }
  #send-btn { padding: 8px 12px; }
}

@media (max-width: 480px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 18px; }
  .msg.user { max-width: 85%; }
}
