/* ═══════════════════════════════════════════════════════════
   Resume Builder — Premium Dark-Mode Design System
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ───────────────────────── */
:root {
  --bg-primary: #0a0a12;
  --bg-secondary: #12121e;
  --bg-card: #1a1a2e;
  --bg-card-hover: #22223a;
  --bg-input: #16162a;
  --bg-input-focus: #1e1e38;

  --fg-primary: #e8e8f0;
  --fg-secondary: #a0a0c0;
  --fg-muted: #6a6a90;
  --fg-inverse: #0a0a12;

  --accent-primary: #7c5cfc;
  --accent-secondary: #5c8afc;
  --accent-gradient: linear-gradient(135deg, #7c5cfc 0%, #5c8afc 50%, #4cd6e0 100%);
  --accent-glow: rgba(124, 92, 252, 0.25);
  --accent-soft: rgba(124, 92, 252, 0.12);

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --ai-color: #f59e0b;
  --ai-gradient: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);

  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--fg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(124, 92, 252, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(92, 138, 252, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Custom Scrollbar ────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--fg-muted);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fg-secondary);
}

/* ── Layout ──────────────────────────────────────── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ── Header ──────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-title h1 {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.app-title .logo-icon {
  font-size: 1.75rem;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.header-actions {
  display: flex;
  gap: 10px;
}

.app-subtitle {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
  font-weight: 400;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.3;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-sm), 0 0 20px rgba(124, 92, 252, 0.15);
}
.btn-primary:hover {
  box-shadow: var(--shadow-md), 0 0 30px rgba(124, 92, 252, 0.3);
  transform: translateY(-1px);
}

.btn-ai {
  background: var(--ai-gradient);
  color: white;
  box-shadow: var(--shadow-sm), 0 0 20px rgba(245, 158, 11, 0.15);
}
.btn-ai:hover {
  box-shadow: var(--shadow-md), 0 0 30px rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: var(--fg-inverse);
}
.btn-success:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--fg-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--fg-primary);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Tabs ────────────────────────────────────────── */
.tabs-container {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 5px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--fg-secondary);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: white;
  background: var(--accent-primary);
  box-shadow: var(--shadow-sm), 0 0 15px rgba(124, 92, 252, 0.2);
}

.tab-btn .tab-icon {
  font-size: 1rem;
}

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg-primary);
}

.card-body {
  padding: 16px 20px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

/* ── Table/List Items ────────────────────────────── */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.item-row:hover {
  background: var(--bg-input-focus);
  border-color: var(--border-strong);
}

.item-row.inactive {
  opacity: 0.45;
}

.item-row.selected {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.item-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: 2px solid var(--border-strong);
  color: var(--fg-muted);
  flex-shrink: 0;
}

.item-toggle.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.item-toggle:hover {
  border-color: var(--accent-primary);
}

.item-content {
  min-width: 0;
}

.item-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg-primary);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-subtitle {
  font-size: 0.8rem;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.item-row:hover .item-actions {
  opacity: 1;
}

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-input);
  color: var(--fg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--danger);
  color: white;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Form Fields ─────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--fg-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus {
  background: var(--bg-input-focus);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--fg-muted);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

/* ── AI Generate Panel ───────────────────────────── */
.ai-panel {
  background: var(--bg-card);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md), 0 0 40px rgba(245, 158, 11, 0.06);
}

.ai-panel-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(239, 68, 68, 0.05));
  border-bottom: 1px solid rgba(245, 158, 11, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-panel-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--ai-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ai-panel-header .ai-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--ai-gradient);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-panel-body {
  padding: 24px;
}

.ai-panel .form-group:last-of-type {
  margin-bottom: 20px;
}

.ai-status {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
}

.ai-status.visible {
  display: block;
}

.ai-status.loading {
  background: var(--accent-soft);
  color: var(--accent-secondary);
  border: 1px solid rgba(92, 138, 252, 0.15);
}

.ai-status.success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.15);
}

.ai-status.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.15);
}

/* ── AI Results ──────────────────────────────────── */
.ai-results {
  margin-top: 20px;
  display: none;
}

.ai-results.visible {
  display: block;
}

.ai-reasoning {
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--ai-color);
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--fg-secondary);
  line-height: 1.6;
}

.ai-section {
  margin-bottom: 16px;
}

.ai-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-section-title .count {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--fg-secondary);
  margin: 3px 4px 3px 0;
  transition: all var(--transition-fast);
}

.ai-chip.selected {
  background: var(--accent-soft);
  border-color: var(--accent-primary);
  color: var(--fg-primary);
}

/* ── Loading Spinner ─────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
}

/* ── Progress Bar ────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar.active .progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ── Toast Notifications ─────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform var(--transition-base);
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  transform: translateX(0);
}

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

.toast.error {
  background: var(--danger);
  color: white;
}

.toast.info {
  background: var(--accent-primary);
  color: white;
}

/* ── Tab Content ─────────────────────────────────── */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn var(--transition-base) ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Empty State ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--fg-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ── Section specific ────────────────────────────── */
.skills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.skill-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent-secondary);
  border-radius: 99px;
  border: 1px solid rgba(124, 92, 252, 0.1);
}

.category-group {
  margin-bottom: 16px;
}

.category-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding-left: 4px;
}

/* ── Status Bar ──────────────────────────────────── */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 32px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

.status-bar .status-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

/* ── Two-column layout for AI tab ────────────────── */
.ai-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

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

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .app-container {
    padding: 16px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .tabs-container {
    gap: 2px;
    padding: 4px;
  }

  .tab-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .item-row {
    grid-template-columns: 38px 1fr auto;
    padding: 10px 12px;
  }

  .modal {
    width: 95%;
    margin: 16px;
  }
}

/* ── Utilities ───────────────────────────────────── */
.mb-0 { margin-bottom: 0; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--fg-muted); }
.text-sm { font-size: 0.82rem; }
.hidden { display: none !important; }
