/* ══════════════════════════════════════════════════════
   Careers Lift — Web App Styles
   Design: white bg, indigo #6366F1, full-screen app shell
══════════════════════════════════════════════════════ */

:root {
  --indigo:      #6366F1;
  --indigo-dark: #4F46E5;
  --indigo-light:#EEF2FF;
  --indigo-mid:  #C7D2FE;
  --green:       #10B981;
  --red:         #EF4444;
  --text:        #1E293B;
  --text-2:      #475569;
  --text-3:      #94A3B8;
  --border:      #E2E8F0;
  --bg:          #F8FAFC;
  --white:       #FFFFFF;
  --sidebar-w:   248px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.05);
  --radius:      12px;
  --radius-sm:   8px;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── AUTH OVERLAY ─────────────────────────────────── */

.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  padding: 16px;
}

.auth-modal {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 36px 40px 32px;
  width: 100%;
  max-width: 420px;
  animation: fadeUp .25s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.auth-brand-name { font-size: 20px; font-weight: 700; color: var(--text); }
.auth-brand-tag  { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 7px 0;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .18s;
}
.auth-tab.active {
  background: var(--white);
  color: var(--indigo);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .02em; text-transform: uppercase; }
.field input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.form-error {
  font-size: 13px;
  color: var(--red);
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--indigo);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}
.btn-primary:hover  { background: var(--indigo-dark); box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.btn-primary:active { transform: scale(.98); }
.w-full { width: 100%; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-footer-note { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 20px; }

/* ── APP SHELL ────────────────────────────────────── */

.app {
  display: flex;
  height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-name { font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar-tag  { font-size: 11px; color: var(--text-3); }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.snav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.snav-item:hover { background: var(--bg); color: var(--text); }
.snav-item.active {
  background: var(--indigo-light);
  color: var(--indigo);
  font-weight: 600;
}
.snav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.usage-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.usage-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.usage-bar-wrap { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 5px; }
.usage-bar { height: 100%; background: var(--indigo); border-radius: 99px; transition: width .4s ease; width: 0%; }
.usage-numbers { font-size: 11px; color: var(--text-3); }

.user-row { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 30px; height: 30px;
  background: var(--indigo-light);
  color: var(--indigo);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.user-email { flex: 1; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: color .15s, background .15s;
}
.logout-btn:hover { color: var(--red); background: #FEF2F2; }

/* ── MAIN CONTENT ─────────────────────────────────── */

.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.view { display: none; flex: 1; flex-direction: column; }
.view.active { display: flex; }

.view-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.view-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.view-sub   { font-size: 13.5px; color: var(--text-2); }

/* ── GENERATE LAYOUT ─────────────────────────────── */

.generate-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 0 32px 32px;
  flex: 1;
  min-height: 0;
}

.inputs-col { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.result-col { display: flex; flex-direction: column; overflow: hidden; }

.input-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.step-badge {
  width: 26px; height: 26px;
  background: var(--indigo);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.card-hint  { font-size: 12px; color: var(--text-3); }

.textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.6;
}
.textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
  background: var(--white);
}

.char-count { font-size: 11px; color: var(--text-3); text-align: right; margin-top: 4px; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 16px;
  text-align: center;
  background: var(--bg);
  transition: border-color .15s, background .15s;
  cursor: pointer;
  margin-bottom: 10px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--indigo);
  background: var(--indigo-light);
}
.upload-zone p { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.upload-hint { font-size: 11px !important; color: var(--text-3) !important; margin-top: 3px !important; }
#upload-done { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 13px; color: var(--text-2); }

.or-divider { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.or-divider span { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.link { background: none; border: none; color: var(--indigo); font-size: inherit; cursor: pointer; text-decoration: underline; padding: 0; font-family: inherit; }
.link:hover { color: var(--indigo-dark); }
.link.danger { color: var(--red); }

.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--indigo);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 3px 10px rgba(99,102,241,.3);
  width: 100%;
}
.btn-generate:hover  { background: var(--indigo-dark); box-shadow: 0 5px 16px rgba(99,102,241,.4); }
.btn-generate:active { transform: scale(.99); }
.btn-generate:disabled { opacity: .65; cursor: not-allowed; transform: none; }

.gen-note { font-size: 11.5px; color: var(--text-3); text-align: center; margin-top: 6px; }

/* Dot pulse loader */
.dot-pulse { display: flex; align-items: center; gap: 5px; }
.dot-pulse span {
  width: 6px; height: 6px;
  background: white; border-radius: 50%;
  animation: pulse .8s ease-in-out infinite;
}
.dot-pulse span:nth-child(2) { animation-delay: .15s; }
.dot-pulse span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%,80%,100% { transform: scale(.7); opacity:.5; } 40% { transform: scale(1); opacity:1; } }

/* Result panel */
.result-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 14px;
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 200px;
}
.empty-sub { font-size: 12px; color: var(--text-3); }

.result-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadeUp .3s ease;
}

.result-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 12px;
  flex-wrap: wrap;
}
.result-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--green);
}
.result-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.model-used {
  font-size: 11px;
  color: var(--text-3);
  background: var(--border);
  border-radius: 99px;
  padding: 2px 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover { background: var(--bg); border-color: var(--indigo); color: var(--indigo); }

.result-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--white);
}

/* ── HISTORY VIEW ────────────────────────────────── */

#history-container { padding: 0 32px 32px; flex: 1; }

.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 260px;
  color: var(--text-3);
  font-size: 14px;
}
.empty-state .empty-sub { font-size: 12px; color: var(--text-3); }

.loader-ring {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.history-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.history-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--indigo-mid);
  transform: translateY(-2px);
}
.hcard-date  { font-size: 11px; color: var(--text-3); margin-bottom: 7px; }
.hcard-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; line-height: 1.4; }
.hcard-preview {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}
.hcard-footer { display: flex; align-items: center; justify-content: space-between; }
.hcard-tokens { font-size: 11px; color: var(--text-3); }
.hcard-view {
  font-size: 12px;
  color: var(--indigo);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── HISTORY MODAL ───────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 740px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: fadeUp .2s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  gap: 12px;
  flex-wrap: wrap;
}
.modal-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-actions { display: flex; align-items: center; gap: 6px; }
.close-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.close-btn:hover { background: #FEF2F2; color: var(--red); border-color: #FECACA; }
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── RESPONSIVE ──────────────────────────────────── */

@media (max-width: 900px) {
  :root { --sidebar-w: 56px; }
  .sidebar-brand .sidebar-name,
  .sidebar-brand .sidebar-tag,
  .snav-item span,
  .sidebar-footer .usage-card,
  .user-email { display: none; }
  .sidebar-brand { justify-content: center; padding: 14px 0; }
  .snav-item { justify-content: center; padding: 10px 0; }
  .sidebar-footer { align-items: center; }
  .user-row { justify-content: center; }
  .user-avatar { margin: 0; }
  .logout-btn { display: none; }
}

@media (max-width: 700px) {
  .generate-layout { grid-template-columns: 1fr; overflow-y: auto; }
  .view-header { padding: 20px 16px 0; }
  .generate-layout { padding: 0 16px 24px; }
  #history-container { padding: 0 16px 24px; }
  .auth-modal { padding: 28px 24px 24px; }
}

/* ── TOAST ────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: white;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
