/* ResumePico - High-Fidelity ATS Resume Builder Stylesheet */
:root {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-sheet: 0 12px 30px -4px rgba(0, 0, 0, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.06);

  /* Dynamic Resume Variables */
  --pico-primary: #1e3a8a;
  --pico-primary-light: #eff6ff;
  --pico-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --pico-spacing: 14px;
  --pico-line-height: 1.45;
  --pico-font-size: 10pt;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; max-width: 100vw; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Header & Toolbar */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 8px 16px;
  box-shadow: var(--shadow-sm);
  width: 100%;
}
.header-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.brand-group { display: flex; align-items: center; gap: 8px; }
.brand-logo {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  font-weight: 700; font-size: 1.1rem; color: var(--text-main);
}
.brand-icon {
  width: 26px; height: 26px; background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; border-radius: var(--radius-sm); display: flex;
  align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 800;
}
.brand-badge {
  font-size: 0.7rem; font-weight: 600; padding: 1px 6px; background: #ecfdf5;
  color: #059669; border: 1px solid #a7f3d0; border-radius: 9999px;
}

.toolbar-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.control-item {
  display: flex; align-items: center; gap: 4px; font-size: 0.8rem;
  font-weight: 500; color: var(--text-muted);
}
.select-input {
  appearance: none;
  background: var(--bg-surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") no-repeat right 8px center;
  padding: 5px 24px 5px 8px; font-size: 0.8rem; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-main); cursor: pointer; outline: none;
}
.select-input:focus { border-color: var(--border-focus); }

/* Color Swatches */
.color-swatches { display: flex; align-items: center; gap: 5px; }
.color-dot {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: transform 0.15s ease; outline: none;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { border-color: #fff; box-shadow: 0 0 0 2px var(--text-main); }
.color-navy { background-color: #1e3a8a; }
.color-green { background-color: #065f46; }
.color-ink { background-color: #1c1917; }
.color-wine { background-color: #831843; }

/* Buttons & Mobile Tabs */
.toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px;
  font-size: 0.8rem; font-weight: 500; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-surface);
  color: var(--text-main); cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
}
.btn:hover { background: var(--bg-subtle); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-sm { padding: 3px 6px; font-size: 0.72rem; }

.mobile-tabs {
  display: none; background: #f1f5f9; padding: 2px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-color);
}
.tab-btn {
  border: none; background: transparent; padding: 5px 12px; font-size: 0.8rem;
  font-weight: 600; border-radius: 4px; color: var(--text-muted); cursor: pointer;
}
.tab-btn.active { background: #fff; color: var(--text-main); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* Main Split Layout */
.app-main {
  flex: 1; display: flex; max-width: 1600px; width: 100%;
  margin: 0 auto; position: relative; overflow: hidden;
}
.editor-panel {
  flex: 0 0 520px; max-width: 560px; height: calc(100vh - 58px);
  overflow-y: auto; padding: 16px 20px 60px; border-right: 1px solid var(--border-color);
  background: var(--bg-surface);
}

/* Accordion Section */
.accordion-section {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); margin-bottom: 12px; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.accordion-header {
  padding: 10px 14px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; background: var(--bg-surface);
}
.accordion-header:hover { background: #f8fafc; }
.accordion-section.expanded .accordion-header { border-bottom: 1px solid var(--border-color); }
.accordion-title-wrap { display: flex; align-items: center; gap: 8px; }
.accordion-title { font-size: 0.88rem; font-weight: 600; color: var(--text-main); }
.accordion-chevron { transition: transform 0.2s ease; font-size: 0.75rem; color: var(--text-muted); }
.accordion-section.expanded .accordion-chevron { transform: rotate(180deg); }
.accordion-body { padding: 14px; display: none; }
.accordion-section.expanded .accordion-body { display: block; }

/* Forms & Dynamic Items */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.col-span-2 { grid-column: span 2; }
.form-group { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.form-label { font-size: 0.76rem; font-weight: 600; color: #475569; }
.form-input, .form-textarea {
  width: 100%; padding: 7px 9px; font-size: 0.82rem; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); outline: none; background: #fff; color: var(--text-main);
  min-width: 0; box-sizing: border-box;
}
.form-input:focus, .form-textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.form-textarea { resize: vertical; min-height: 72px; font-family: inherit; line-height: 1.4; }

.dynamic-items-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.item-card { border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: #f8fafc; padding: 10px; }
.item-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid #e2e8f0;
}
.item-card-title { font-size: 0.82rem; font-weight: 600; color: var(--text-main); }
.item-card-actions { display: flex; align-items: center; gap: 3px; }
.icon-btn {
  background: #fff; border: 1px solid var(--border-color); border-radius: 4px;
  width: 22px; height: 22px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 0.7rem; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: #e2e8f0; color: var(--text-main); }
.icon-btn.danger:hover { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }

/* Tag Input */
.tag-input-container {
  display: flex; flex-wrap: wrap; gap: 5px; padding: 5px 8px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: #fff; min-height: 38px; align-items: center;
}
.tag-input-container:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.tag-badge {
  display: inline-flex; align-items: center; gap: 4px; background: #f1f5f9;
  color: #1e293b; font-size: 0.75rem; font-weight: 500; padding: 2px 7px;
  border-radius: 4px; border: 1px solid #cbd5e1;
}
.tag-badge .tag-remove { cursor: pointer; font-size: 0.85rem; color: #94a3b8; }
.tag-badge .tag-remove:hover { color: var(--danger); }
.tag-text-input { border: none; outline: none; font-size: 0.82rem; flex: 1; min-width: 90px; padding: 2px; }

/* Preview Workspace */
.preview-panel {
  flex: 1; height: calc(100vh - 58px); overflow-y: auto; overflow-x: hidden;
  background: #cbd5e1; padding: 18px 12px 60px; display: flex;
  flex-direction: column; align-items: center; position: relative;
}
.preview-toolbar {
  position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px); border: 1px solid var(--border-color);
  border-radius: 9999px; padding: 3px 12px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px; font-size: 0.75rem; box-shadow: var(--shadow-md);
}
.sheet-viewport {
  width: 100%; display: flex; justify-content: center; transform-origin: top center;
  transition: transform 0.2s ease;
}

/* A4 Sheet Strict Dimensions */
.a4-sheet {
  width: 210mm; min-height: 297mm; background: #ffffff;
  box-shadow: var(--shadow-sheet); border-radius: 2px; box-sizing: border-box;
  position: relative; overflow: hidden;
}

/* Common Resume Inner Layout */
.resume-sheet {
  font-family: var(--pico-font); font-size: var(--pico-font-size);
  line-height: var(--pico-line-height); color: #1e293b;
  padding: calc(var(--pico-spacing) * 1.6); word-break: break-word;
}
.candidate-name {
  font-size: 1.85rem; font-weight: 800; line-height: 1.15; color: var(--text-main); letter-spacing: -0.02em;
}
.candidate-title {
  font-size: 1.02rem; font-weight: 600; color: var(--pico-primary); margin: 2px 0 6px;
}
.candidate-contacts {
  font-size: 0.84em; color: #475569; display: flex; flex-wrap: wrap; gap: 3px 6px; align-items: center;
}
.contact-sep { color: #cbd5e1; }
.contact-link { color: inherit; text-decoration: none; }
.contact-link:hover { text-decoration: underline; color: var(--pico-primary); }

.resume-section { margin-top: calc(var(--pico-spacing) * 1.2); }
.section-title {
  font-size: 1rem; font-weight: 700; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--pico-primary); margin-bottom: calc(var(--pico-spacing) * 0.6);
}
.summary-text { font-size: 0.92em; color: #334155; text-align: justify; }

.entries-list { display: flex; flex-direction: column; gap: calc(var(--pico-spacing) * 0.8); }
.entry-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.entry-role { font-size: 0.96rem; font-weight: 700; color: #0f172a; }
.entry-company { font-size: 0.9rem; font-weight: 600; color: #334155; }
.entry-meta { font-size: 0.84em; color: #64748b; text-align: right; white-space: nowrap; }
.resume-bullet-list { margin: 3px 0 0 16px; padding: 0; font-size: 0.9em; color: #334155; }
.resume-bullet-list li { margin-bottom: 2px; }
.entry-honors, .entry-summary { font-size: 0.86em; color: #475569; margin-top: 3px; }

/* Skills Chips */
.skill-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.skill-chip {
  font-size: 0.8em; font-weight: 500; padding: 2px 7px; border-radius: 4px;
  background: var(--pico-primary-light); color: var(--pico-primary);
  border: 1px solid rgba(0, 0, 0, 0.05);
}
.skills-inline-text { font-size: 0.9em; color: #334155; }

/* Template 1: Modern */
.template-modern .candidate-name { color: var(--pico-primary); }
.template-modern .section-title { border-bottom: 2px solid var(--pico-primary); padding-bottom: 2px; }

/* Template 2: Professional */
.template-professional .resume-header { text-align: center; border-bottom: 2px solid #0f172a; padding-bottom: 10px; }
.template-professional .candidate-contacts { justify-content: center; }
.template-professional .section-title { color: #0f172a; border-bottom: 1px solid #cbd5e1; padding-bottom: 2px; }
.template-professional .entry-company { color: var(--pico-primary); }

/* Template 3: Minimalist */
.template-minimalist { padding: calc(var(--pico-spacing) * 2); }
.template-minimalist .section-title {
  color: #64748b; font-size: 0.82rem; letter-spacing: 0.12em;
  border-bottom: 1px solid #e2e8f0; padding-bottom: 3px;
}
.template-minimalist .entry-company-sep { color: #94a3b8; margin: 0 4px; }
.template-minimalist .skill-chip { background: #f1f5f9; color: #334155; }

/* Template 4: Creative */
.template-creative { padding: 0; }
.creative-grid { display: grid; grid-template-columns: 32% 68%; min-height: 297mm; }
.creative-sidebar {
  background: #f8fafc; border-right: 2px solid var(--border-color);
  padding: calc(var(--pico-spacing) * 1.4) calc(var(--pico-spacing) * 1.1);
  display: flex; flex-direction: column; gap: calc(var(--pico-spacing) * 1.1);
}
.creative-sidebar .candidate-name { font-size: 1.4rem; color: var(--pico-primary); }
.creative-sidebar .sidebar-heading {
  font-size: 0.82rem; font-weight: 700; text-transform: uppercase;
  color: var(--pico-primary); border-bottom: 1px solid var(--border-color);
  padding-bottom: 3px; margin-bottom: 6px;
}
.sidebar-contact-list { list-style: none; font-size: 0.82em; display: flex; flex-direction: column; gap: 4px; }
.sidebar-contact-list a { color: inherit; text-decoration: none; }
.sidebar-edu-list { display: flex; flex-direction: column; gap: 7px; }
.sidebar-edu-degree { font-weight: 700; font-size: 0.86em; }
.sidebar-edu-school { font-size: 0.8em; color: #475569; }
.sidebar-edu-date { font-size: 0.76em; color: #94a3b8; }
.creative-main { padding: calc(var(--pico-spacing) * 1.4) calc(var(--pico-spacing) * 1.5); }

/* Toast Notification */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.toast {
  background: #1e293b; color: #fff; padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 500; box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(10px); transition: all 0.2s ease; pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Responsive Mobile Layout (<= 900px, tested down to 390px) */
@media (max-width: 900px) {
  .mobile-tabs { display: flex; }
  .header-container { flex-direction: column; align-items: stretch; gap: 8px; width: 100%; }
  .brand-group { justify-content: space-between; width: 100%; }
  .toolbar-controls { width: 100%; justify-content: flex-start; gap: 6px; }
  .toolbar-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 5px; }
  .app-main { flex-direction: column; height: auto; width: 100%; }
  .editor-panel, .preview-panel {
    flex: 1 1 100%; max-width: 100%; width: 100%; height: auto;
    min-height: calc(100vh - 110px); border-right: none; padding: 12px 10px 80px;
    box-sizing: border-box; overflow-x: hidden;
  }
  body[data-active-tab="edit"] .preview-panel { display: none; }
  body[data-active-tab="preview"] .editor-panel { display: none; }
  body[data-active-tab="preview"] .preview-panel { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
}

/* Print Rules - Strictly A4 Page */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; color: #000 !important; margin: 0 !important; padding: 0 !important; }
  .app-header, .editor-panel, .preview-toolbar, .toast-container, .mobile-tabs { display: none !important; }
  .app-main, .preview-panel, .sheet-viewport {
    display: block !important; padding: 0 !important; margin: 0 !important;
    width: 210mm !important; height: 297mm !important; background: transparent !important;
    overflow: visible !important; transform: none !important;
  }
  .a4-sheet {
    width: 210mm !important; height: auto !important; min-height: 297mm !important;
    box-shadow: none !important; border-radius: 0 !important;
  }
}
