/* ============================================
   SEO AUDIT TOOL — DESIGN SYSTEM & STYLES
   ============================================ */

/* --- CSS Variables --- */
:root {
  --primary: #1E73BE;
  --primary-hover: #0A58CA;
  --text: #1A1A1A;
  --text-secondary: #6B7280;
  --bg: #FFFFFF;
  --bg-alt: #F8F9FA;
  --success: #28A745;
  --warning: #FFC107;
  --danger: #DC3545;
  --border: #E5E7EB;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
  --transition: 0.25s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Reset & Base --- */
.seo-audit-tool-wrapper *,
.seo-audit-tool-wrapper *::before,
.seo-audit-tool-wrapper *::after {
  box-sizing: border-box;
}

.seo-audit-tool-wrapper {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-align: left;
}

.seo-audit-tool-wrapper .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.seo-audit-tool-wrapper h1,
.seo-audit-tool-wrapper h2,
.seo-audit-tool-wrapper h3 {
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}

.seo-audit-tool-wrapper p {
  margin: 0;
}

.seo-audit-tool-wrapper .text-primary {
  color: var(--primary);
}

/* --- HERO SECTION --- */
.hero {
  background: var(--bg);
  padding: 80px 0 60px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

.seo-audit-tool-wrapper .hero .container {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
}

.seo-audit-tool-wrapper .hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  margin-bottom: 16px;
  text-align: center !important;
  width: 100% !important;
}

.seo-audit-tool-wrapper .hero-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 560px;
  width: 100% !important;
  margin: 0 auto 36px auto !important;
  text-align: center !important;
  float: none !important;
  display: block !important;
}

/* Input Group */
.input-group {
  display: flex;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto 32px;
}

.input-wrapper {
  flex: 1;
  position: relative;
}

.seo-audit-tool-wrapper .input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  pointer-events: none;
  box-sizing: content-box;
}

#urlInput {
  width: 100%;
  padding: 14px 16px 14px 46px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

#urlInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 115, 190, 0.15);
}

#urlInput::placeholder {
  color: #9CA3AF;
}

#analyzeBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

#analyzeBtn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 115, 190, 0.3);
}

#analyzeBtn:active {
  transform: translateY(0);
}

#analyzeBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Hero Stats */
.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.hero-stats strong {
  color: var(--text);
  font-weight: 700;
}

.stat-divider {
  width: 4px;
  height: 4px;
  background: var(--border);
  border-radius: 50%;
}

/* --- LOADING OVERLAY --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.loading-card {
  text-align: center;
  padding: 48px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

.loading-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.loading-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.loading-progress-bar {
  width: 260px;
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 100px;
  transition: width 0.5s ease;
}

/* --- ERROR MESSAGE --- */
.error-message {
  padding: 24px 0;
}

.error-card {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.error-card svg {
  color: var(--danger);
  margin-bottom: 16px;
}

.error-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.error-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.btn-secondary {
  display: inline-block;
  padding: 10px 24px;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: var(--border);
}

/* --- RESULTS SECTION --- */
.results-section {
  padding: 48px 0 60px;
  background: var(--bg-alt);
  animation: fadeIn 0.5s ease;
}

/* --- SCORE CARD --- */
.score-card {
  display: flex;
  align-items: center;
  gap: 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}

.score-visual {
  position: relative;
  flex-shrink: 0;
}

.score-ring {
  width: 160px;
  height: 160px;
}

.score-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.score-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 534;
  stroke-dashoffset: 534;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 1.5s ease, stroke 0.5s ease;
}

.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.score-value span {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.score-value small {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
}

.score-details {
  flex: 1;
}

.score-label {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.score-url {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  word-break: break-all;
}

.score-breakdown {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.breakdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- AUDIT CARDS --- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.audit-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.audit-card:hover {
  box-shadow: var(--shadow-md);
}

.audit-card-wide {
  grid-column: 1 / -1;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.card-header:hover {
  background: var(--bg-alt);
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon svg {
  width: 20px;
  height: 20px;
}

.card-icon-blue {
  background: rgba(30, 115, 190, 0.1);
  color: var(--primary);
}

.card-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-score {
  font-size: 14px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 100px;
  background: var(--bg-alt);
}

.chevron {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  transition: transform var(--transition);
}

.audit-card.expanded .chevron {
  transform: rotate(180deg);
}

.card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.audit-card.expanded .card-body {
  max-height: 1000px;
}

/* Checks List */
.checks-list {
  padding: 0 24px 24px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.check-item:last-child {
  border-bottom: none;
}

.check-status {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.check-status svg {
  width: 12px;
  height: 12px;
}

.check-pass {
  background: rgba(40, 167, 69, 0.1);
  color: var(--success);
}

.check-warn {
  background: rgba(255, 193, 7, 0.1);
  color: var(--warning);
}

.check-fail {
  background: rgba(220, 53, 69, 0.1);
  color: var(--danger);
}

.check-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}

.check-info p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Speed Metrics */
.speed-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 0 24px 24px;
}

.speed-metric {
  padding: 20px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  text-align: center;
}

.speed-metric-value {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.speed-metric-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.speed-metric-bar {
  height: 4px;
  background: var(--border);
  border-radius: 100px;
  margin-top: 12px;
  overflow: hidden;
}

.speed-metric-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 1s ease;
}

/* --- ISSUES SECTION --- */
.issues-section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}

.issues-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.issue-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.issue-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.issue-group-header h3 {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.issue-count {
  font-size: 13px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 100px;
}

.issue-critical .issue-group-header {
  color: var(--danger);
}

.issue-critical .issue-count {
  background: rgba(220, 53, 69, 0.1);
  color: var(--danger);
}

.issue-warning .issue-group-header {
  color: var(--warning);
}

.issue-warning .issue-count {
  background: rgba(255, 193, 7, 0.15);
  color: #B8860B;
}

.issue-passed .issue-group-header {
  color: var(--success);
}

.issue-passed .issue-count {
  background: rgba(40, 167, 69, 0.1);
  color: var(--success);
}

.issue-group ul {
  list-style: none;
  padding: 12px 20px;
}

.issue-group li {
  padding: 8px 0;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--bg-alt);
  line-height: 1.5;
}

.issue-group li:last-child {
  border-bottom: none;
}

/* --- CTA SECTION --- */
.cta-section {
  margin-bottom: 20px;
}

.cta-card {
  background: var(--bg);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
}

.cta-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 10px;
}

.cta-card p {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 500px;
  margin: 0 auto 28px;
}

.cta-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  padding: 14px 32px;
  background: var(--primary);
  color: #ffffff !important;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.btn-cta:hover {
  background: var(--primary-hover);
  color: #ffffff !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(30, 115, 190, 0.25);
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--success);
  color: #ffffff !important;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.btn-whatsapp:hover {
  background: #1e7e34;
  color: #ffffff !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(40, 167, 69, 0.25);
}

.pdf-export-container {
  display: flex;
  justify-content: center;
  width: 100%;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: #ffffff;
  color: var(--text) !important;
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: all var(--transition);
  cursor: pointer;
}

.btn-secondary:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: var(--primary) !important;
}

.btn-secondary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* --- PDF EXPORT OVERRIDES --- */
.hidden-on-web,
.pdf-branding-header {
  display: none !important;
}
.pdf-export-mode {
  padding: 0 !important;
  margin: 0 !important;
}

.pdf-export-mode .pdf-branding-header {
  display: block !important;
  text-align: center;
  margin: 0 0 10px 0;
  padding: 10px;
  background: #f8fafc;
  border-radius: var(--radius);
  font-size: 14px;
  color: #0f172a;
}

.pdf-export-mode .pdf-branding-header a {
  color: #1e73be !important;
  font-weight: 700;
  text-decoration: underline !important;
}

.pdf-export-mode .hidden-on-web {
  display: block !important;
  text-align: center;
  margin: 0 0 10px 0;
  padding: 8px;
  background: #f8fafc;
  border-radius: var(--radius);
  font-size: 14px;
  color: #0f172a;
}

.pdf-export-mode .pdf-logo {
  display: block !important;
  margin: 0 auto 8px !important;
  max-height: 48px !important;
  width: auto !important;
  object-fit: contain !important;
}

.pdf-export-mode .hidden-on-web a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.pdf-export-mode .score-card {
  padding: 20px !important;
  margin-bottom: 15px !important;
  gap: 20px !important;
}

.pdf-export-mode .score-ring {
  width: 100px !important;
  height: 100px !important;
}

.pdf-export-mode .score-value span {
  font-size: 28px !important;
}

.pdf-export-mode .score-label {
  font-size: 18px !important;
}

.pdf-export-mode .score-url {
  margin-bottom: 10px !important;
}

.pdf-export-mode .cta-card {
  display: none !important;
}

.pdf-export-mode .results-grid {
  grid-template-columns: 1fr !important;
  gap: 15px !important;
  margin: 0 -10px !important;
}

.pdf-export-mode .audit-card {
  box-shadow: none !important;
  border: 1px solid #cbd5e1 !important;
  page-break-inside: avoid;
  break-inside: avoid;
}

.pdf-export-mode .card-header {
  padding: 12px 18px !important;
}

.pdf-export-mode .checks-list {
  padding: 0 18px 12px !important;
}

.pdf-export-mode .check-item {
  padding: 8px 0 !important;
}

.pdf-export-mode .card-subtitle {
  color: #475569 !important;
}

.pdf-export-mode h2,
.pdf-export-mode p,
.pdf-export-mode span {
  color: #0f172a;
}

.pdf-export-mode svg {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  stroke-opacity: 1 !important;
  fill-opacity: 1 !important;
}

.pdf-export-mode .card-icon svg {
  width: 24px !important;
  height: 24px !important;
}

.pdf-export-mode .status-icon svg {
  width: 20px !important;
  height: 20px !important;
}

/* --- FOOTER --- */
.footer {
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

/* --- UTILITIES --- */
.hidden {
  display: none !important;
}

/* --- ANIMATIONS --- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
  opacity: 0;
}

.fade-in-delay-1 {
  animation-delay: 0.1s;
}

.fade-in-delay-2 {
  animation-delay: 0.2s;
}

.fade-in-delay-3 {
  animation-delay: 0.3s;
}

.fade-in-delay-4 {
  animation-delay: 0.4s;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .hero {
    padding: 50px 0 40px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .hero-subtitle {
    font-size: 15px;
  }

  .input-group {
    flex-direction: column;
  }

  #analyzeBtn {
    justify-content: center;
    width: 100%;
  }

  .hero-stats {
    flex-direction: column;
    gap: 8px;
  }

  .stat-divider {
    display: none;
  }

  .score-card {
    flex-direction: column;
    text-align: center;
    padding: 32px 24px;
    gap: 24px;
  }

  .score-breakdown {
    justify-content: center;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .issues-grid {
    grid-template-columns: 1fr;
  }

  .speed-metrics {
    grid-template-columns: 1fr;
  }

  .cta-card {
    padding: 32px 20px;
  }

  .cta-card h2 {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .hero {
    padding: 40px 0 32px;
  }

  .score-ring {
    width: 130px;
    height: 130px;
  }

  .score-value span {
    font-size: 40px;
  }

  .card-header {
    padding: 16px 18px;
  }

  .checks-list {
    padding: 0 18px 18px;
  }

  .cta-buttons {
    flex-direction: column;
  }

  .btn-cta,
  .btn-whatsapp {
    width: 100%;
    justify-content: center;
  }
}