/* ==========================================================================
   CareerJoy Resume Platform — brand theme
   Navy #1B4F8A · Orange-red #E8441A · White #FFFFFF · Inter
   Clean, human, corporate professional. No dark mode. No gradients.
   ========================================================================== */

:root {
  --navy:       #1B4F8A;
  --navy-dark:  #163f6e;   /* darker navy for depth / active */
  --orange:     #E8441A;
  --orange-dk:  #cf3a14;   /* orange hover depth */
  --white:      #ffffff;

  --grey-bg:    #f4f6f9;   /* app canvas */
  --grey-user:  #eef1f5;   /* contractor chat bubble */
  --grey-line:  #e3e8ef;   /* borders */
  --grey-soft:  #f7f9fb;   /* subtle fills */
  --text:       #1f2a37;   /* primary body text */
  --text-mut:   #64748b;   /* muted text */

  --radius:     10px;
  --shadow-sm:  0 1px 2px rgba(27, 79, 138, 0.06);
  --shadow-md:  0 8px 24px rgba(22, 63, 110, 0.12);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--grey-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ============================ SIDEBAR ============================ */
.sidebar {
  background: var(--white);
  color: var(--navy);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--grey-line);
  min-height: 0;
}

.sidebar__brand {
  padding: 24px 22px 18px;
  border-bottom: 1px solid var(--grey-line);
}
.sidebar__logo { width: 172px; height: auto; display: block; }
.sidebar__tagline {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-mut);
  text-transform: uppercase;
}

.sidebar__search { padding: 16px 18px 8px; }
.sidebar__search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--grey-line);
  background: var(--white);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.sidebar__search input::placeholder { color: var(--text-mut); }
.sidebar__search input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 79, 138, 0.1);
}

.sidebar__add { margin: 10px 18px 14px; width: calc(100% - 36px); }

.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 16px;
  min-height: 0;
}

.client-group { margin-top: 14px; }
.client-group__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-mut);
  padding: 6px 10px;
}

.client-list { list-style: none; }

.client-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.client-item:hover { background: var(--grey-soft); }
.client-item.active {
  background: rgba(27, 79, 138, 0.07);
  border-left-color: var(--orange);
  color: var(--navy);
}
.client-item.active .client-item__name { font-weight: 600; }

.client-item__left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-item__name {
  font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--progress { background: var(--orange); }
.dot--completed { background: var(--navy); }

.empty-list { color: var(--text-mut); font-size: 13px; padding: 8px 12px; }

.sidebar__footer {
  padding: 14px 22px;
  border-top: 1px solid var(--grey-line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--navy);
  text-transform: uppercase;
}

/* ============================ MAIN ============================ */
.main { background: var(--grey-bg); min-height: 0; overflow: hidden; }

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-mut);
  padding: 40px;
}
.empty-state__logo { width: 260px; height: auto; margin-bottom: 26px; opacity: 0.95; }
.empty-state h2 { color: var(--navy); margin-bottom: 10px; font-size: 22px; font-weight: 700; }
.empty-state p { max-width: 440px; line-height: 1.65; font-size: 15px; }

.workspace {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.workspace__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  background: var(--white);
  border-bottom: 1px solid var(--grey-line);
}
.workspace__name { font-size: 20px; font-weight: 700; color: var(--navy); }
.workspace__files { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }

.file-chip {
  font-size: 12px;
  color: var(--navy);
  background: var(--grey-soft);
  border: 1px solid var(--grey-line);
  padding: 4px 10px;
  border-radius: 20px;
}

.workspace__actions { display: flex; align-items: center; gap: 14px; flex: none; }

.badge {
  font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid transparent;
}
.badge--progress { background: rgba(232, 68, 26, 0.1); color: var(--orange-dk); border-color: rgba(232, 68, 26, 0.25); }
.badge--completed { background: rgba(27, 79, 138, 0.1); color: var(--navy); border-color: rgba(27, 79, 138, 0.22); }

/* Downloads */
.downloads {
  padding: 16px 28px;
  background: var(--white);
  border-bottom: 1px solid var(--grey-line);
}
.downloads__title { font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 12px; }
.download-list { display: flex; flex-wrap: wrap; gap: 10px; }
.download-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--navy);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.download-item:hover { border-color: var(--orange); color: var(--orange-dk); background: var(--grey-soft); }
.download-item .fmt {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
  background: var(--navy); color: var(--white);
}

/* Chat */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.msg { display: flex; max-width: 76%; }
.msg--user { align-self: flex-end; }
.msg--model { align-self: flex-start; }

.msg__bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}
/* Contractor (user) — light grey */
.msg--user .msg__bubble {
  background: var(--grey-user);
  color: var(--text);
  border: 1px solid var(--grey-line);
  border-bottom-right-radius: 3px;
}
/* CareerJoy AI (Gemini) — white with navy left border */
.msg--model .msg__bubble {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--grey-line);
  border-left: 4px solid var(--navy);
  border-bottom-left-radius: 3px;
  box-shadow: var(--shadow-sm);
}

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--navy);
  opacity: 0.35;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* Chat form */
.chat-form {
  display: flex;
  gap: 12px;
  padding: 16px 28px 22px;
  background: var(--white);
  border-top: 1px solid var(--grey-line);
}
.chat-form__input {
  flex: 1;
  resize: none;
  padding: 12px 16px;
  border: 1px solid var(--grey-line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  max-height: 160px;
}
.chat-form__input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 79, 138, 0.1);
}

/* ============================ BUTTONS ============================ */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Primary: navy -> orange on hover */
.btn--primary { background: var(--navy); color: var(--white); }
.btn--primary:hover:not(:disabled) { background: var(--orange); }

/* Ghost: outlined navy */
.btn--ghost { background: var(--white); color: var(--navy); border: 1px solid var(--grey-line); }
.btn--ghost:hover { border-color: var(--navy); background: var(--grey-soft); }
/* Send to Client — always CareerJoy navy (#1B4F8A), stays navy on hover. */
.btn--hubspot { background: var(--navy); color: var(--white); }
.btn--hubspot:hover:not(:disabled) { background: var(--navy-dark); }

/* ============================ MODAL ============================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(22, 63, 110, 0.45);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  width: 100%; max-width: 460px;
  background: var(--white);
  border-radius: 14px;
  border-top: 4px solid var(--orange);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--grey-line);
}
.modal__header h3 { color: var(--navy); font-size: 17px; }
.modal__close {
  border: none; background: none; font-size: 26px; line-height: 1;
  cursor: pointer; color: var(--text-mut);
}
.modal__close:hover { color: var(--orange); }
.modal__form { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--navy); }
.field__hint { font-size: 12px; color: var(--text-mut); }
.field input[type="text"] {
  padding: 10px 12px; border: 1px solid var(--grey-line);
  border-radius: var(--radius); font-size: 14px; font-family: inherit;
}
.field input[type="text"]:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 79, 138, 0.1);
}
.field input[type="file"] { font-size: 13px; color: var(--text-mut); }
.modal__footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ============================ TOAST ============================ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--white);
  padding: 12px 20px; border-radius: var(--radius); font-size: 14px;
  box-shadow: var(--shadow-md); z-index: 200;
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast--error { background: var(--orange); }

/* ===================== SIDEBAR COMPLETED BUTTON ===================== */
.sidebar__completed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 16px 8px;
  padding: 12px 14px;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--navy);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.sidebar__completed:hover { background: var(--grey-soft); border-color: var(--navy); }
.sidebar__completed.active { background: rgba(27, 79, 138, 0.08); border-color: var(--navy); }
.count-badge {
  min-width: 22px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--navy);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* ===================== WORKSPACE TIMESTAMPS ===================== */
.workspace__timestamps {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-mut);
}
.workspace__timestamps .ts-label { font-weight: 600; color: var(--navy); }

/* ===================== COMPLETED PAGE ===================== */
.completed-page {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 24px 28px;
  overflow-y: auto;
}
.completed-page__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.completed-page__title { font-size: 22px; font-weight: 700; color: var(--navy); }
.completed-page__summary { margin-top: 4px; font-size: 13px; color: var(--text-mut); }
.completed-page__header input {
  width: 300px; max-width: 45vw;
  padding: 10px 14px;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
}
.completed-page__header input:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 79, 138, 0.1);
}

.completed-table {
  background: var(--white);
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.completed-table__head,
.completed-row {
  display: grid;
  grid-template-columns: 2fr 1.3fr 1.3fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
}
.completed-table__head {
  background: var(--grey-soft);
  border-bottom: 1px solid var(--grey-line);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mut);
}
.completed-row {
  border-bottom: 1px solid var(--grey-line);
  cursor: pointer;
  transition: background 0.15s;
}
.completed-row:last-child { border-bottom: none; }
.completed-row:hover { background: var(--grey-soft); }
.completed-row__name { font-size: 14px; font-weight: 600; color: var(--navy); }
.completed-row__date { font-size: 13px; color: var(--text); }
.completed-row__open {
  font-size: 12px; font-weight: 600; color: var(--navy);
  border: 1px solid var(--grey-line); border-radius: 8px;
  padding: 6px 12px; background: var(--white);
}
.completed-row:hover .completed-row__open { border-color: var(--orange); color: var(--orange-dk); }
.completed-empty { padding: 30px 18px; text-align: center; color: var(--text-mut); font-size: 14px; }

/* ============================ ADMIN ============================ */
.sidebar__admin {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 16px 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: #fef2f2;
  border: 1px solid #fecaca;
}
.admin-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: #b91c1c; }
.admin-exit {
  border: none; background: none; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #b91c1c; text-decoration: underline;
  font-family: inherit;
}

/* Delete buttons (only rendered in admin mode) */
.del-btn {
  flex: none;
  border: none;
  background: transparent;
  color: #b91c1c;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: inherit;
}
.del-btn:hover { background: #fee2e2; }

/* The delete button only renders in admin mode, so show it on every client
   (a clear red control), not just on hover. */
.client-item .del-btn { opacity: 1; }

.msg { position: relative; align-items: center; gap: 6px; }
.msg .del-btn { opacity: 0; align-self: flex-start; }
.msg:hover .del-btn { opacity: 1; }
.completed-row__del { color: #b91c1c; }

/* ============================ RESPONSIVE ============================ */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 290px; z-index: 50;
             transform: translateX(-100%); transition: transform 0.25s;
             box-shadow: var(--shadow-md); }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .msg { max-width: 90%; }
}
