/* ============================================================
   Resume Analyzer — light professional (corporate SaaS style)
   ============================================================ */

:root {
  --bg-page: #ffffff;
  --bg-panel: #f5f7fa;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #475569;
  --muted-soft: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.08);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --transition: 0.2s ease;
}

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

html {
  height: 100%;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.site-header {
  flex-shrink: 0;
  padding: 1rem 1.75rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  position: relative;
  z-index: 10;
}

.site-header-titles {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}

.site-header-tagline {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--muted);
}

.global-err-banner {
  flex-shrink: 0;
  width: 100%;
  max-width: 1400px;
  margin: 0.75rem auto 0;
  padding: 0.65rem 1rem;
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  z-index: 50;
  position: relative;
}

/* ── Layout 60% / 40% ── */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 3fr 2fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.25rem 1.25rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    padding: 0.875rem;
  }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.panel:hover {
  box-shadow: var(--shadow-hover);
}

.panel-head {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: #ffffff;
}

.panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem;
}

.layout > .panel:nth-child(1) .panel-body {
  overflow-y: auto;
  overflow-x: hidden;
}

.layout > .panel:nth-child(1) .dropzone {
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  background: var(--bg-card);
}

.layout > .panel:nth-child(2) .panel-body {
  overflow: hidden;
}

.layout > .panel:nth-child(2) #dashContent {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.layout > .panel:nth-child(2) #dashContent .actions {
  margin-top: auto;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  padding-top: 1rem;
  margin-bottom: -0.25rem;
  padding-bottom: 0.25rem;
  background: var(--bg-panel);
  z-index: 2;
}

/* ── Dropzone ── */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 2rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition),
    box-shadow var(--transition);
  margin-bottom: 1rem;
  background: var(--bg-card);
  position: relative;
}

.dropzone::before {
  content: "📄";
  display: block;
  font-size: 2rem;
  margin-bottom: 0.35rem;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: var(--shadow-card);
}

.dropzone p {
  margin: 0.25rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.dropzone strong {
  color: var(--primary);
  font-weight: 600;
}

input[type="file"] {
  display: none;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.875rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--font);
  transition: background var(--transition), border-color var(--transition),
    color var(--transition);
}

.tab-btn:hover {
  background: #f8fafc;
  color: var(--text);
  border-color: #cbd5e1;
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* ── Preview ── */
.preview-block {
  font-size: 0.85rem;
}

.field-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
}

.preview-block h3 {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-soft);
  font-weight: 600;
}

.source-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.src-badge {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  line-height: 1.3;
  color: var(--muted);
  background: #f1f5f9;
}

.src-badge-regex {
  color: var(--muted);
  background: #f1f5f9;
  border-color: var(--border);
}

.preview-block .box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.75rem;
  margin-bottom: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
  font-size: 0.8125rem;
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.preview-raw {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  color: var(--muted);
  max-height: 400px;
  overflow: auto;
  line-height: 1.5;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.6;
}

.layout > .panel:nth-child(1) #previewEmpty.empty-state,
.layout > .panel:nth-child(2) #dashEmpty.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

/* ── Score rings (green → amber → red) ── */
.score-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.score-ring {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: conic-gradient(
    #16a34a calc(var(--p) * 0.33%),
    #ca8a04 calc(var(--p) * 0.67%),
    #dc2626 calc(var(--p) * 1%),
    #e2e8f0 0
  );
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
}

.score-ring-inner {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.category-rings {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 520px) {
  .category-rings {
    grid-template-columns: repeat(4, 1fr);
  }
}

.cat-ring-item {
  text-align: center;
}

.cat-ring-item .label {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.5rem;
  line-height: 1.3;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mini-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto;
  background: conic-gradient(
    var(--primary) calc(var(--p) * 1%),
    #e2e8f0 0%
  );
  display: grid;
  place-items: center;
}

.mini-ring-inner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.metric {
  margin-bottom: 1rem;
}

.metric label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-weight: 500;
}

.metric label span:last-child {
  color: var(--text);
  font-weight: 600;
}

.bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #3b82f6);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.detail-list {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
}

.detail-list li {
  margin-bottom: 0.15rem;
}

/* ── ATS card ── */
.ats-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.ats-grade {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.ats-grade.good {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.ats-grade.fair {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.ats-grade.needs {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.list-check {
  color: var(--success);
  font-size: 0.8rem;
  margin: 0.25rem 0;
  line-height: 1.45;
}

.list-issue {
  color: var(--warning);
  font-size: 0.8rem;
  margin: 0.25rem 0;
  line-height: 1.45;
}

.dash-blurb {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.ats-tips {
  margin: 0.45rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.ats-tips li {
  margin-bottom: 0.2rem;
}

/* ── Buttons (AI stays visible: outline + tint) ── */
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

button.primary {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-xs);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.84rem;
  font-family: var(--font);
  transition: background var(--transition), border-color var(--transition),
    box-shadow var(--transition);
}

button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

button.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

button.secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 0.84rem;
  font-family: var(--font);
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition);
}

button.secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

#btnAiEnhance {
  background: var(--primary-soft);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
  font-weight: 600;
}

#btnAiEnhance:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.14);
  border-color: var(--primary);
  color: var(--primary-hover);
}

/* ── AI results ── */
.ai-results {
  margin-top: 0.875rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.ai-results .panel-head {
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-size: 0.75rem;
}

.ai-results .panel-head::after {
  content: "▼";
  font-size: 0.65rem;
  color: var(--muted);
  transition: transform var(--transition);
}

.ai-results.ai-collapsed .panel-head::after {
  transform: rotate(-90deg);
}

.ai-results.ai-collapsed #aiData {
  display: none;
}

.ai-results #aiData {
  padding: 0.875rem 1rem 1rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.ai-section {
  margin-bottom: 1rem;
}

.ai-section:last-child {
  margin-bottom: 0;
}

.ai-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-soft);
  font-weight: 600;
  margin: 0 0 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ai-badge {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: var(--primary);
  line-height: 1.25;
}

.ai-career-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-xs);
  background: #f1f5f9;
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}

.ai-bullet-score {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.ai-bullet-max {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.ai-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.ai-tag-list li {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.ai-tag-gap li {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.ai-bullet-list {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.8125rem;
  color: var(--text);
  line-height: 1.45;
}

.ai-bullet-list li {
  margin-bottom: 0.25rem;
}

.ai-bullet-list.ai-weakness li::marker {
  color: var(--danger);
}

.ai-results .preview-block .box {
  background: #ffffff;
}

.ai-results .ai-err {
  margin: 0;
  font-size: 0.84rem;
  color: var(--danger);
  line-height: 1.45;
}

.ai-loading-msg {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.ai-insights {
  margin-bottom: 1rem;
}

.ai-structured-summary {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.ai-muted-plain {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.ai-hint {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.ai-subheading {
  margin: 0.5rem 0 0.3rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--muted-soft);
}

.meta-line {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.err {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 0.65rem;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
  margin-bottom: 0.875rem;
  line-height: 1.4;
}

.loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.84rem;
  flex-shrink: 0;
  margin-bottom: 0.75rem;
}

.loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  animation: loading-pulse 1s ease-in-out infinite alternate;
}

@keyframes loading-pulse {
  from {
    opacity: 0.35;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1.05);
  }
}

#exportCapture {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 800px;
  background: #ffffff;
  color: var(--text);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

html {
  scroll-behavior: smooth;
}

button:focus-visible,
.dropzone:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.ai-notice {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
