* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #3D2B1F; /* Dark Brown */
  --primary-light: #5A4031;
  --secondary: #8C7B6C; /* Taupe */
  --accent: #C5A059; /* Gold accent */
  --success: #1B4332; /* Deep Green */
  --error: #7B1B1B; /* Deep Red */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F9F7F5; /* Bone/Off-white */
  --bg-card: #FFFFFF;
  --bg-tertiary: #F2EDE9;
  --text-primary: #1A120E;
  --text-secondary: #4A3F35;
  --text-muted: #8C7B6C;
  --border-color: #E5E1DD;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --shadow-sm: 0 2px 4px rgba(61, 43, 31, 0.05);
  --shadow-md: 0 4px 12px rgba(61, 43, 31, 0.08);
  --shadow-lg: 0 12px 32px rgba(61, 43, 31, 0.12);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, .logo-text {
  font-family: "Playfair Display", serif;
  font-weight: 700;
}

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.header {
  padding: 24px 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
}

.logo-text {
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--primary);
  text-transform: uppercase;
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.dashboard-btn:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-md);
}

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

.auth-link {
  padding: 10px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.auth-link:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}


.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

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

.header-spacer {
  width: 100px; /* Balance the header layout */
}

/* Hero */
.hero {
  padding: 80px 0 40px;
  text-align: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

/* Input Mode Toggle */
.input-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
}

.mode-btn {
  padding: 10px 20px;
  background: var(--bg-secondary);
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--primary);
  color: white;
}

.mode-btn:not(.active):hover {
  background: var(--bg-tertiary);
}

/* JD Input Containers */
.jd-input-text,
.jd-input-file,
.cv-input-text,
.cv-input-file {
  display: none;
}

.jd-input-text.active,
.jd-input-file.active,
.cv-input-text.active,
.cv-input-file.active {
  display: block;
}

/* Consistent heights */
.jd-input-text textarea,
.cv-input-text textarea,
.jd-input-file .upload-zone,
.cv-input-file .upload-zone {
  min-height: 200px;
}


.hero-content {
  max-width: 700px;
  margin: 0 auto;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: 0; /* Professional sharp look */
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 32px;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 24px;
}

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

.hero-description {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
}

/* App Section */
.app-section {
  padding: 60px 0 100px;
}

.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 48px;
  box-shadow: var(--shadow-lg);
}

/* Form */
.cv-form {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

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

.form-group label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

textarea {
  width: 100%;
  height: 280px;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  transition: all var(--transition-fast);
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 4px rgba(61, 43, 31, 0.05);
}

.helper-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Upload Zone */
.upload-zone {
  position: relative;
  height: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  overflow: hidden;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--bg-tertiary);
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 100%;
  padding: 20px;
}

.upload-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upload-main {
  color: var(--primary);
  font-weight: 600;
  font-size: 1rem;
}

.browse-link {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.upload-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-info {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  padding: 24px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.file-info.active {
  display: flex;
}

.file-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  word-break: break-all;
}

.remove-file {
  background: transparent;
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all var(--transition-fast);
}

.remove-file:hover {
  border-color: var(--error);
  color: var(--error);
  background: #fff5f5;
}

/* Options Section */
.options-section {
  border-top: 1px solid var(--border-color);
  padding-top: 40px;
}

.options-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 60px;
}

@media (max-width: 768px) {
  .options-row {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.option-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-primary);
  user-select: none;
}

.checkbox-item input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  height: 18px;
  width: 18px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  transition: all var(--transition-fast);
}

.checkbox-item:hover input ~ .checkmark {
  border-color: var(--primary);
}

.checkbox-item input:checked ~ .checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-item input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-item .checkmark:after {
  left: 6px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Format Toggle */
.format-toggle {
  display: flex;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.format-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-radius: 2px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.format-btn.active {
  background: var(--primary);
  color: white;
}

/* Submit Button */
.submit-btn {
  width: 100%;
  padding: 24px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 8px;
}

.submit-btn:hover {
  background: var(--primary-light);
  box-shadow: 0 8px 24px rgba(61, 43, 31, 0.15);
}

.submit-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

.btn-content,
.btn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.btn-loading {
  display: none;
}

.submit-btn.loading .btn-content {
  display: none;
}

.submit-btn.loading .btn-loading {
  display: flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Generating Overlay */
.generating-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.generating-overlay.active {
  display: flex;
}

.loading-box {
  max-width: 400px;
  width: 100%;
}

.loading-logo {
  font-family: var(--font-header);
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 24px;
  animation: pulseLogo 2s infinite ease-in-out;
}

@keyframes pulseLogo {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.98); }
}

.loading-status {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  height: 1.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 40px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.5s ease;
  animation: progressPulse 4s infinite linear;
}

@keyframes progressPulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

.loading-tips {
  padding: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.tip-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

.tip-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Results Section */
.results-section {
  display: none;
  margin-top: 80px;
  padding-top: 60px;
  border-top: 2px solid var(--primary);
}

.results-section.active {
  display: block;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 48px;
  flex-wrap: wrap;
  gap: 24px;
}

.results-title {
  text-align: left;
}

.results-header h3 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 12px;
}

.results-header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.format-selector {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.format-selector .option-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 48px;
}

@media (max-width: 900px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
}

.result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.result-card h4 {
  font-size: 1.25rem;
  color: var(--primary);
  margin-bottom: 12px;
}

.result-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.preview-btn {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.download-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.download-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(197, 160, 89, 0.3);
}

.preview-content,
.editor-container {
  display: none;
}

.preview-content.active,
.editor-container.active {
  display: block;
}

.preview-content {
  margin-top: 24px;
  padding: 32px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.85rem;
  color: #000;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.document-editor {
  width: 100%;
  height: 450px;
  padding: 24px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  margin-top: 24px;
  transition: all var(--transition-fast);
  box-shadow: inset 0 2px 4px rgba(61, 43, 31, 0.03);
}

.document-editor:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 2px 4px rgba(61, 43, 31, 0.03), 0 0 0 4px rgba(61, 43, 31, 0.05);
}

.editor-hint {
  display: none;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: left;
}

.editor-container.active ~ .editor-hint,
.preview-content.active + .cv-hint {
  display: block;
}

/* Adjust result card for editor */
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 48px;
}

#cvCard, #coverLetterCard, #emailCard {
  max-width: none;
  width: 100%;
}

@media (max-width: 1100px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
}

/* Reset Button */
.reset-btn {
  width: auto;
  display: block;
  margin: 0 auto;
  padding: 14px 40px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

/* Footer */
.footer {
  padding: 40px 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 16px 32px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: 1000;
  font-weight: 600;
}

.toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.toast.success {
  background: var(--success);
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 0;
}

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

/* Usage Counter */
.usage-counter {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.upgrade-link {
    display: block;
    margin-top: 0.5rem;
    color: #3d2b1f;
    font-weight: 700;
    text-decoration: underline;
}

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