/* CSS Variables */
:root {
  --primary-color: #0073b1;
  --primary-hover: #005582;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --background: #f5f7fa;
  --card-background: #ffffff;
  --text-primary: #2d3748;
  --text-secondary: #718096;
  --border-color: #e2e8f0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 3rem;
}

.header h1 {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

/* Section */
.section {
  background: var(--card-background);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.hidden {
  display: none !important;
}

/* Form Styles */
.form {
  max-width: 600px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-group textarea {
  resize: vertical;
}

/* Buttons */
.btn {
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

/* Loading Section */
.loading-container {
  text-align: center;
  padding: 2rem 0;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 2rem;
}

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

.loading-container h2 {
  margin-bottom: 2rem;
  color: var(--text-primary);
}

.progress-steps {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.step {
  text-align: center;
  opacity: 0.4;
  transition: opacity 0.3s;
}

.step.active {
  opacity: 1;
}

.step-indicator {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--border-color);
  margin: 0 auto 0.5rem;
  transition: background 0.3s;
}

.step.active .step-indicator {
  background: var(--primary-color);
}

.step p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Results Section */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.results-header h2 {
  margin: 0;
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--background);
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Posts Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.post-card {
  background: var(--card-background);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  transition: all 0.3s;
  cursor: pointer;
}

.post-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

.post-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.author-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.author-avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.25rem;
}

.author-info h3 {
  font-size: 1rem;
  margin-bottom: 0.125rem;
}

.author-info p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.post-text {
  margin: 1rem 0;
  line-height: 1.6;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  gap: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.post-score {
  margin-top: 1rem;
  padding: 0.5rem;
  background: var(--background);
  border-radius: 6px;
  text-align: center;
  font-weight: 600;
}

.score-high {
  color: var(--success-color);
}

.score-medium {
  color: #ffa500;
}

.score-low {
  color: var(--text-secondary);
}

/* Hot post badge */
.hot-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(255, 107, 107, 0.2);
}

/* Engagement total metric */
.engagement-total {
  font-weight: 600;
  color: var(--primary-color);
}

/* Error Section */
.error-container {
  text-align: center;
  padding: 2rem;
}

.error-container h2 {
  color: var(--danger-color);
  margin-bottom: 1rem;
}

.error-container p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Highlighted Stat Card (Time Saved) */
.stat-highlight {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.stat-highlight .stat-value {
  color: white;
  font-size: 2.5rem;
}

.stat-highlight .stat-label {
  color: rgba(255, 255, 255, 0.9);
}

/* Section Headings */
.section-heading {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin: 2rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

/* User Inputs Display Card */
.user-inputs-card {
  background: var(--background);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.user-inputs-card .section-heading {
  margin-top: 0;
  font-size: 1.25rem;
}

.input-display-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.input-display-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-value {
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* Keywords Display Card */
.keywords-card {
  background: var(--background);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.keywords-card .section-heading {
  margin-top: 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.keyword-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-color);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  min-width: 32px;
}

.keywords-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.keyword-tag {
  background: white;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.3s;
}

.keyword-tag:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Statistics Dashboard */
.stats-dashboard {
  background: var(--background);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 2rem;
}

.stats-dashboard .section-heading {
  margin-top: 0;
  font-size: 1.25rem;
}

.time-saved-breakdown {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.breakdown-item:last-of-type {
  border-bottom: none;
}

.breakdown-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0 0.5rem 0;
  margin-top: 0.75rem;
  border-top: 2px solid var(--primary-color);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--primary-color);
}

.breakdown-label {
  color: var(--text-primary);
  font-size: 0.9375rem;
}

.breakdown-value {
  font-weight: 600;
  color: var(--primary-color);
}

/* Profiles Grid */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.profile-card {
  background: var(--card-background);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  transition: all 0.3s;
  cursor: pointer;
}

.profile-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, #005582 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-info h3 {
  font-size: 1.125rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.type-badge {
  font-size: 0.875rem;
}

.profile-headline {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--background);
  border-radius: 6px;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.detail-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.detail-text {
  color: var(--text-primary);
  font-weight: 500;
}

.profile-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.profile-score {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
}

/* No Results Message */
.no-results {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
  font-size: 1.125rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .section {
    padding: 1.5rem;
  }

  .posts-grid {
    grid-template-columns: 1fr;
  }

  .profiles-grid {
    grid-template-columns: 1fr;
  }

  .results-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .progress-steps {
    flex-direction: column;
    gap: 1rem;
  }

  .results-header {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-secondary {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1rem 0.5rem;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .section {
    padding: 1rem;
  }
}

/* ============================================================================
   HERO STATS SECTION - Phase 1 UI Polish
   ============================================================================ */

.hero-stats-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 3rem 2rem;
  margin: 2rem 0 3rem 0;
  color: white;
  box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
}

.hero-stats-title {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
  color: white;
}

.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.hero-stat-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}

.hero-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.hero-stat-primary {
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.hero-stat-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.hero-stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0.5rem 0;
}

.hero-stat-label {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  opacity: 0.95;
}

.hero-stat-sublabel {
  font-size: 0.85rem;
  opacity: 0.75;
}

.hero-processing-time {
  text-align: center;
  font-size: 1.1rem;
  opacity: 0.9;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.processing-label {
  margin-right: 0.5rem;
}

.processing-value {
  font-weight: 700;
  font-size: 1.3rem;
}

/* ============================================================================
   COLLAPSIBLE INPUTS - Less Prominent
   ============================================================================ */

.user-inputs-collapsible {
  background: #f8f9fa;
  border-radius: 8px;
  margin: 1.5rem 0;
  padding: 0;
  border: 1px solid #e9ecef;
}

.collapsible-heading {
  cursor: pointer;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #495057;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.collapsible-heading::-webkit-details-marker {
  display: none;
}

.collapse-icon {
  transition: transform 0.3s;
}

details[open] .collapse-icon {
  transform: rotate(180deg);
}

.user-inputs-collapsible .user-inputs-card {
  padding: 0 1.5rem 1.5rem 1.5rem;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* ============================================================================
   COMPACT KEYWORDS
   ============================================================================ */

.keywords-card-compact {
  margin: 1rem 0 2rem 0;
  text-align: center;
}

.keywords-card-compact .keywords-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

/* ============================================================================
   SECTION HEADINGS - More Prominent
   ============================================================================ */

.section-heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d3748;
  margin: 2.5rem 0 1.5rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid #667eea;
}

/* ============================================================================
   DETAILED BREAKDOWN - Less Prominent
   ============================================================================ */

.stats-dashboard-detailed {
  margin-top: 3rem;
  padding: 2rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.stats-dashboard-detailed .section-heading {
  font-size: 1.25rem;
  margin-top: 0;
  border-bottom: 2px solid #dee2e6;
}

/* ============================================================================
   RESPONSIVE - Hero Stats
   ============================================================================ */

@media (max-width: 768px) {
  .hero-stats-section {
    padding: 2rem 1.5rem;
  }

  .hero-stats-title {
    font-size: 1.5rem;
  }

  .hero-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .hero-stat-card {
    padding: 1rem;
  }

  .hero-stat-value {
    font-size: 2rem;
  }
  
  .hero-stat-icon {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .hero-stats-grid {
    grid-template-columns: 1fr;
  }
}
