/* ============================================================
   MetierKit — App-wide styles (dashboard, questionnaire, brief)
   Inherits design tokens from theme.css
   ============================================================ */

/* ---- NAV -------------------------------------------------- */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg-primary);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  font-size: 0.9rem;
  color: var(--fg-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.nav-link:hover { color: var(--fg-primary); }

.nav-cta {
  padding: 8px 18px;
  background: var(--accent);
  color: #0a0a0f;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.15s;
}
.nav-cta:hover { opacity: 0.85; }

/* ---- APP MAIN ------------------------------------------- */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 32px;
}

/* ---- BUTTONS ------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity 0.15s, background 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #0a0a0f;
}
.btn-primary:hover { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--fg-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.15); color: var(--fg-primary); }

.btn-large {
  padding: 14px 32px;
  font-size: 1rem;
}

.btn-block { width: 100%; justify-content: center; }

/* ---- PAGE HEADER --------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--fg-secondary);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- STATS ROW ---------------------------------------- */
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card-number {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card-label {
  font-size: 0.82rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- TABLE -------------------------------------------- */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  background: var(--bg-secondary);
  padding: 14px 20px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-primary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.cell-name { font-weight: 500; }
.cell-email { color: var(--fg-secondary); font-size: 0.87rem; }
.cell-date { color: var(--fg-muted); font-size: 0.87rem; }
.cell-actions { display: flex; gap: 12px; align-items: center; }

.action-link {
  font-size: 0.85rem;
  color: var(--fg-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.action-link:hover { color: var(--fg-primary); }
.action-link.accent { color: var(--accent); font-weight: 600; }
.action-link.accent:hover { opacity: 0.8; }

.muted { color: var(--fg-muted); }

/* ---- BADGES ------------------------------------------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.badge-done { background: rgba(80, 200, 120, 0.12); color: #50c878; }
.badge-pending { background: rgba(212, 168, 83, 0.12); color: var(--accent); }
.badge-error { background: rgba(220, 80, 80, 0.12); color: #dc5050; }
.badge-none { background: var(--bg-secondary); color: var(--fg-muted); }

/* ---- EMPTY STATE --------------------------------------- */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--fg-secondary);
}

.empty-icon { font-size: 3rem; margin-bottom: 24px; }
.empty-state h2 { font-family: var(--font-display); margin-bottom: 12px; color: var(--fg-primary); }
.empty-state p { margin-bottom: 28px; max-width: 360px; margin-left: auto; margin-right: auto; }

/* ---- QUESTIONNAIRE ------------------------------------ */
.questionnaire-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.questionnaire-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 56px;
}

.q-brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.q-progress {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.q-intro {
  margin-bottom: 48px;
}

.q-intro h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.q-intro p {
  color: var(--fg-secondary);
  font-size: 1rem;
  line-height: 1.7;
}

.q-section {
  margin-bottom: 48px;
}

.q-section-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}

.form-group { margin-bottom: 20px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--fg-secondary);
  margin-bottom: 8px;
}

.required { color: var(--accent); }

.form-input, .form-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--fg-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.15s;
  outline: none;
  -webkit-appearance: none;
}

.form-input:focus, .form-textarea:focus {
  border-color: rgba(212, 168, 83, 0.4);
}

.form-textarea { resize: vertical; }

select.form-input option {
  background: var(--bg-secondary);
  color: var(--fg-primary);
}

.q-submit {
  text-align: center;
  padding-top: 16px;
}

.submit-note {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.already-submitted {
  text-align: center;
  padding: 80px 24px;
}

.check-icon {
  width: 64px;
  height: 64px;
  background: rgba(80, 200, 120, 0.15);
  color: #50c878;
  font-size: 1.8rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

.already-submitted h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 12px;
}

/* ---- THANK YOU ---------------------------------------- */
.thankyou-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 80px 24px;
  text-align: center;
}

.thankyou-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 56px 40px;
}

.ty-icon {
  width: 72px;
  height: 72px;
  background: rgba(212, 168, 83, 0.12);
  color: var(--accent);
  font-size: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 28px;
}

.ty-icon-spin { animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ty-icon-error { background: rgba(220,80,80,0.12); color: #dc5050; }

.thankyou-card h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.thankyou-card p {
  color: var(--fg-secondary);
  line-height: 1.7;
  margin-bottom: 28px;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 24px 0 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  width: 5%;
  transition: width 1s ease;
}

.status-detail {
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin-top: 0;
  margin-bottom: 0 !important;
}

/* ---- BRIEF -------------------------------------------- */
.brief-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.brief-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 12px;
}

.back-link {
  font-size: 0.88rem;
  color: var(--fg-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--fg-primary); }

.brief-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.brief-header {
  margin-bottom: 32px;
}

.brief-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brief-badge {
  padding: 5px 14px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
}

.brief-client {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg-primary);
}

.brief-date {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.brief-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  line-height: 1.8;
}

.brief-body {
  color: var(--fg-primary);
  font-size: 0.97rem;
}

.brief-body h1, .brief-body h2, .brief-body h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--fg-primary);
}

.brief-body h1 { font-size: 1.4rem; }
.brief-body h2 { font-size: 1.1rem; color: var(--accent); }
.brief-body h3 { font-size: 1rem; }

.brief-body strong { color: var(--fg-primary); font-weight: 600; }

.brief-body li {
  margin-left: 24px;
  margin-bottom: 6px;
  list-style: disc;
}

.brief-pending, .brief-error {
  text-align: center;
  padding: 48px;
  color: var(--fg-secondary);
}

.brief-answers {
  margin-top: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}

.brief-answers summary {
  padding: 16px 24px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--fg-muted);
  user-select: none;
}
.brief-answers summary:hover { color: var(--fg-secondary); }

.answers-grid { padding: 0 24px 20px; }

.answer-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.answer-row:last-child { border-bottom: none; }
.answer-label { color: var(--fg-muted); font-weight: 500; }
.answer-value { color: var(--fg-secondary); }

/* ---- TEMPLATES ---------------------------------------- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.template-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s;
}
.template-card:hover { border-color: rgba(212,168,83,0.3); }

.template-tone {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  align-self: flex-start;
}
.tone-warm { background: rgba(212,168,83,0.12); color: var(--accent); }
.tone-professional { background: rgba(100,150,255,0.12); color: #6496ff; }
.tone-action { background: rgba(80,200,120,0.12); color: #50c878; }

.template-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

.template-subject {
  font-size: 0.85rem;
  color: var(--fg-secondary);
}

.template-preview {
  color: var(--fg-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  flex: 1;
}

.template-tip {
  display: flex;
  gap: 20px;
  background: var(--bg-card);
  border: 1px solid var(--accent-glow);
  border-radius: var(--radius);
  padding: 24px 28px;
}

.tip-icon { font-size: 1.5rem; flex-shrink: 0; }
.template-tip strong { display: block; font-family: var(--font-display); margin-bottom: 6px; }
.template-tip p { font-size: 0.9rem; color: var(--fg-secondary); }

/* Template detail */
.email-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}

.email-preview-header {
  background: var(--bg-secondary);
  padding: 20px 28px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.8;
}

.email-label { color: var(--fg-muted); font-weight: 600; }
.email-val { color: var(--fg-secondary); }

.email-preview-body { padding: 28px; }

.email-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--fg-primary);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.template-instructions {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.template-instructions h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--fg-secondary);
}

.instructions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instructions-list li {
  font-size: 0.9rem;
  color: var(--fg-secondary);
  padding-left: 20px;
  position: relative;
}

.instructions-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
}

code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--accent);
}

/* ---- ERROR -------------------------------------------- */
.error-wrap {
  max-width: 500px;
  margin: 0 auto;
  padding: 120px 24px;
  text-align: center;
}

.error-code {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
  margin-bottom: 24px;
}

.error-wrap h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: 12px;
}

.error-wrap p {
  color: var(--fg-secondary);
  margin-bottom: 28px;
}

/* ---- RESPONSIVE --------------------------------------- */
@media (max-width: 768px) {
  .app-main { padding: 32px 20px; }
  .app-nav { padding: 0 20px; }
  .nav-links { gap: 12px; }

  .template-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .data-table { font-size: 0.82rem; }
  .data-table th, .data-table td { padding: 12px; }

  .brief-content { padding: 28px 20px; }
  .answer-row { grid-template-columns: 1fr; gap: 4px; }

  .page-header { flex-direction: column; }
}
