:root {
  color-scheme: dark;
  font-family: "Alan Sans", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-newsreader: "Newsreader", serif;
  --font-alan-sans: "Alan Sans", sans-serif;
  --accent-green: #84cc16; /* Lime green for positives */
  --accent-red: #ef4444; /* Red for negatives */
  --threat-high: #dc2626;
  --threat-medium: #f59e0b;
  --threat-low: #10b981;
}

body {
  min-height: 100vh;
  background: #0f172a;
  color: #e2e8f0;
}

/* Dark theme section (header) */
section:first-of-type {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.loader {
  display: inline-block;
  border: 2px solid rgba(99, 102, 241, 0.25);
  border-top-color: rgba(79, 70, 229, 1);
  border-radius: 9999px;
  animation: spin 1s linear infinite;
}

.progress-track {
  position: relative;
  height: 0.5rem;
  width: 100%;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.15);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 9999px;
  background: linear-gradient(90deg, rgba(129, 140, 248, 0.95), rgba(79, 70, 229, 1));
  transition: width 0.4s ease;
}

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

.fade-in {
  animation: fade-in 300ms ease-out forwards;
  opacity: 0;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

::-webkit-scrollbar-track {
  background: rgba(30, 41, 59, 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.5);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.7);
}

/* Tailwind scrollbar classes */
.scrollbar-thin {
  scrollbar-width: thin;
}

.scrollbar-thumb-slate-700 {
  scrollbar-color: rgba(51, 65, 85, 0.5) rgba(30, 41, 59, 0.5);
}

.scrollbar-track-slate-800 {
  scrollbar-color: rgba(51, 65, 85, 0.5) rgba(30, 41, 59, 0.5);
}

/* Sidebar Navigation Links - match competitor name styling */
.sidebar-nav-link {
  font-family: var(--font-newsreader);
  letter-spacing: -0.02em;
  transition: all 0.2s ease;
}

.sidebar-nav-link:hover {
  color: #ffffff !important;
  background-color: rgba(99, 102, 241, 0.15) !important;
  border-left: 3px solid #6366f1;
  padding-left: calc(0.75rem - 3px);
}

.sidebar-nav-link.active {
  color: #f1f5f9 !important;
  background-color: rgba(99, 102, 241, 0.2) !important;
  border-left: 3px solid #6366f1;
  padding-left: calc(0.75rem - 3px);
}

/* Competitor Sidebar Item */
.competitor-sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.competitor-sidebar-item:hover {
  background-color: rgba(51, 65, 85, 0.5);
}

.competitor-sidebar-item.active {
  background-color: rgba(99, 102, 241, 0.2);
  border-left-color: #6366f1;
  color: #c7d2fe;
}

.competitor-sidebar-item .name {
  font-size: 0.875rem;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.competitor-sidebar-item .threat-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  margin-left: 0.5rem;
  position: relative;
  cursor: default;
}

/* Threat badge tooltip — sidebar */
.competitor-sidebar-item .threat-badge[data-threat-reason]:hover::after,
.threat-level-badge[data-threat-reason]:hover::after {
  content: attr(data-threat-reason);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid rgba(71, 85, 105, 0.6);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  white-space: normal;
  width: max-content;
  max-width: 220px;
  z-index: 100;
  pointer-events: none;
}

.threat-badge.high {
  background-color: rgba(220, 38, 38, 0.2);
  color: #fca5a5;
}

.threat-badge.medium {
  background-color: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.threat-badge.low {
  background-color: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
}

/* Competitor Card */
.competitor-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.6) 100%);
  border: 1px solid rgba(71, 85, 105, 0.3);
  border-radius: 1rem;
  padding: 2rem;
  margin-bottom: 3rem;
  scroll-margin-top: 2rem;
  transition: all 0.3s ease;
}

.competitor-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid rgba(71, 85, 105, 0.2);
}

.competitor-card-info {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.competitor-logo {
  display: none;
  width: 64px;
  height: 64px;
  border-radius: 0.5rem;
  background-color: rgba(71, 85, 105, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #cbd5e1;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.competitor-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f1f5f9;
  font-family: var(--font-newsreader);
}

.competitor-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 0.5rem;
}

.metric {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-green);
  margin-top: 0.25rem;
}

.threat-level {
  text-align: right;
}

.threat-level-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
  cursor: default;
}

.threat-level-badge.high {
  background-color: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.threat-level-badge.medium {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.threat-level-badge.low {
  background-color: rgba(16, 185, 129, 0.15);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Two-Column Layout for Sections */
.competitor-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .competitor-sections {
    grid-template-columns: 1fr;
  }
}

.section-block {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(71, 85, 105, 0.2);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e2e8f0;
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--font-alan-sans);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 0.375rem;
  color: #a5b4fc;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background-color: rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.5);
}

.copy-btn.copied {
  background-color: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  border-color: rgba(16, 185, 129, 0.3);
}

.section-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #cbd5e1;
}

.section-content li {
  margin-left: 1.5rem;
  color: #cbd5e1;
}

.section-content li::marker {
  color: #64748b;
}

/* Pricing Section */
.pricing-content {
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid var(--accent-green);
  padding: 1rem;
  border-radius: 0.375rem;
  margin-top: 0.5rem;
}

.pricing-item {
  padding: 0.375rem 0;
  color: #cbd5e1;
  font-size: 0.9375rem;
  list-style: disc;
  margin-left: 1.25rem;
}

/* Section content — plain disc bullets for all item types */
ul.section-content {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0;
}

ul.section-content li {
  color: #cbd5e1;
  padding: 0.25rem 0;
  line-height: 1.5;
}

/* Company URL and description styling */
.competitor-url {
  font-size: 0.875rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.competitor-description {
  font-size: 0.875rem;
  color: #cbd5e1;
  margin-top: 0.25rem;
  line-height: 1.4;
}

/* Weakness items inherit disc bullet from ul.section-content */
.section-content .weakness {
  color: #cbd5e1;
}

/* Overview section */
.overview-text {
  color: #cbd5e1;
  line-height: 1.7;
  margin-bottom: 1rem;
}

/* Keyframes and animations */
@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: slide-up 0.5s ease-out forwards;
}

/* Modern SaaS enhancements */
h1, h2, h3 {
  font-family: var(--font-newsreader);
  font-optical-sizing: auto;
  letter-spacing: -0.02em;
  color: #f1f5f9;
}

h1 {
  font-weight: 700;
}

h2 {
  font-weight: 600;
}

h3 {
  font-weight: 600;
}

/* Enhanced link styles */
a {
  transition: color 0.2s ease, text-decoration 0.2s ease;
}

a:hover {
  text-decoration: underline;
}

/* Better focus states */
*:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Input styling */
input[type="url"],
input[type="text"],
textarea,
select {
  color: #e2e8f0;
}

input[type="url"]:focus,
input[type="text"]:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Body text styling */
body {
  font-family: var(--font-alan-sans);
  font-optical-sizing: auto;
  font-size: 1rem;
  line-height: 1.6;
}

/* PDF Download Container */
#pdf-download-container {
  text-align: center;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(71, 85, 105, 0.2);
}

/* Market snapshot styling */
.market-snapshot-section {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.2) 0%, rgba(20, 83, 138, 0.2) 100%);
  border: 1px solid rgba(100, 116, 180, 0.3);
  border-radius: 1rem;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  color: #cbd5e1;
  line-height: 1.7;
}

/* Hide old light theme competitor tabs */
.competitor-tabs-container {
  display: none;
}

.competitor-tab {
  display: none;
}

.competitor-card.light-theme {
  display: none;
}

/* Playbook result styling */
#playbook-results {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(71, 85, 105, 0.2);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

#playbook-results details {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(71, 85, 105, 0.2);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
  color: #cbd5e1;
}

#playbook-results summary {
  cursor: pointer;
  font-weight: 600;
  color: #e2e8f0;
}

#playbook-results summary:hover {
  color: #c7d2fe;
}

/* Loading state — flex-shrink-0 at bottom of start-screen flex column, always in viewport */
#loading-state {
  /* no positioning needed; the flex layout keeps it in-frame */
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  /* Reduce padding on mobile */
  body {
    padding: 0;
  }

  section {
    padding: 1rem 1rem !important;
  }

  /* Make form more mobile-friendly */
  .mx-auto.max-w-4xl {
    padding: 0 1rem;
  }

  /* Stack sidebar and main area vertically on mobile */
  #results .flex-1 {
    flex-direction: column !important;
  }

  /* Collapse sidebar to small drawer-like view on mobile */
  #competitors-sidebar {
    width: 100% !important;
    max-width: 100%;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid rgba(71, 85, 105, 0.5);
    max-height: 200px;
    overflow-x: auto;
  }

  #competitors-list {
    flex-direction: row;
    flex-wrap: wrap;
    display: flex;
    width: auto;
  }

  .competitor-sidebar-item {
    flex-shrink: 0;
    min-width: 150px;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
  }

  .competitor-sidebar-item .name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Main content area takes full width */
  main {
    width: 100% !important;
  }

  /* Responsive competitor cards */
  .competitor-card {
    min-height: auto;
  }

  .competitor-card-header {
    flex-direction: column;
    padding: 1rem !important;
  }

  .competitor-card-info {
    width: 100%;
  }

  /* Responsive grid for sections */
  .section-block {
    min-width: 100%;
  }

  .col-span-2 {
    grid-column: 1 / -1 !important;
  }

  /* Reduce font sizes on mobile */
  .section-title {
    font-size: 1rem;
  }

  .competitor-name {
    font-size: 1.1rem;
  }

  .competitor-url {
    font-size: 0.75rem;
  }

  .competitor-description {
    font-size: 0.8rem;
  }

  /* Sidebar action buttons */
  #download-pdf-btn-sidebar,
  #expand-playbook-btn-sidebar {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem !important;
  }

  /* Make progress track and loading section mobile-friendly */
  #loading-state {
    padding: 1rem 0.5rem !important;
  }

  .progress-track {
    height: 0.375rem;
  }

  /* Adjust pricing section for mobile */
  .pricing-content {
    padding: 0.75rem;
    border-left-width: 2px;
  }

  .pricing-item {
    padding: 0.375rem 0;
    font-size: 0.875rem;
  }

  /* Adjust metric badges */
  .metric {
    flex-wrap: wrap;
    font-size: 0.75rem;
  }

  .metric-label {
    min-width: 100%;
  }

  .metric-value {
    min-width: 100%;
  }

  /* Market overview and company panel text adjustments */
  .market-snapshot-section {
    padding: 1rem 1rem !important;
    font-size: 0.95rem;
  }

  /* Scrollbar styles for mobile */
  #competitors-list {
    scrollbar-width: thin;
  }

  /* Threat badge sizing */
  .threat-badge {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
  }
}

@media (max-width: 480px) {
  /* Extra small devices */

  section {
    padding: 0.75rem !important;
  }

  .mx-auto.max-w-4xl {
    padding: 0 0.75rem;
  }

  #competitors-sidebar {
    max-height: 150px;
  }

  .competitor-sidebar-item {
    min-width: 120px;
    padding: 0.5rem 0.5rem !important;
  }

  .section-title {
    font-size: 0.95rem;
  }

  .competitor-name {
    font-size: 1rem;
  }

  /* Stack threat level below name on very small screens */
  .competitor-sidebar-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .threat-badge {
    font-size: 0.6rem;
    margin-top: 0.25rem;
  }

  input[type="url"],
  input[type="text"],
  button {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }

  /* Reduce padding on form inputs */
  form {
    gap: 0.75rem;
  }
}
