/* Apple-inspired global design system */
:root {
  --bg: #f5f7fb;
  --card-bg: #ffffff;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --border: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --radius-lg: 16px;
  --shadow-card: 0 10px 25px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 12px 30px rgba(15, 23, 42, 0.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", sans-serif;
  --neutral: #cbd5e1;      /* soft gray */
  --warning: #fbbf24;      /* amber */
  --danger:  #ef4444;      /* red */
  --success: #22c55e;      /* green */
}

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

body {
  background: linear-gradient(180deg, #f3f6fb 0%, #e7ebf2 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  backdrop-filter: blur(18px);
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: all 0.3s ease;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  flex-wrap: wrap;
  gap: 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: radial-gradient(circle at 20% 20%, #eff6ff 0, #1d4ed8 50%, #0f172a 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
}

.logo-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.logo-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Navigation */
.main-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link {
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: rgba(241, 245, 249, 0.9);
  color: var(--text-main);
}

.nav-link.active {
  background: #eef2ff;
  color: var(--accent-dark);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 80px 0 60px;
}

.hero-heading {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.hero-subtext {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  justify-content: center;   /* ✅ centers grid within container */
  justify-items: center;     /* ✅ centers each card */
  gap: 24px;
  margin-top: 40px;
}

@media (min-width: 1024px) {
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}

/* Fix meta grid responsiveness */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  font-size: 0.9rem;
  margin-bottom: 8px;
  word-break: break-word;
}

/* Make long session IDs wrap */
.meta-grid span {
  word-break: break-all;
}

/* Ensure Study Plan card full width */
#studyPlanCard {
  grid-column: 1 / -1;
  padding-bottom: 28px;
}

/* Small screen adjustments */
@media (max-width: 600px) {
  .card {
    padding: 16px;
  }

  .btn {
    font-size: 0.85rem;
  }

  .hero-heading {
    font-size: 1.6rem;
  }
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.card-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.5);
  transform: translateY(-2px);
}

.btn-secondary {
  background: #eef2ff;
  color: #1d4ed8;
  box-shadow: none;
}

.btn-secondary:hover {
  background: #e0e7ff;
  transform: translateY(-2px);
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.card-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.card-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neutral);
  transition: background 0.25s;
}

.card-status.loading::before {
  background: var(--warning);
  animation: pulse 1.2s infinite;
}

.card-status.error::before {
  background: var(--danger);
}

.card-status.success::before {
  background: var(--success);
}

.card-status.loading::before {
  background: var(--warning);
  animation: pulseFade 1.4s ease-in-out infinite;
}

.card-status.success::before,
.card-status.error::before {
  animation: fadePop 0.6s ease;
}

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

@keyframes fadePop {
  0% { opacity: 0; transform: scale(0.8); }
  60% { opacity: 1; transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.6;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

.card p,
.card div {
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.question-text {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 6px;
}

.card h4 {
  margin-top: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.study-block {
  margin-bottom: 1.4rem;
}

.history-item {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-subtle);
  margin-bottom: 8px;
}

.history-item:hover {
  background: var(--bg-hover);
}

.meta-grid div {
  word-break: break-all;
}

/* Overlay covers entire viewport */
.global-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

/* Visible when active */
.global-overlay.active {
  display: flex;
}

/* Simple Apple-like spinner */
.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #007aff;
  /* iOS blue accent */
  animation: spin 1s linear infinite;
}

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

/* Improve bullet list spacing inside cards */
.card ul.list {
  padding-left: 22px;
  margin-top: 6px;
  margin-bottom: 10px;
}

.card ul.list li {
  line-height: 1.5;
  margin-bottom: 4px;
}

/* Study Plan block typography */
.study-block h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.study-block {
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}

.study-block .list,
.study-block .tag-row,
.study-block .question-text {
  color: var(--text-main);
}

/* Center the home page cards under the hero text */
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 60px;
}

.home-hero .cards {
  display: flex;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 40px;
   /* max-width: 800px;  prevents overexpansion on large screens */
}

.home-hero .card {
  flex: 1 1 280px;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.home-hero .card .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  border-radius: 999px;
  font-weight: 600;

  flex: 0 0 auto;      /* <- critical: stops vertical stretching */
  align-self: stretch; /* <- keeps full width */
  margin-top: auto;
}

/* Ensure primary/secondary buttons share same vertical rhythm */
.home-hero .card .btn-primary,
.home-hero .card .btn-secondary {
  min-height: 52px;
}

.upload-feedback {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.resume-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 32px;
  align-items: stretch;
}

/* Upload form layout */
.upload-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 0;
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-form:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.08);
}

.upload-form label {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.upload-form label:hover {
  background: var(--accent-dark);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

.upload-form input[type="file"] {
  display: none; /* Hide default ugly file input */
}

.upload-form small {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 6px;
}

.upload-form .btn {
  width: auto;
  padding: 8px 18px;
  font-size: 0.85rem;
}

.container {
  max-width: 1200px;
}

.feedback-box {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 12px;
  padding: 10px;
  border: 1px solid var(--border);
}

/* === Resume Assistant Refinements === */

/* Center upload and resume cards under hero */
.resume-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  margin-top: 20px;
  animation: fadeInPage 0.8s ease forwards;
  opacity: 0;
  transform: translateY(10px);
}

@keyframes fadeInPage {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Upload card prominence */
.card.upload-card {
  border: 1px solid rgba(37, 99, 235, 0.15);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.08);
  background: rgba(255, 255, 255, 0.96);
}

/* Compact status indicators for Upload + Analysis */
.card-status {
  position: relative;
  top: 2px;
}
.card-status.loading::before {
  background: var(--warning);
}
.card-status.success::before {
  background: var(--success);
}
.card-status.error::before {
  background: var(--danger);
}

/* Better spacing inside feedback and analysis boxes */
.feedback-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03);
}

/* Improve spacing for bullet lists */
.feedback-box ul {
  padding-left: 22px;
  margin-top: 6px;
}
.feedback-box li {
  margin-bottom: 6px;
  line-height: 1.5;
}

.feedback-box.appear {
  animation: slideUp 0.6s ease forwards;
  opacity: 0;
  transform: translateY(10px);
}

@keyframes slideUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.feedback-header p {
  margin: 0;
  flex: 1;
}

.feedback-header .btn {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Ensure uniform card sizing across grid */
.resume-grid .card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: 100%;
}

.analysis-output {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 6px;
  word-break: break-word;
  transition: all 0.3s ease;
}

.resume-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.resume-section h4 {
  margin-bottom: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.resume-section ul {
  margin-left: 16px;
  list-style: disc;
}

.resume-section p,
.resume-section li {
  line-height: 1.45;
  color: var(--text-muted);
}

.results-section {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-top: 32px;
}

#improvedBulletsCard,
#tailoredCard {
  display: none;
}
#improvedBulletsCard.active,
#tailoredCard.active {
  display: block;
  animation: fadeInPage 0.6s ease forwards;
}

.bullet-list.small li {
  line-height: 1.55;
  margin-bottom: 6px;
  color: var(--text-main);
}

#analysisOutput {
  min-height: 640px; /* keeps the right card in sync with the left */
}