/* ─── CSS VARIABLES ──────────────────────────────────────────────────────── */
:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f1f3f4;
  --surface: #ffffff;
  --surface-hover: #f1f3f4;
  --border: #e0e0e0;
  --border-light: #f1f3f4;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-tertiary: #9aa0a6;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-light: #e8f0fe;
  --accent-text: #1a73e8;
  --user-bubble: #e8f0fe;
  --user-bubble-text: #1a73e8;
  --ai-bubble: #f8f9fa;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 24px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --bg: #1f1f1f;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3c3c3c;
  --surface: #2d2d2d;
  --surface-hover: #3c3c3c;
  --border: #3c3c3c;
  --border-light: #2d2d2d;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-tertiary: #5f6368;
  --accent: #8ab4f8;
  --accent-hover: #aecbfa;
  --accent-light: #1e3a5f;
  --accent-text: #8ab4f8;
  --user-bubble: #1e3a5f;
  --user-bubble-text: #8ab4f8;
  --ai-bubble: #2d2d2d;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.4);
}

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

body {
  font-family: 'Roboto', 'Google Sans Text', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
  overflow: hidden;
}

/* ─── TOP NAV ────────────────────────────────────────────────────────────── */
.topnav {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  gap: 12px;
  position: relative;
  z-index: 10;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a73e8, #34a853);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Google Sans', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.nav-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.nav-name {
  font-family: 'Google Sans', sans-serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
}

.nav-name span { color: var(--accent); }

.nav-spacer { flex: 1; }

.nav-chip {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: 20px;
  font-family: 'Google Sans Text', sans-serif;
}

.theme-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.theme-btn:hover { background: var(--surface-hover); }

/* ─── MAIN LAYOUT ────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
}

/* ─── MESSAGES ───────────────────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.messages.is-empty {
  justify-content: center;
  align-items: center;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 24px;
  animation: fadeUp 0.5s ease;
}

.empty-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a73e8, #34a853);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Google Sans', sans-serif;
  font-weight: 600;
  font-size: 24px;
  color: white;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  flex-shrink: 0;
}

.empty-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.empty-title {
  font-family: 'Google Sans', sans-serif;
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-sub {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.6;
  margin-bottom: 32px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 560px;
}

.suggest-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Google Sans Text', sans-serif;
  box-shadow: var(--shadow-sm);
}
.suggest-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-md);
}

/* ─── MESSAGE ROWS ───────────────────────────────────────────────────────── */
.msg-row {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  animation: fadeUp 0.25s ease;
}

.msg-row.user { flex-direction: row-reverse; }

.msg-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Google Sans', sans-serif;
  margin-top: 4px;
  overflow: hidden;
}

.msg-icon.ai {
  background: linear-gradient(135deg, #1a73e8, #34a853);
  color: white;
}

.msg-icon.ai img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.msg-icon.user-icon {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.msg-bubble {
  max-width: 76%;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  border-radius: 20px;
}

.msg-bubble.ai {
  background: var(--ai-bubble);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-top-left-radius: 4px;
}

.msg-bubble.user {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-top-right-radius: 4px;
  font-weight: 500;
}

.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin: 6px 0; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble strong { font-weight: 500; color: var(--text-primary); }

/* ─── TYPING DOTS ────────────────────────────────────────────────────────── */
.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 4px 2px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: bounce 1.2s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

/* ─── INPUT AREA ─────────────────────────────────────────────────────────── */
.input-area {
  padding: 16px 0 20px;
  flex-shrink: 0;
}

.input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 10px 10px 10px 20px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-md);
}

.input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 15px;
  color: var(--text-primary);
  font-family: 'Roboto', sans-serif;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
  padding: 4px 0;
}

.input-box textarea::placeholder { color: var(--text-tertiary); }

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.send-btn:disabled {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: default;
}

.send-btn:not(:disabled):hover {
  background: var(--accent-hover);
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.input-footer {
  text-align: center;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'Google Sans Text', sans-serif;
}

.input-footer a {
  color: var(--accent-text);
  text-decoration: none;
}

/* ─── ANIMATIONS ─────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav-chip { display: none; }
  .msg-bubble { max-width: 88%; font-size: 13px; }
  .empty-title { font-size: 20px; }
}

/* ─── RESUME BUTTON (NAV) ────────────────────────────────────────────────────── */
.resume-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-text);
  font-size: 13px;
  font-family: 'Google Sans Text', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.resume-btn:hover {
  background: var(--accent-light);
}

/* ─── PDF MODAL ──────────────────────────────────────────────────────────────── */
.pdf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.pdf-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.pdf-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 860px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.2s ease;
}
.pdf-overlay.open .pdf-modal {
  transform: translateY(0) scale(1);
}

.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.pdf-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Google Sans Text', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.pdf-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-download-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent-text);
  font-size: 12px;
  font-family: 'Google Sans Text', sans-serif;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
}
.pdf-download-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.pdf-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.pdf-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.pdf-modal-body {
  flex: 1;
  overflow: hidden;
}

.pdf-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

@media (max-width: 600px) {
  .pdf-overlay { padding: 0; }
  .pdf-modal { border-radius: 0; height: 100dvh; max-width: 100%; }
  .resume-btn span { display: none; }
}
