/* Modern styling variables for UI */
:root {
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-brand: 'Outfit', sans-serif;
  --font-resume: 'Times New Roman', Times, Georgia, serif;

  /* Light Theme (Google style) */
  --bg-app: #f8f9fa;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --border-color: #dadce0;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-light: #e8f0fe;
  --secondary: #3c4043;
  --accent: #e28743;
  --success: #137333;
  --success-bg: #e6f4ea;
  --warning: #b06000;
  --warning-bg: #fef7e0;
  --error: #c5221f;
  --error-bg: #fce8e6;
  --shadow: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
  --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.3);
  --scrollbar-thumb: #dadce0;
  --scrollbar-track: #f1f3f4;

  /* Resume specific parameters (default: letter, standard margins) */
  --resume-width: 8.5in;
  --resume-height: 11in;
  --resume-padding: 0.75in;
  --resume-font-size: 10pt;
  --resume-line-height: 1.45;
  --resume-margin-bottom: 12px;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-app: #121212;
  --bg-sidebar: #1e1e1e;
  --bg-card: #1e1e1e;
  --border-color: #3c4043;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #70757a;
  --primary: #8ab4f8;
  --primary-hover: #aecbfa;
  --primary-light: rgba(138, 180, 248, 0.15);
  --secondary: #e8eaed;
  --scrollbar-thumb: #5f6368;
  --scrollbar-track: #202124;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-app);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* App Header */
.app-header {
  height: 64px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 10;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand h1 {
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.brand h1 span {
  color: var(--primary);
  font-weight: 700;
}

.logo-icon {
  color: var(--primary);
  font-size: 28px;
}

.badge {
  background-color: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  margin-left: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* General Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  height: 38px;
}

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

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-secondary-outline:hover {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.btn-icon:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.btn-small {
  width: 28px;
  height: 28px;
}

.btn-full-width {
  width: 100%;
}

/* Layout Panels */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Sidebar (Editor) */
.editor-pane {
  width: 480px;
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 5;
}

/* Editor Navigation Tabs - Wrap elements so they don't hide */
.editor-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
}

.tab-link {
  flex: 1 1 22%;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-link span {
  font-size: 20px;
}

.tab-link:hover {
  color: var(--primary);
  background-color: var(--primary-light);
}

.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Tab Content Areas */
.tab-content-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.tab-panel.active {
  display: flex;
}

.panel-header {
  margin-bottom: 12px;
}

.panel-header h2 {
  font-family: var(--font-brand);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.panel-header p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Forms Styling */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235f6368'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 32px;
}

.form-control {
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.code-font {
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  line-height: 1.5;
}

/* Item cards */
.item-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
}

.bullets-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.bullet-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  position: relative;
}

.bullet-status-indicator {
  position: absolute;
  right: 44px;
  top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.bullet-status-indicator.valid {
  color: var(--success);
}

.bullet-status-indicator.invalid {
  color: var(--error);
}

.action-card {
  background-color: var(--warning-bg);
  border: 1px solid #f0e0c0;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  gap: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--warning);
}

.action-card span {
  font-size: 24px;
  flex-shrink: 0;
}

.suggestions-box {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.suggestion-chip {
  display: inline-block;
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  margin: 2px;
  cursor: pointer;
  font-weight: 500;
}

.suggestion-chip:hover {
  background-color: var(--primary);
  color: white;
}

/* Switch styling for References */
.switch-container {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.switch-slider {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background-color: var(--border-color);
  border-radius: 12px;
  margin-right: 12px;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

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

input[type="checkbox"]:checked + .switch-slider {
  background-color: var(--primary);
}

input[type="checkbox"]:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  text-transform: none;
}

.switch-compact {
  width: 36px !important;
  height: 20px !important;
  margin-right: 8px !important;
}

.switch-compact::before {
  height: 14px !important;
  width: 14px !important;
  left: 3px !important;
  bottom: 3px !important;
}

input[type="checkbox"]:checked + .switch-compact::before {
  transform: translateX(16px) !important;
}

.section-divider {
  display: flex;
  align-items: center;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 16px 0 8px 0;
}

.section-divider::after, .section-divider::before {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.section-divider::before {
  margin-right: .5em;
}

.section-divider::after {
  margin-left: .5em;
}

.hidden {
  display: none !important;
}

.error-msg {
  color: var(--error);
  background-color: var(--error-bg);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 8px;
}

/* Right Panel: CV Preview Layout */
.preview-pane {
  flex: 1;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  align-items: center;
}

.preview-controls {
  width: 100%;
  height: 48px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

.preview-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.preview-badge .dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--success);
}

.cv-page-wrapper {
  flex: 1;
  width: 100%;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
}

.cv-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 40px;
  color: var(--text-secondary);
  width: 100%;
  max-width: 400px;
  margin: auto;
}

.cv-empty-state > .material-icons-round {
  font-size: 64px;
  color: var(--border-color);
  margin-bottom: 16px;
}

.cv-empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.cv-empty-state p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* Harvard CV Styling Details (Strictly Executive) */
.harvard-cv-container {
  background-color: #ffffff;
  box-shadow: var(--shadow);
  font-family: var(--font-resume);
  color: #000000;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  text-align: justify;
  position: relative;
  transform-origin: top center;
  transition: all 0.2s;
  
  /* Apply reactive variables */
  width: var(--resume-width);
  min-height: var(--resume-height);
  padding: var(--resume-padding);
  font-size: var(--resume-font-size);
  line-height: var(--resume-line-height);
}

.harvard-cv-container a {
  color: #000000;
  text-decoration: none;
  border-bottom: 1px dotted #333333;
}

.harvard-cv-container a:hover {
  text-decoration: underline;
}

/* Page Sizes Classes */
.harvard-cv-container.size-letter {
  --resume-width: 8.5in;
  --resume-height: 11in;
}
.harvard-cv-container.size-a4 {
  --resume-width: 8.27in;
  --resume-height: 11.69in;
}
.harvard-cv-container.size-legal {
  --resume-width: 8.5in;
  --resume-height: 14in;
}

/* Margins Classes */
.harvard-cv-container.margin-standard {
  --resume-padding: 0.75in;
}
.harvard-cv-container.margin-narrow {
  --resume-padding: 0.50in;
}
.harvard-cv-container.margin-wide {
  --resume-padding: 1.00in;
}

/* Fit to page rules controlled via dynamic variables */
.harvard-cv-container.fit-densified {
  --resume-font-size: 9pt;
  --resume-line-height: 1.25;
  --resume-margin-bottom: 6px;
}
.harvard-cv-container.fit-expanded {
  --resume-font-size: 11pt;
  --resume-line-height: 1.5;
  --resume-margin-bottom: 18px;
}

/* Header Info */
.cv-header {
  text-align: center;
  margin-bottom: 18px;
}

.cv-header h1 {
  font-size: 1.6em;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  text-transform: uppercase;
  font-family: var(--font-resume);
}

.cv-header-title {
  font-size: 1.1em;
  font-weight: 500;
  font-style: italic;
  text-transform: uppercase;
  margin-top: 2px;
  margin-bottom: 6px;
  color: #333333;
  font-family: var(--font-resume);
}

.cv-contact-line {
  font-size: 0.9em;
  color: #333333;
  margin-top: 4px;
}

/* Section Separator */
.cv-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.cv-section-title {
  font-size: 1.05em;
  font-weight: 700;
  letter-spacing: 1.5px;
  border-bottom: 1.5px solid #000000;
  padding-bottom: 3px;
  text-transform: uppercase;
  margin-bottom: 10px;
  font-family: var(--font-resume);
}

.cv-bio-content {
  font-size: 1.0em;
  line-height: var(--resume-line-height);
  text-justify: inter-word;
}

.cv-keywords-line {
  font-size: 0.9em;
  color: #444;
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: 0.3px;
}

.cv-section-keywords {
  font-size: 0.9em;
  color: #444;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

/* Experience & Education Layout */
.cv-exp-item, .cv-edu-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.cv-item-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}

.cv-exp-group, .cv-edu-group {
  margin-bottom: 14px;
}

.cv-item-subheader {
  display: flex;
  justify-content: space-between;
  font-style: italic;
  color: #222222;
}

.cv-bullets {
  margin-left: 18px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cv-bullets li {
  line-height: var(--resume-line-height);
  list-style-type: disc;
  padding-left: 2px;
  text-align: justify;
  text-justify: inter-word;
}

.cv-skills-cat-row {
  margin-bottom: 4px;
}

/* References Styling */
.cv-references-statement {
  font-style: italic;
}

.cv-ref-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 4px;
}

.cv-ref-item {
  line-height: 1.35;
}

.cv-ref-item strong {
  font-weight: 700;
  display: block;
}

/* Scrollbar Tweaks */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Hide mobile-only toggles on desktop */
.btn-mobile-preview,
.btn-view-edit-help {
  display: none;
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(32, 33, 36, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background-color: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-header span {
  font-size: 28px;
}

.modal-header h2 {
  font-family: var(--font-brand);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.modal-body p:not(:last-child) {
  margin-bottom: 12px;
}

.modal-body ul {
  margin: 8px 0 12px 0;
  padding-left: 20px;
}

.modal-body li {
  margin-bottom: 8px;
}

.inline-icon {
  font-size: 16px;
  vertical-align: middle;
  color: var(--primary);
}

.modal-footer {
  margin-top: 16px;
}

.text-primary {
  color: var(--primary);
}

/* ===== Responsive: Tablets ===== */
@media (max-width: 1024px) {
  .editor-pane {
    width: 380px;
  }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 768px) {
  .app-header {
    padding: 0 12px;
    height: 56px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .brand h1 span {
    display: none;
  }

  .logo-icon {
    font-size: 24px;
  }

  .header-actions {
    gap: 6px;
  }

  .header-actions .btn {
    padding: 6px 10px;
    height: 34px;
    gap: 4px;
    min-width: unset;
  }

  .header-actions .btn span:not(.material-icons-round) {
    display: none;
  }

  .header-actions .btn .material-icons-round {
    font-size: 20px;
  }

  .btn-mobile-preview,
  .btn-view-edit-help {
    display: flex;
  }

  .main-layout {
    flex-direction: column;
  }

  .editor-pane {
    width: 100%;
    height: calc(100vh - 56px);
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow: hidden;
  }

  /* On mobile, preview is hidden by default; user toggles to view mode */
  .preview-pane {
    display: none;
    flex: 1;
    min-height: 40vh;
  }

  .main-layout.mobile-show-preview .editor-pane {
    display: none;
  }

  .main-layout.mobile-show-preview .preview-pane {
    display: flex;
    min-height: calc(100vh - 56px);
  }

  .editor-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .editor-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-link {
    flex: 0 0 auto;
    min-width: 72px;
    padding: 8px 6px;
    font-size: 10px;
  }

  .tab-link span {
    font-size: 18px;
  }

  .tab-content-container {
    padding: 16px;
  }

  .tab-panel {
    gap: 14px;
  }

  .preview-controls {
    height: 40px;
    padding: 0 12px;
  }

  .cv-page-wrapper {
    padding: 16px 12px;
  }

  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  .item-card {
    padding: 12px;
  }

  .card-actions {
    top: 8px;
    right: 8px;
  }

  .panel-header h2 {
    font-size: 16px;
  }

  .section-divider {
    margin: 12px 0 6px 0;
  }

  .btn-full-width {
    padding: 10px 12px;
    font-size: 13px;
  }

  .bullet-input-wrapper {
    gap: 6px;
  }

  #prof-phone-prefix {
    width: 100px !important;
  }
}

/* ===== Responsive: Small phones ===== */
@media (max-width: 480px) {
  .app-header {
    height: 48px;
    padding: 0 8px;
  }

  .brand h1 {
    font-size: 14px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .btn {
    padding: 4px 6px;
    height: 30px;
  }

  .header-actions .btn span {
    font-size: 18px;
  }

  .btn-icon {
    width: 32px;
    height: 32px;
  }

  .editor-pane {
    max-height: none;
    flex: 1;
    overflow-y: auto;
  }

  .tab-link {
    min-width: 60px;
    padding: 6px 4px;
    font-size: 9px;
  }

  .tab-link span {
    font-size: 16px;
  }

  .tab-content-container {
    padding: 12px;
  }

  .cv-page-wrapper {
    padding: 12px 8px;
  }

  .preview-pane {
    min-height: 35vh;
  }

  .main-layout.mobile-show-preview .preview-pane {
    min-height: calc(100vh - 48px);
  }

  .item-card {
    padding: 10px;
  }

  .form-control {
    font-size: 13px;
    padding: 8px 10px;
  }
}

/* PDF Print styles */
@media print {
  body {
    background: none;
    color: #000;
  }
  .app-header, .editor-pane, .preview-controls {
    display: none !important;
  }
  .main-layout {
    display: block;
  }
  .preview-pane {
    background: none;
    padding: 0;
    margin: 0;
    width: 100%;
    height: auto;
    overflow: visible;
  }
  .cv-page-wrapper {
    padding: 0;
    margin: 0;
    display: block;
    overflow: visible;
  }
  .harvard-cv-container {
    box-shadow: none;
    margin: 0;
    padding: var(--resume-padding);
    width: 100%;
    transform: none !important;
  }
}
