/* ─────────────────────────────────────────────────────────────────────────────
   Resumé.AI — Main Stylesheet
   Aesthetic: Editorial / Refined dark-sidebar split layout
───────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #f4f2ed;
  --surface:     #ffffff;
  --sidebar-bg:  #0f1623;
  --sidebar-border: #1e2d3d;
  --text:        #1a1a1a;
  --text-muted:  #6b7280;
  --border:      #e2ddd6;
  --accent:      #2563eb;
  --accent-alt:  #8b5cf6;
  --ai-color:    #7c3aed;
  --success:     #16a34a;
  --danger:      #dc2626;
  --font-serif:  'DM Serif Display', Georgia, serif;
  --font-sans:   'DM Sans', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
  --radius:      8px;
  --radius-sm:   4px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.12);
  --transition:  0.18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 56px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center;
}
.header-inner {
  width: 100%; display: flex; align-items: center;
  gap: 24px; padding: 0 24px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 16px; color: #fff;
}
.logo-text { font-family: var(--font-serif); font-size: 18px; color: #e8e8e8; }
.logo-dot { color: var(--accent); }

.header-nav { display: flex; gap: 4px; margin-left: auto; }
.nav-btn {
  background: transparent; border: none; cursor: pointer;
  color: #6b7280; font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.nav-btn:hover { color: #e8e8e8; background: rgba(255,255,255,.07); }
.nav-btn.active { color: #fff; background: rgba(255,255,255,.1); }

.header-actions { display: flex; align-items: center; gap: 12px; margin-left: 8px; }
.template-picker { display: flex; align-items: center; gap: 8px; }
.template-picker label { font-size: 12px; color: #6b7280; white-space: nowrap; }
.template-picker select {
  background: rgba(255,255,255,.06); border: 1px solid var(--sidebar-border);
  color: #d1d5db; font-family: var(--font-sans); font-size: 12px;
  padding: 5px 10px; border-radius: var(--radius-sm); cursor: pointer;
  outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  padding-right: 26px;
}

/* ── App Layout ─────────────────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 440px 1fr;
  height: 100vh;
  padding-top: 56px;
}

/* ── Panels ─────────────────────────────────────────────────────────────────── */
.panel { height: 100%; overflow: hidden; }

.panel-form {
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.panel-scroll { height: 100%; overflow-y: auto; padding: 28px 28px 120px; }
.panel-scroll::-webkit-scrollbar { width: 6px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Form Sections ──────────────────────────────────────────────────────────── */
.form-section { margin-bottom: 36px; }

.section-label {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 18px;
}
.section-number {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  color: var(--accent); opacity: 0.8;
  letter-spacing: 0.05em;
}
.section-label h2 {
  font-family: var(--font-serif); font-size: 18px; font-weight: 400;
  color: var(--text);
}

.field-grid { display: grid; gap: 12px; }
.field-grid.two-col { grid-template-columns: 1fr 1fr; }
.field.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 11.5px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.req { color: var(--accent); }
.hint { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.65; font-size: 10px; }

input[type=text], input[type=email], input[type=tel], textarea, select {
  width: 100%;
  background: #fafaf8; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-sans); font-size: 13.5px;
  padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: #fff;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }

/* Skill Tags */
.skill-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.skill-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: #eff6ff; color: #1d4ed8;
  border: 1px solid #bfdbfe; border-radius: 99px;
  padding: 3px 10px; font-size: 12px; font-weight: 500;
  animation: tagIn .15s ease;
}
@keyframes tagIn { from { opacity:0; transform:scale(.85); } to { opacity:1; transform:scale(1); } }
.skill-tag button {
  background: none; border: none; cursor: pointer;
  color: #3b82f6; line-height: 1; font-size: 14px; padding: 0 1px;
}

/* ── Repeating Item Cards ───────────────────────────────────────────────────── */
.item-card {
  background: #fafaf8; border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 10px; position: relative;
}
.item-card .card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.item-card .card-title {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em;
}
.remove-btn {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 2px 5px; border-radius: 4px; font-size: 18px; line-height: 1;
  transition: color var(--transition), background var(--transition);
}
.remove-btn:hover { color: var(--danger); background: #fff0f0; }

.add-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: 1.5px dashed var(--border);
  color: var(--text-muted); font-family: var(--font-sans); font-size: 13px;
  padding: 8px 16px; border-radius: var(--radius); cursor: pointer;
  transition: all var(--transition); margin-top: 4px;
}
.add-btn:hover {
  border-color: var(--accent); color: var(--accent);
  background: rgba(37,99,235,.04);
}

/* ── Form Actions ───────────────────────────────────────────────────────────── */
.form-actions {
  position: fixed; bottom: 0; left: 0; width: 440px;
  background: linear-gradient(to top, var(--surface) 75%, transparent);
  padding: 20px 28px 24px;
  display: flex; gap: 10px; z-index: 50;
}
.btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 20px;
  border: none; border-radius: var(--radius); cursor: pointer;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Preview Panel ──────────────────────────────────────────────────────────── */
.panel-preview {
  background: #e8e5de;
  display: flex; flex-direction: column;
}
.preview-toolbar {
  height: 48px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px; flex-shrink: 0;
}
.preview-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); transition: background var(--transition);
}
.status-dot.ready  { background: var(--success); }
.status-dot.loading { background: #f59e0b; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.preview-actions { display: flex; gap: 8px; }
.toolbar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1.5px solid var(--border);
  color: var(--text-muted); font-family: var(--font-sans); font-size: 12.5px;
  padding: 5px 12px; border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--transition);
}
.toolbar-btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-download {
  background: var(--accent); border-color: var(--accent); color: #fff !important;
}
.btn-download:hover { background: #1d4ed8 !important; border-color: #1d4ed8 !important; }
.btn-download:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Preview Frame ──────────────────────────────────────────────────────────── */
.preview-frame-wrapper {
  flex: 1; overflow: auto; display: flex; justify-content: center;
  padding: 24px;
}
.preview-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--text-muted); text-align: center;
  flex: 1; opacity: 0.5;
}
.preview-empty p { font-size: 14px; }
#previewFrame {
  width: 794px; /* A4 at 96dpi */
  height: 1123px;
  border: none;
  box-shadow: var(--shadow-lg);
  background: white;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Loading Overlay ────────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15,22,35,.75); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.loading-overlay.active { display: flex; }
.loading-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 32px 40px; display: flex; flex-direction: column;
  align-items: center; gap: 16px; box-shadow: var(--shadow-lg);
}
.loading-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-card p { font-size: 14px; color: var(--text-muted); }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 99999;
  background: var(--text); color: #fff;
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 13.5px; max-width: 320px;
  transform: translateY(20px); opacity: 0;
  transition: all 0.25s ease; pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ── Mobile: single-panel toggle ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .panel-form  { display: none; }
  .panel-preview { display: none; }
  .panel.active { display: flex; flex-direction: column; }
  .form-actions { width: 100%; }
  .panel-form.active { display: block; }
  .panel-preview.active { display: flex; }
  #previewFrame { width: 100%; }
}
