/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1B2A5E;
  --accent: #4A7BC5;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1A202C;
  --muted: #64748B;
  --danger: #E53E3E;
  --success: #38A169;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

html { font-size: 16px; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Layout ───────────────────────────────────────────────────────── */
.app-header {
  background: var(--navy);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.app-header .logo { font-size: 1.1rem; font-weight: 700; color: white; letter-spacing: -0.3px; }
.app-header .logo span { color: var(--accent); }
.app-header nav { display: flex; align-items: center; gap: 16px; }
.app-header nav a { color: rgba(255,255,255,.8); font-size: .875rem; transition: color .2s; }
.app-header nav a:hover { color: white; text-decoration: none; }
.app-header .btn-logout {
  background: rgba(255,255,255,.12);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: .875rem;
  transition: background .2s;
}
.app-header .btn-logout:hover { background: rgba(255,255,255,.22); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.page { padding: 32px 24px; max-width: 1200px; margin: 0 auto; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  border: none; transition: all .15s;
  text-decoration: none;
}
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: #243572; text-decoration: none; }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: #3a6ab5; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }
.btn-danger { background: var(--danger); color: white; border: none; }
.btn-danger:hover { background: #c53030; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-body { padding: 24px; }
.card-header { padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--bg); }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg); }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--text); }
.form-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .875rem; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,123,197,.15); }
.form-textarea { min-height: 80px; resize: vertical; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 32px; }
.form-hint { font-size: .75rem; color: var(--muted); }
.form-error { font-size: .75rem; color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Auth Page ────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--navy) 0%, #2d4a9e 100%);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-logo { font-size: 1.5rem; font-weight: 800; color: var(--navy); margin-bottom: 8px; }
.auth-logo span { color: var(--accent); }
.auth-subtitle { color: var(--muted); font-size: .875rem; margin-bottom: 32px; }
.otp-input {
  width: 100%; text-align: center; font-size: 2rem; font-weight: 700;
  letter-spacing: 12px; padding: 16px; border: 2px solid var(--border);
  border-radius: var(--radius); font-family: monospace;
  transition: border-color .15s;
}
.otp-input:focus { outline: none; border-color: var(--accent); }

/* ── Dashboard ────────────────────────────────────────────────────── */
.cv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.cv-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  cursor: pointer;
}
.cv-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cv-card-preview {
  height: 180px;
  background: linear-gradient(135deg, var(--navy) 0%, #243572 40%, #3a6ab5 100%);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.cv-card-preview .t-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,.2);
  color: white;
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 20px;
}
.cv-card-preview .preview-mini {
  width: 90px;
  height: 127px;
  background: white;
  border-radius: 3px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.cv-card-body { padding: 16px; }
.cv-card-title { font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.cv-card-meta { font-size: .75rem; color: var(--muted); }
.cv-card-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ── Editor ───────────────────────────────────────────────────────── */
.editor-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 56px);
  overflow: hidden;
}
.editor-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  scrollbar-width: none;
}
.editor-tabs::-webkit-scrollbar { display: none; }
.editor-tab {
  padding: 10px 14px;
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all .15s;
}
.editor-tab.active { color: var(--navy); border-bottom-color: var(--navy); }
.editor-tab:hover { color: var(--text); }
.editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.editor-preview {
  background: #E8ECF0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.editor-preview-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.preview-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
}
.preview-scale-wrap {
  transform-origin: top center;
  width: 794px;
  flex-shrink: 0;
}
.save-status {
  font-size: .75rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
}
.save-status.saving { color: var(--muted); }

/* ── Section Items ────────────────────────────────────────────────── */
.item-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.item-card-header {
  padding: 10px 14px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.item-card-title { font-size: .875rem; font-weight: 500; }
.item-card-body { padding: 14px; display: none; }
.item-card.open .item-card-body { display: block; }
.item-card-actions { display: flex; gap: 6px; }

/* ── Skill level ──────────────────────────────────────────────────── */
.skill-dots { display: flex; gap: 4px; align-items: center; }
.skill-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  cursor: pointer;
  transition: background .15s;
}
.skill-dot.filled { background: var(--accent); }

/* ── Color picker ─────────────────────────────────────────────────── */
.color-row { display: flex; align-items: center; gap: 10px; }
.color-swatch { width: 36px; height: 36px; border-radius: 6px; border: 2px solid var(--border); cursor: pointer; overflow: hidden; padding: 0; }
.color-swatch input[type=color] { width: 200%; height: 200%; margin: -50%; border: none; cursor: pointer; }

/* ── Template selector ────────────────────────────────────────────── */
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.template-option {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s;
}
.template-option.selected { border-color: var(--accent); }
.template-option:hover { border-color: var(--accent); }
.template-thumb {
  height: 100px;
  background: linear-gradient(135deg, #1B2A5E, #4A7BC5);
  display: grid;
  place-items: center;
}
.template-label { padding: 8px; font-size: .75rem; font-weight: 500; text-align: center; }

/* ── CV Templates (A4) ────────────────────────────────────────────── */
.cv-a4 {
  width: 794px;
  min-height: 1123px;
  background: white;
  position: relative;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}

/* ── Public CV Page ───────────────────────────────────────────────── */
.cv-public-wrap {
  min-height: 100vh;
  background: #E8ECF0;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.cv-public-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: .875rem; margin-bottom: 16px; }
.alert-success { background: #f0fff4; border: 1px solid #9ae6b4; color: #276749; }
.alert-error { background: #fff5f5; border: 1px solid #fed7d7; color: #9b2c2c; }
.alert-info { background: #ebf8ff; border: 1px solid #bee3f8; color: #2a4a6b; }

/* ── Utils ────────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--muted); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Print ────────────────────────────────────────────────────────── */
@media print {
  body { background: white !important; }
  .cv-public-actions, .app-header { display: none !important; }
  .cv-public-wrap { padding: 0 !important; background: white !important; }
  .cv-a4 { box-shadow: none !important; }
}

@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-preview { display: none; }
  .editor-layout.show-preview .editor-sidebar { display: none; }
  .editor-layout.show-preview .editor-preview { display: flex; }
  .preview-scale-wrap { width: 100%; transform: none !important; }
  .cv-a4 { width: 100% !important; }
}
