/* ============================================================
   EB-2 NIW Case Manager — Stylesheet
   frontend/css/styles.css
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600&family=DM+Sans:wght@300;400;500&family=DM+Mono&display=swap');

:root {
  --navy:       #0f1729;
  --navy-light: #1a2744;
  --gold:       #c9a84c;
  --gold-light: #e8c97a;
  --gold-pale:  #fdf4e0;
  --cream:      #fdf9f4;
  --text-primary:   #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted:     #718096;
  --border:         #e6ddd0;
  --white:          #ffffff;
  --sidebar-width:  244px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(201,168,76,0.18);
}
.sidebar-logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 0.3px;
  line-height: 1.4;
}
.sidebar-logo p {
  font-size: 9px;
  color: rgba(255,255,255,0.35);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1.8px;
}

.nav-section {
  padding: 16px 16px 6px;
  font-size: 9px;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin: 1px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  transition: all 0.15s;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  font-family: 'DM Sans', sans-serif;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.85); }
.nav-item.active { background: rgba(201,168,76,0.14); color: var(--gold-light); }
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.65; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.case-badge {
  background: rgba(201,168,76,0.09);
  border: 1px solid rgba(201,168,76,0.18);
  border-radius: 8px;
  padding: 10px 12px;
}
.cb-label { font-size: 9px; color: rgba(255,255,255,0.28); text-transform: uppercase; letter-spacing: 1.5px; }
.cb-value { font-size: 12px; color: var(--gold-light); margin-top: 3px; font-family: 'DM Mono', monospace; }

/* ── Main area ───────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-family: 'Playfair Display', serif; font-size: 19px; color: var(--text-primary); }
.topbar-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.stage-pill {
  background: var(--gold-pale);
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 11px;
  color: #8a6200;
  font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--navy);
  color: var(--gold-light);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--cream); border-color: var(--gold); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Panels ──────────────────────────────────────────────── */
.panel {
  flex: 1;
  overflow-y: auto;
  padding: 26px;
  display: none;
}
.panel.active { display: block; }
.chat-panel { display: none; padding: 0; }
.chat-panel.active { display: flex; flex-direction: column; }

/* ── Chat ────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message { display: flex; gap: 10px; }
.message.user { flex-direction: row-reverse; align-self: flex-end; max-width: 75%; }
.message.ai   { max-width: 85%; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
}
.avatar.ai   { background: var(--navy); color: var(--gold); font-family: 'Playfair Display', serif; }
.avatar.user { background: var(--gold-pale); color: #8a6200; }

.bubble {
  padding: 11px 15px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.65;
}
.bubble.ai   { background: var(--white); border: 1px solid var(--border); color: var(--text-primary); border-radius: 3px 12px 12px 12px; }
.bubble.user { background: var(--navy); color: rgba(255,255,255,0.92); border-radius: 12px 3px 12px 12px; }
.bubble p         { margin-bottom: 7px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h3        { font-family: 'Playfair Display', serif; font-size: 14px; margin: 10px 0 5px; color: var(--navy); }
.bubble.user h3   { color: var(--gold-light); }
.bubble strong    { font-weight: 500; }
.bubble ul, .bubble ol { margin: 6px 0 6px 18px; }
.bubble li        { margin-bottom: 3px; }
.disclaimer { font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 10px; font-style: italic; line-height: 1.5; }
.bubble.user .disclaimer { color: rgba(255,255,255,0.45); border-top-color: rgba(255,255,255,0.15); }

.chat-input-area {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 14px 26px;
  flex-shrink: 0;
}
.quick-actions { display: flex; gap: 7px; margin-bottom: 11px; flex-wrap: wrap; }
.qa-btn {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 5px 13px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}
.qa-btn:hover { background: var(--gold-pale); border-color: rgba(201,168,76,0.4); color: #8a6200; }

.input-row { display: flex; gap: 9px; align-items: flex-end; }
.chat-textarea {
  flex: 1;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--cream);
  resize: none;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  line-height: 1.5;
}
.chat-textarea:focus { border-color: var(--gold); background: var(--white); }

.send-btn {
  width: 42px; height: 42px;
  background: var(--navy);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-btn:hover { background: var(--navy-light); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards & Sections ───────────────────────────────────── */
.section-header { margin-bottom: 22px; }
.section-header h2 { font-family: 'Playfair Display', serif; font-size: 21px; color: var(--navy); margin-bottom: 5px; }
.section-header p  { font-size: 13px; color: var(--text-muted); }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}

/* ── Document Vault ─────────────────────────────────────── */
.vault-wrap { overflow-x: auto; }
.vault-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 700px; }
.vault-table th {
  background: var(--navy);
  color: rgba(255,255,255,0.65);
  padding: 9px 13px;
  text-align: left;
  font-weight: 400;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.vault-table th:first-child { border-radius: 7px 0 0 7px; }
.vault-table th:last-child  { border-radius: 0 7px 7px 0; }
.vault-table td { padding: 9px 13px; border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; }
.vault-table tr:hover td { background: rgba(201,168,76,0.04); }

.doc-id  { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--navy); font-weight: 500; white-space: nowrap; }
.cat-tag { display: inline-block; padding: 2px 7px; border-radius: 9px; font-size: 10px; font-weight: 500; font-family: 'DM Mono', monospace; background: var(--navy); color: var(--gold-light); }

.status-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.s-strong    { background: #d4edda; color: #155724; }
.s-draft     { background: #fff3cd; color: #6d4f00; }
.s-missing   { background: #f8d7da; color: #721c24; }
.s-sent      { background: #d1ecf1; color: #0c5460; }
.s-confirmed { background: #d4edda; color: #155724; }
.s-needs     { background: #fff3cd; color: #6d4f00; }

/* ── Prong bars ─────────────────────────────────────────── */
.prong-track { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.prong-fill  { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--navy) 0%, var(--gold) 100%); transition: width 1s ease; }

/* ── Case Stages ─────────────────────────────────────────── */
.stage-list { display: flex; flex-direction: column; }
.stage-item { display: flex; gap: 14px; padding: 14px 0; position: relative; }
.stage-item:not(:last-child)::after { content:''; position:absolute; left:14px; top:42px; bottom:0; width:2px; background:var(--border); }
.stage-item.done::after { background: var(--navy); }
.stage-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-muted);
  flex-shrink: 0; z-index: 1;
}
.stage-item.done    .stage-dot { background: var(--navy); border-color: var(--navy); color: var(--gold); }
.stage-item.current .stage-dot { background: var(--gold-pale); border-color: var(--gold); color: #8a6200; font-weight: 600; }
.stage-title { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.stage-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── CV Textarea ─────────────────────────────────────────── */
.cv-textarea {
  width: 100%;
  min-height: 200px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--cream);
  resize: vertical;
  outline: none;
  line-height: 1.65;
}
.cv-textarea:focus { border-color: var(--gold); background: var(--white); }

/* ── Letter & Email cards ────────────────────────────────── */
.letter-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.letter-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; cursor: pointer; transition: border-color 0.2s;
}
.letter-card:hover { border-color: var(--gold); }
.lc-type  { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 7px; }
.lc-title { font-family: 'Playfair Display', serif; font-size: 15px; color: var(--navy); margin-bottom: 5px; }
.lc-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.lc-link  { margin-top: 10px; font-size: 12px; color: var(--gold); }

.email-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 13px; margin-bottom: 22px; }
.email-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; cursor: pointer; transition: border-color 0.2s;
}
.email-card:hover { border-color: var(--gold); }
.ec-title { font-size: 13px; font-weight: 500; color: var(--navy); margin: 8px 0 4px; }
.ec-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 14px; opacity: 0.28; }
.empty-state h3  { font-family: 'Playfair Display', serif; font-size: 18px; color: var(--navy); margin-bottom: 7px; }
.empty-state p   { font-size: 13px; }

/* ── Typing indicator ────────────────────────────────────── */
.typing-indicator { display: flex; gap: 4px; padding: 11px 15px; background: var(--white); border: 1px solid var(--border); border-radius: 3px 12px 12px 12px; width: fit-content; }
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: blink 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,60%,100%{opacity:0.3;transform:scale(0.9)} 30%{opacity:1;transform:scale(1.1)} }

/* ── Profile Modal ───────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,41,0.65); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-box { background: var(--white); border-radius: 14px; padding: 26px; width: 420px; max-width: 92vw; }
.modal-title { font-family: 'Playfair Display', serif; font-size: 19px; color: var(--navy); margin-bottom: 18px; }
.field-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 5px; }
.field-input {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none;
  background: var(--cream); color: var(--text-primary);
}
.field-input:focus { border-color: var(--gold); background: var(--white); }
.field-group { margin-bottom: 13px; }

/* ── Status bar ──────────────────────────────────────────── */
#status-bar {
  position: fixed; bottom: 0; left: var(--sidebar-width); right: 0;
  background: var(--navy-light); color: rgba(255,255,255,0.7);
  font-size: 11px; padding: 6px 22px; z-index: 100; display: none;
  font-family: 'DM Mono', monospace;
}

/* ── Memory tags ─────────────────────────────────────────── */
.mem-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 9px;
  font-family: 'DM Mono', monospace;
  background: var(--cream);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Folder tree ─────────────────────────────────────────── */
.folder-item {
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.folder-item:hover { background: var(--gold-pale); }
.folder-item.active { background: var(--gold-pale); color: var(--navy); font-weight: 500; }

/* ── File cards ──────────────────────────────────────────── */
.file-card { transition: box-shadow 0.15s; }
.file-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-family: 'Playfair Display', serif; color: var(--navy); margin-bottom: 8px; font-size: 16px; }
.empty-state p { font-size: 13px; max-width: 400px; margin: 0 auto; line-height: 1.6; }

/* ── Progress bar ────────────────────────────────────────── */
.progress-bar { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #c9a84c88; }
