/* frontend/css/style.css */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --border: #334155;
  --error: #f87171;
  --ok: #34d399;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
}
.hidden { display: none !important; }
.accent { color: var(--accent); }

/* ===== 로그인 ===== */
.login-wrap {
  display: flex; align-items: center; justify-content: center; height: 100vh;
}
.login-card {
  background: var(--panel); padding: 40px; border-radius: 16px;
  width: 360px; border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-card h1 { margin: 0; font-size: 32px; }
.subtitle { color: var(--muted); margin: 6px 0 24px; font-size: 14px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 15px;
}
.login-card button[type=submit], .chat-input button, #login-form button {
  width: 100%; padding: 12px; border: none; border-radius: 8px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06283d; font-weight: 700; font-size: 15px;
}
.error { color: var(--error); font-size: 13px; margin: 8px 0 0; }
.demo-accounts { margin-top: 22px; font-size: 12px; color: var(--muted); }
.demo-accounts span { display: block; margin-bottom: 8px; }
.demo-accounts code { color: var(--accent-2); }
.chip {
  display: inline-block; margin: 3px 4px 0 0; padding: 6px 10px; font-size: 12px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 20px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }

/* ===== 앱 ===== */
.app-wrap { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-size: 20px; font-weight: 700; }
.user-box { display: flex; align-items: center; gap: 12px; }
.badge {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--accent-2);
  padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.ghost {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.ghost:hover { color: var(--text); }

.chat-main { flex: 1; display: flex; flex-direction: column; max-width: 920px; width: 100%; margin: 0 auto; padding: 16px; overflow: hidden; }
.messages { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 16px; }

/* 메시지 버블 */
.msg { max-width: 90%; padding: 14px 16px; border-radius: 14px; line-height: 1.6; }
.msg.user { align-self: flex-end; background: var(--accent); color: #06283d; font-weight: 600; }
.msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); width: 100%; max-width: 100%; }
.msg.bot.error { border-color: var(--error); }

.bot-summary { white-space: pre-wrap; }
.meta-line { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.meta-line .tag {
  display: inline-block; background: var(--panel-2); padding: 2px 8px; border-radius: 10px;
  margin-right: 6px; border: 1px solid var(--border);
}
.chart-box { margin-top: 14px; background: var(--panel-2); border-radius: 10px; padding: 12px; }

/* 출처 패널 */
.sources { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 10px; }
.sources h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.source-item { font-size: 12px; padding: 7px 10px; margin-bottom: 6px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); }
.source-item .stype { font-weight: 700; margin-right: 6px; }
.source-item .stype.sql { color: var(--accent); }
.source-item .stype.doc { color: var(--ok); }
.source-item code { color: var(--accent-2); word-break: break-all; }

.typing { color: var(--muted); font-style: italic; }

/* 대화 맥락 패널 (2층 메모리) */
.ctx-panel { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; font-size: 12px; }
.ctx-line { color: var(--muted); margin-bottom: 6px; }
.ctx-rewritten { color: var(--muted); font-style: italic; margin-bottom: 8px; word-break: break-all; }
.ctx-board-title { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-right: 8px; }
.ctx-board { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ctx-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px;
  border: 1px solid var(--border); background: var(--panel-2);
}
.ctx-chip.used { color: var(--accent-2); border-color: var(--accent); }
.ctx-chip.board { color: var(--text); }
.ctx-del {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 11px; line-height: 1; padding: 0;
}
.ctx-del:hover { color: var(--accent); }

/* 제안/입력 */
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 8px; }
.suggest {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; border-radius: 20px; font-size: 13px; cursor: pointer;
}
.suggest:hover { border-color: var(--accent); }
.chat-input { display: flex; gap: 10px; padding: 12px 8px 4px; }
.chat-input input {
  flex: 1; padding: 13px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 15px;
}
.chat-input button { width: auto; padding: 0 24px; }

/* ===== 상단바 소개 링크 ===== */
.brand-box { display: flex; align-items: baseline; gap: 14px; }
.back-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--accent); }

/* ===== 의견 보내기 모달 ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2, 6, 23, .7);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px 28px; width: 440px; max-width: calc(100vw - 32px);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-card h3 { margin: 0 0 4px; font-size: 18px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.modal-card select, .modal-card input, .modal-card textarea {
  width: 100%; padding: 11px 13px; margin-bottom: 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font-size: 14px; font-family: inherit; resize: vertical;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.modal-actions button[type=submit] {
  width: auto; padding: 9px 22px; border: none; border-radius: 8px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06283d; font-weight: 700; font-size: 14px;
}
.fb-result { font-size: 13px; color: var(--ok); margin: 12px 0 0; }
