@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --sidebar-bg: #1e1e1e;
  --sidebar-hover: #2a2a2a;
  --sidebar-active: #333;
  --sidebar-text: #ccc;
  --sidebar-text-dim: #888;
  --sidebar-border: #333;
  --main-bg: #fff;
  --bg-input: #f4f4f5;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-muted: #999;
  --accent: #10a37f;
  --accent-hover: #0d8a6a;
  --user-bubble: #f4f4f5;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--main-bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ===== 로그인 ===== */
.screen { height: 100vh; display: flex; align-items: center; justify-content: center; background: #fafafa; }

.login-box {
  max-width: 440px;
  width: 100%;
  padding: 40px;
  text-align: center;
}

.login-logo { width: 400px; margin-bottom: 32px; max-width: 100%; margin-left: auto; margin-right: auto; display: block; }
.main-logo { width: 200px; margin-bottom: 16px; }
.login-box h1 { font-size: 32px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.login-box p { color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }

.login-box input {
  width: 100%;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.login-box input:focus { border-color: var(--accent); }
.login-box input::placeholder { color: var(--text-muted); }
.sub-text { font-size: 13px; color: var(--text-muted); margin-top: 16px; }
.sub-text a { color: var(--accent); text-decoration: none; font-weight: 600; }
.error-text { color: #ef4444; font-size: 13px; margin-top: 8px; }

.btn { padding: 12px 20px; border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.btn-primary { background: var(--accent); color: #fff; width: 100%; padding: 14px; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: var(--bg-input); color: var(--text-muted); cursor: not-allowed; }

/* ===== 앱 레이아웃 ===== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ===== 사이드바 ===== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s;
}

.sidebar.hidden {
  margin-left: -260px;
}

.sidebar-header {
  padding: 12px;
}

.sidebar-new-chat {
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.sidebar-new-chat:hover { background: var(--sidebar-hover); }

.sidebar-search {
  padding: 0 12px 8px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--sidebar-hover);
  border: none;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13px;
  outline: none;
}

.sidebar-search input::placeholder { color: var(--sidebar-text-dim); }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 13px;
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item:hover { background: var(--sidebar-hover); }
.sidebar-item.active { background: var(--sidebar-active); color: #fff; }

.sidebar-item-icon { font-size: 14px; flex-shrink: 0; }
.sidebar-item-name { overflow: hidden; text-overflow: ellipsis; }

/* 임베딩 상태 */
.embedding-status {
  margin: 8px 12px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 8px;
  padding: 10px;
}

.embedding-status.done { background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.2); }
.embedding-label { font-size: 11px; font-weight: 600; color: #fbbf24; margin-bottom: 6px; }
.embedding-status.done .embedding-label { color: var(--accent); }
.embedding-bar { width: 100%; height: 3px; background: var(--sidebar-border); border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.embedding-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.5s; width: 0%; }
.embedding-text { font-size: 10px; color: var(--sidebar-text-dim); }

/* 사이드바 하단 */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  font-size: 13px;
}

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

.sidebar-logout {
  background: none;
  border: none;
  color: var(--sidebar-text-dim);
  font-size: 12px;
  cursor: pointer;
}

.sidebar-logout:hover { color: var(--sidebar-text); }

/* ===== 메인 콘텐츠 ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--main-bg);
}

.main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.current-chat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ===== 빈 상태 ===== */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.empty-state h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 600px;
}

.quick-btn {
  padding: 10px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.quick-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(16, 163, 127, 0.04); }

/* ===== 채팅 메시지 ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}

.chat-msg {
  max-width: 720px;
  margin: 0 auto 24px;
  padding: 0 24px;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  background: var(--user-bubble);
  max-width: 720px;
  margin: 0 auto 24px;
  padding: 16px 24px;
  border-radius: 18px;
  color: var(--text);
}

.chat-msg.assistant {
  color: var(--text);
}

.chat-msg .sources {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== 입력 ===== */
.chat-input-area {
  padding: 16px 24px 24px;
  background: var(--main-bg);
}

.chat-input-wrap {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 4px 4px 18px;
  transition: border-color 0.2s;
}

.chat-input-wrap:focus-within { border-color: var(--accent); }

.chat-input-wrap input {
  flex: 1;
  padding: 12px 0;
  background: transparent;
  border: none;
  font-size: 15px;
  color: var(--text);
  outline: none;
}

.chat-input-wrap input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 36px;
  height: 36px;
  background: var(--text);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.chat-send-btn:hover { background: #333; }

/* ===== 주간 요약 날짜 선택 ===== */
.summary-picker {
  max-width: 500px;
  margin-top: 16px;
}

.summary-picker-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.week-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.week-btn {
  padding: 10px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.week-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(16, 163, 127, 0.04);
}

.summary-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.summary-custom input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.summary-custom span {
  color: var(--text-muted);
  font-size: 13px;
}

.summary-go {
  width: auto !important;
  padding: 8px 16px !important;
  font-size: 13px !important;
}

/* ===== 로딩 ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 스크롤바 ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.15); }

.sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
.sidebar ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== 반응형 ===== */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 100; height: 100vh; }
  .sidebar.hidden { margin-left: -260px; }
  .chat-msg, .chat-msg.user { padding: 12px 16px; }
  .chat-input-area { padding: 12px 16px 16px; }
}
