/* ===================== RESET & BASE ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===================== DARK THEME (default) ===================== */
:root {
  --accent: #6366f1;
  --accent-light: #818cf8;
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --bg4: #252532;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #f0f0f5;
  --text2: #9090a8;
  --text3: #5a5a72;
  --danger: #f87171;
  --success: #34d399;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: 'Inter', system-ui, sans-serif;
  --transition: 0.18s ease;
  --preview-bg: #1a1a22;
}

/* ===================== LIGHT THEME ===================== */
[data-theme="light"] {
  --bg: #f4f4f8;
  --bg2: #ffffff;
  --bg3: #f0f0f5;
  --bg4: #e4e4ee;
  --border: rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.14);
  --text: #111118;
  --text2: #555568;
  --text3: #9090a8;
  --preview-bg: #dde0e8;
}

html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; -webkit-font-smoothing: antialiased; transition: background var(--transition), color var(--transition); }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 4px; }

/* ===================== TOPBAR ===================== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 8px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #a855f7); display: flex; align-items: center; justify-content: center; font-size: 15px; }
.topbar-title { font-size: 14px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-sub { font-size: 10px; color: var(--text2); }
.topbar-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* ===================== PROGRESS BAR ===================== */
.progress-wrap {
  position: fixed; top: 52px; left: 0; right: 0; z-index: 99;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; height: 24px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.progress-track { flex: 1; height: 4px; background: var(--bg4); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--accent); border-radius: 4px; transition: width 0.4s ease, background 0.4s ease; }
.progress-label { font-size: 10px; font-weight: 700; color: var(--text2); min-width: 28px; text-align: right; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 12px; font-size: 12px; font-weight: 500; font-family: var(--font);
  border-radius: var(--radius-xs); border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text);
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.btn:hover { background: var(--bg4); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 0 16px rgba(99,102,241,0.3); }
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: rgba(248,113,113,0.1); }
.btn-sm { padding: 4px 9px; font-size: 11px; }

/* ===================== LAYOUT ===================== */
.app-layout {
  display: grid; grid-template-columns: 320px 1fr;
  height: 100vh; padding-top: 76px;
}

/* ===================== SIDEBAR ===================== */
.sidebar { background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.stab {
  flex: 1; padding: 10px 0; font-size: 11px; font-weight: 500;
  text-align: center; cursor: pointer; color: var(--text2);
  border: none; background: none; font-family: var(--font);
  transition: all var(--transition); position: relative;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.stab svg { width: 13px; height: 13px; }
.stab::after { content: ''; position: absolute; bottom: 0; left: 15%; right: 15%; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; transform: scaleX(0); transition: transform var(--transition); }
.stab.active { color: var(--text); }
.stab.active::after { transform: scaleX(1); }
.sidebar-body { flex: 1; overflow-y: auto; padding: 14px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===================== FORM ===================== */
.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.label { display: block; font-size: 10px; font-weight: 700; color: var(--text2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
input[type="text"], textarea, select {
  width: 100%; padding: 8px 10px; font-size: 12px; font-family: var(--font);
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition); outline: none;
}
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
input[type="text"]::placeholder, textarea::placeholder { color: var(--text3); }
textarea { resize: vertical; min-height: 75px; line-height: 1.6; }

/* ===================== SECTION HEAD ===================== */
.section-head { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.1em; margin: 16px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }

/* ===================== AI STATUS ===================== */
.ai-status { display: none; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-xs); background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.2); font-size: 11px; color: var(--accent-light); margin-bottom: 10px; }
.ai-status.visible { display: flex; }
.ai-spinner { width: 13px; height: 13px; border: 2px solid rgba(99,102,241,0.3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== AI BUTTON ===================== */
.ai-btn {
  width: 100%; padding: 8px 12px; font-size: 12px; font-weight: 600; font-family: var(--font); cursor: pointer;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(168,85,247,0.1));
  border: 1px solid rgba(99,102,241,0.25); border-radius: var(--radius-xs);
  color: var(--accent-light); transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.ai-btn:hover { background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(168,85,247,0.2)); border-color: rgba(99,102,241,0.4); }
.ai-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.spark { font-size: 13px; }

/* ===================== SKILLS ===================== */
.skills-row { display: flex; gap: 6px; }
.skills-row input { flex: 1; }
.skills-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.skill-tag { font-size: 11px; padding: 3px 9px; background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.2); border-radius: 100px; display: flex; align-items: center; gap: 4px; color: var(--accent-light); animation: fadeIn 0.2s ease; }
.skill-tag .rm { cursor: pointer; color: var(--text3); font-size: 10px; }
.skill-tag .rm:hover { color: var(--danger); }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* ===================== CARDS ===================== */
.card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px; margin-bottom: 8px; animation: slideIn 0.2s ease; cursor: grab; }
.card:active { cursor: grabbing; }
.card.drag-over { border-color: var(--accent); background: rgba(99,102,241,0.05); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.card-title { font-size: 11px; font-weight: 600; color: var(--text2); cursor: grab; }
.add-card-btn { width: 100%; padding: 8px; font-size: 11px; font-weight: 500; font-family: var(--font); cursor: pointer; background: transparent; border: 1px dashed var(--border2); border-radius: var(--radius-xs); color: var(--text2); transition: all var(--transition); display: flex; align-items: center; justify-content: center; gap: 5px; }
.add-card-btn:hover { border-color: var(--accent); color: var(--accent-light); background: rgba(99,102,241,0.05); }

/* ===================== TEMPLATE GRID ===================== */
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tpl-card { border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 7px; cursor: pointer; transition: all var(--transition); text-align: center; background: var(--bg3); }
.tpl-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.tpl-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.tpl-thumb { width: 100%; height: 68px; border-radius: 4px; margin-bottom: 5px; overflow: hidden; }
.tpl-name { font-size: 11px; font-weight: 600; color: var(--text2); }
.tpl-card.selected .tpl-name { color: var(--accent-light); }

/* ===================== ACCENT DOTS ===================== */
.accent-row { display: flex; gap: 7px; flex-wrap: wrap; }
.accent-dot { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all var(--transition); }
.accent-dot:hover { transform: scale(1.15); }
.accent-dot.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.3); }

/* ===================== TOOLS TAB ===================== */
.tool-desc { font-size: 11px; color: var(--text2); margin-bottom: 8px; line-height: 1.5; }
.tool-result { margin-top: 10px; }

/* Score circle */
.score-circle { width: 90px; height: 90px; border-radius: 50%; border: 4px solid; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 14px; }
.score-num { font-size: 28px; font-weight: 800; line-height: 1; }
.score-sub { font-size: 10px; color: var(--text2); }
.score-section { margin-bottom: 10px; }
.score-section-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 5px; }
.score-item { font-size: 11px; color: var(--text2); padding: 2px 0; line-height: 1.5; }

/* Resume list */
.resume-list-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-xs); margin-bottom: 6px; }
.resume-list-info { flex: 1; cursor: pointer; }
.resume-list-info:hover .resume-list-name { color: var(--accent-light); }
.resume-list-name { font-size: 12px; font-weight: 600; }
.resume-list-date { font-size: 10px; color: var(--text3); margin-top: 1px; }

/* ===================== PREVIEW PANEL ===================== */
.preview-panel { display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.preview-topbar { display: flex; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.preview-title { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 6px var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.preview-scroll { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; justify-content: center; background: var(--preview-bg); }
.resume-paper { width: 100%; max-width: 680px; background: white; color: #111; box-shadow: 0 4px 40px rgba(0,0,0,0.4); border-radius: 2px; min-height: 880px; flex-shrink: 0; }

/* ===================== TOAST ===================== */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--bg4); color: var(--text); padding: 9px 18px; border-radius: 100px; font-size: 12px; font-weight: 500; opacity: 0; transition: all 0.3s ease; pointer-events: none; z-index: 999; border: 1px solid var(--border2); white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== MOBILE TOGGLE ===================== */
.mobile-toggle { display: none; position: fixed; bottom: 20px; right: 20px; z-index: 200; width: 50px; height: 50px; border-radius: 50%; background: var(--accent); border: none; cursor: pointer; box-shadow: 0 4px 20px rgba(99,102,241,0.5); font-size: 20px; color: white; align-items: center; justify-content: center; transition: all var(--transition); }
.mobile-toggle:hover { transform: scale(1.08); }

/* ===================== UTILITIES ===================== */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }

/* ===================== RESUME TEMPLATES ===================== */
.resume-classic { font-family: Georgia, serif; color: #1a1a1a; padding: 52px 56px; }
.rc-header { text-align: center; padding-bottom: 18px; margin-bottom: 22px; border-bottom: 2px solid #1a1a1a; }
.rc-name { font-size: 30px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; }
.rc-role { font-size: 13px; color: #555; margin-top: 4px; }
.rc-contact { font-size: 11.5px; color: #666; margin-top: 7px; }
.rc-section { margin-bottom: 20px; }
.rc-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 2.5px; border-bottom: 1px solid #ddd; padding-bottom: 5px; margin-bottom: 12px; }
.rc-exp { margin-bottom: 14px; }
.rc-exp-row { display: flex; justify-content: space-between; align-items: baseline; }
.rc-exp-title { font-size: 14px; font-weight: 700; }
.rc-exp-date { font-size: 11px; color: #777; }
.rc-exp-company { font-size: 12.5px; font-style: italic; color: #555; margin-top: 1px; }
.rc-exp-desc { font-size: 12px; color: #444; margin-top: 5px; line-height: 1.65; white-space: pre-line; }
.rc-skills { display: flex; flex-wrap: wrap; gap: 6px; }
.rc-skill { font-size: 11.5px; padding: 3px 11px; border: 1px solid #ccc; border-radius: 2px; color: #333; }
.rc-summary { font-size: 13px; color: #444; line-height: 1.75; font-style: italic; }

.resume-modern { font-family: 'Segoe UI', system-ui, sans-serif; display: grid; grid-template-columns: 210px 1fr; min-height: 880px; }
.rm-left { background: #1a1a2e; color: #dde; padding: 40px 22px; }
.rm-avatar { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: #fff; margin: 0 auto 14px; }
.rm-name { font-size: 15px; font-weight: 700; text-align: center; color: #fff; }
.rm-role { font-size: 11px; color: #8888aa; text-align: center; margin-top: 3px; margin-bottom: 22px; }
.rm-sec { margin-bottom: 20px; }
.rm-sec-title { font-size: 9px; text-transform: uppercase; letter-spacing: 2.5px; font-weight: 700; margin-bottom: 9px; opacity: 0.5; }
.rm-contact-item { font-size: 11px; color: #bbbbd0; margin-bottom: 6px; display: flex; gap: 6px; align-items: flex-start; word-break: break-all; }
.rm-skill-bar { margin-bottom: 8px; }
.rm-skill-name { font-size: 11px; color: #bbbbd0; margin-bottom: 3px; }
.rm-skill-track { height: 3px; background: rgba(255,255,255,0.08); border-radius: 2px; }
.rm-skill-fill { height: 3px; border-radius: 2px; }
.rm-right { padding: 40px 28px; background: #fff; }
.rm-greeting { font-size: 24px; font-weight: 800; color: #1a1a2e; margin-bottom: 4px; }
.rm-summary { font-size: 12px; color: #666; line-height: 1.75; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid #eee; }
.rm-section { margin-bottom: 20px; }
.rm-section-title { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 2.5px; margin-bottom: 12px; }
.rm-exp { display: flex; gap: 12px; margin-bottom: 14px; }
.rm-exp-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.rm-exp-title { font-size: 13px; font-weight: 700; color: #1a1a2e; }
.rm-exp-meta { font-size: 11px; color: #999; margin: 2px 0 4px; }
.rm-exp-desc { font-size: 12px; color: #555; line-height: 1.65; white-space: pre-line; }

.resume-minimal { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #111; padding: 56px 64px; }
.rmin-name { font-size: 34px; font-weight: 200; letter-spacing: -1px; margin-bottom: 5px; }
.rmin-role { font-size: 14px; color: #888; margin-bottom: 4px; font-weight: 300; }
.rmin-contact { font-size: 12px; color: #bbb; margin-bottom: 36px; }
.rmin-section { margin-bottom: 28px; }
.rmin-section-title { font-size: 9.5px; text-transform: uppercase; letter-spacing: 3.5px; color: #bbb; margin-bottom: 14px; }
.rmin-exp { margin-bottom: 16px; display: grid; grid-template-columns: 110px 1fr; gap: 0 22px; }
.rmin-exp-date { font-size: 11px; color: #bbb; padding-top: 1px; }
.rmin-exp-title { font-size: 13px; font-weight: 500; }
.rmin-exp-company { font-size: 12px; color: #888; margin-top: 1px; }
.rmin-exp-desc { font-size: 12px; color: #555; margin-top: 5px; line-height: 1.65; white-space: pre-line; }
.rmin-skills { display: flex; flex-wrap: wrap; gap: 5px; }
.rmin-skill { font-size: 11px; color: #666; padding: 3px 12px; border: 1px solid #e0e0e0; border-radius: 100px; }
.rmin-summary { font-size: 13px; color: #555; line-height: 1.85; font-weight: 300; }

.resume-creative { font-family: 'Segoe UI', system-ui, sans-serif; color: #1a1a1a; }
.rcr-top { padding: 36px 48px; color: white; }
.rcr-name { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.rcr-role { font-size: 14px; opacity: 0.88; margin-top: 4px; font-weight: 300; }
.rcr-contacts { display: flex; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.rcr-contact-item { font-size: 12px; opacity: 0.82; }
.rcr-body { padding: 32px 48px; display: grid; grid-template-columns: 1fr 190px; gap: 32px; }
.rcr-section { margin-bottom: 22px; }
.rcr-section-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px; }
.rcr-exp { margin-bottom: 14px; border-left: 3px solid; padding-left: 12px; }
.rcr-exp-title { font-size: 13px; font-weight: 700; }
.rcr-exp-meta { font-size: 11px; color: #999; margin: 2px 0 4px; }
.rcr-exp-desc { font-size: 12px; color: #555; line-height: 1.65; white-space: pre-line; }
.rcr-skill { margin-bottom: 10px; }
.rcr-skill-name { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.rcr-skill-track { height: 5px; background: #f0f0f0; border-radius: 3px; }
.rcr-skill-fill { height: 5px; border-radius: 3px; }
.rcr-summary { font-size: 12px; color: #444; line-height: 1.75; }

/* ===================== PRINT ===================== */
@media print {
  body * { visibility: hidden; }
  #resume-output, #resume-output * { visibility: visible; }
  #resume-output { position: fixed; top: 0; left: 0; width: 100%; box-shadow: none; }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 76px; bottom: 0; width: 85%; max-width: 340px; z-index: 90; transform: translateX(-100%); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); }
  .sidebar.open { transform: translateX(0); }
  .preview-panel { grid-column: 1; }
  .mobile-toggle { display: flex; }
  .topbar-sub { display: none; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 10px; }
  .topbar-title { font-size: 13px; }
  .preview-scroll { padding: 10px 6px; }
  .resume-paper { border-radius: 0; }
}

/* ===================== FORM VALIDATION ===================== */
.req { color: var(--danger); font-size: 10px; margin-left: 2px; }

input.input-error, textarea.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(248,113,113,0.12) !important;
}

.field-error {
  font-size: 10px;
  color: var(--danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  animation: fadeIn 0.15s ease;
}
.field-error::before { content: '⚠'; font-size: 10px; }
