/* 1. Variables & Design Tokens */
:root {
  /* Colors */
  --bg-paper: #ffffff;
  --bg-app: #f8f9fa;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --google-blue: #1a73e8;
  --google-red: #d93025;
  --google-green: #1e8e3e;
  --border-light: #dadce0;
  --border-subtle: #f1f3f4;
  
  /* Typography */
  --font-main: 'Product Sans', 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* 2. Global Reset */
* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-paper);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.5;
}

body.page-loading {
  overflow: hidden;
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(2px);
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.page-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.page-loader-inner {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.page-loader-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2.5px solid rgba(26, 115, 232, 0.2);
  border-top-color: var(--google-blue);
  animation: pageSpin 0.8s linear infinite;
}

.page-loader-text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

@keyframes pageSpin {
  to {
    transform: rotate(360deg);
  }
}

body.verify-body {
  background-color: var(--bg-paper);
}

/* 3. Reusable Components */

/* The Paper Container - used in Editor and Verify pages */
.paper-container {
  max-width: 850px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 60px 40px;
  background: var(--bg-paper);
}

.verify-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.verify-sheet {
  width: 100%;
  max-width: 760px;
  background: rgba(255, 252, 246, 0.92);
  border: 1px solid rgba(218, 220, 224, 0.8);
  box-shadow: 0 20px 60px rgba(60, 64, 67, 0.08);
  border-radius: 20px;
  padding: 42px 44px 36px;
}

.verify-paper {
  max-width: 850px;
}

.is-hidden {
  display: none !important;
}

.verify-loader {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 22px 0 8px;
}

.verify-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(26, 115, 232, 0.18);
  border-top-color: var(--google-blue);
  animation: verifySpin 0.85s linear infinite;
}

.verify-loader-text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.verify-loader-lines {
  width: min(100%, 540px);
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.verify-loader-line {
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ece9e2 20%, #f8f6f1 50%, #ece9e2 80%);
  background-size: 220% 100%;
  animation: verifyShimmer 1.4s ease infinite;
}

.verify-loader-line.short {
  width: 74%;
}

/* Toast Notification */
#toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-paper);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 2000;
  box-shadow: var(--shadow-md);
  max-width: min(92vw, 420px);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  opacity: 0;
  pointer-events: none;
}

#toast.toast-show {
  opacity: 1;
  pointer-events: auto;
}

#toast.toast-hide {
  opacity: 0;
}

#toast[data-variant="success"] {
  background: #e8f5ec;
  border-color: #b9e2c5;
  color: #196d35;
}

#toast[data-variant="danger"] {
  background: #fdeceb;
  border-color: #f1c5c1;
  color: #b3261e;
}

#toast[data-variant="warning"] {
  background: #fff6df;
  border-color: #f2de9f;
  color: #7a5300;
}

#toast.toast-confirm {
  border-radius: 14px;
  padding: 12px 14px;
  width: min(92vw, 420px);
}

#toast.toast-top-center {
  top: 16px;
  bottom: auto;
}

.toast-message {
  margin: 0;
  font-size: 14px;
}

.toast-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-action-btn {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.toast-action-btn:hover {
  border-color: #c4c7cc;
}

.toast-action-cancel {
  background: #fff;
  color: var(--text-secondary);
}

.toast-action-confirm {
  background: var(--google-blue);
  border-color: var(--google-blue);
  color: #fff;
}

.toast-action-confirm:hover {
  background: #155fbe;
  border-color: #155fbe;
}

/* SweetAlert Theme */
.swal2-popup.vi-swal-popup {
  border-radius: 14px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  font-family: var(--font-main);
}

.swal2-title.vi-swal-title {
  color: var(--text-primary);
  font-size: 1.2rem;
  font-weight: 600;
}

.swal2-html-container.vi-swal-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.swal2-popup.vi-swal-toast {
  border-radius: 999px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  background: var(--bg-paper);
  color: var(--text-primary);
  padding: 8px 14px;
  font-family: var(--font-main);
}

.swal2-popup.vi-swal-toast .swal2-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0;
}

.swal2-actions .swal2-confirm.vi-swal-confirm-btn,
.swal2-actions .swal2-cancel.vi-swal-cancel-btn {
  border-radius: 8px;
  font-family: var(--font-main);
  font-weight: 500;
  border: 1px solid transparent;
  box-shadow: none;
}

@keyframes verifySpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes verifyShimmer {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 220% 50%;
  }
}

/* Toast animations removed - toasts now appear/disappear instantly */

.verify-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.verify-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding-top: 11px;
}

.verify-score {
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 600;
}

.verify-score-line {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.verify-title {
  margin-bottom: 18px;
}

.verify-content {
  min-height: 0;
  font-size: 1.15rem;
  line-height: 1.85;
  color: #3c4043;
  white-space: pre-wrap;
  margin-bottom: 40px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border-subtle);
}

.verify-metrics {
  padding-top: 16px;
}

.verify-metrics h3 {
  margin: 0 0 26px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.verify-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.verify-metric {
  padding: 16px 18px;
  background: #fafbfc;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.verify-metric-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.verify-metric-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

@media (max-width: 900px) {
  .verify-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .verify-page {
    align-items: stretch;
  }

  .verify-sheet {
    padding: 28px 20px 24px;
    border-radius: 16px;
  }

  .verify-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .verify-score {
    font-size: 1rem;
  }

  .verify-metrics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .paper-container {
    padding: 30px 20px;
  }

  .app-header {
    height: auto;
    padding: 12px 16px;
    gap: 12px;
    flex-wrap: wrap;
  }

  .header-left,
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
}

/* Common Header Styles */
.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: white;
  z-index: 100;
}

/* Ghost Button (Your new standard) */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  padding: 8px 16px;
  border-radius: 6px;
  font-family: var(--font-main);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-ghost:hover {
  background-color: var(--bg-app);
  color: var(--text-primary);
  border-color: #bdc1c6;
}

/* Primary Action Button (Blue) */
.btn-primary {
  background-color: var(--google-blue);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-family: var(--font-main);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background-color: #1765cc;
  box-shadow: 0 1px 2px rgba(66,133,244,0.3);
}

/* Badge for Score */
.badge-score {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-high { background: #e6f4ea; color: var(--google-green); }
.badge-mid  { background: #fef7e0; color: #b06000; }
.badge-low  { background: #fce8e6; color: var(--google-red); }

/* Utilities */
.text-sub { color: var(--text-secondary); font-size: 0.9rem; }
.mt-1 { margin-top: 8px; }
.flex-center { display: flex; align-items: center; }