// ==========================================================================
// Monitor.Cat — SEO & GEO Module Page
// ==========================================================================

@use 'tokens' as *;

.monitorcat-wrap {
  // ---------------------------------------------------------------------------
  // Page header with actions
  // ---------------------------------------------------------------------------
  .mc-seo-page .mc-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .mc-page-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .mc-seo-post-switcher {
    .mc-select-sm {
      padding: 8px 32px 8px 12px;
      font-size: 0.8125rem;
      min-width: 180px;
    }

    .mc-dropdown-trigger {
      min-width: 180px;
    }
  }

  // ---------------------------------------------------------------------------
  // Section layout (Site Health + Page Analysis)
  // ---------------------------------------------------------------------------
  .mc-seo-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;

    & + .mc-seo-section {
      border-top: 2px solid $mc-base-alt;
      padding-top: 1.5rem;
    }
  }

  .mc-seo-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;

    h2 {
      margin: 0;
    }

    p {
      margin: 0;
    }
  }

  .mc-seo-page-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .mc-pedestal-xs {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }

  // ---------------------------------------------------------------------------
  // Inline loading (for site health)
  // ---------------------------------------------------------------------------
  .mc-seo-inline-loading {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem 1.25rem;
    background: $mc-white;
    border: 1px solid $mc-border-color;
    border-radius: $mc-radius-card;
    font-size: 0.875rem;
    color: $mc-text-medium;

    i {
      color: $mc-primary;
    }
  }

  // ---------------------------------------------------------------------------
  // Deeplink tooltip
  // ---------------------------------------------------------------------------
  .mc-seo-post-switcher-wrap {
    position: relative;
  }

  .mc-seo-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: $mc-primary-light;
    border: 2px solid $mc-primary;
    border-radius: $mc-radius-card;
    box-shadow: $mc-shadow-card;
    font-size: 0.8125rem;
    color: $mc-text;
    line-height: 1.55;
    width: 460px;
    max-width: calc(100vw - 2rem);
    animation: mc-tooltip-appear 0.35s $mc-ease-spring;

    &::before {
      content: '';
      position: absolute;
      top: -7px;
      right: 24px;
      width: 12px;
      height: 12px;
      background: $mc-primary-light;
      border-left: 2px solid $mc-primary;
      border-top: 2px solid $mc-primary;
      transform: rotate(45deg);
    }
  }

  .mc-seo-tooltip-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: $mc-primary;
    border-radius: 50%;
    color: $mc-white;
    font-size: 0.875rem;
  }

  .mc-seo-tooltip-body {
    flex: 1;
    color: $mc-text-medium;

    strong {
      display: block;
      margin-bottom: 2px;
      color: $mc-text;
      font-size: 0.875rem;
    }
  }

  .mc-seo-tooltip-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: $mc-text-light;
    font-size: 0.8rem;
    transition: color $mc-transition-base;

    &:hover {
      color: $mc-text;
    }
  }

  @keyframes mc-tooltip-appear {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  // ---------------------------------------------------------------------------
  // Loading state
  // ---------------------------------------------------------------------------
  .mc-seo-loading-card {
    text-align: center;
    padding: 3rem 2rem;

    h2 {
      margin-top: 1.25rem;
      margin-bottom: 0.5rem;
    }
  }

  .mc-seo-loading-steps {
    list-style: none;
    padding: 0;
    margin: 1.5rem auto 0;
    max-width: 360px;
    text-align: left;
  }

  .mc-seo-loading-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: $mc-text-light;
    transition: color 0.3s $mc-ease-spring, opacity 0.3s $mc-ease-spring;

    &.is-active {
      color: $mc-text;
      font-weight: 500;
    }

    &.is-done {
      color: $mc-mint-strong;
    }

    i {
      width: 20px;
      text-align: center;
      flex-shrink: 0;
    }
  }

  // ---------------------------------------------------------------------------
  // Hero score card
  // ---------------------------------------------------------------------------
  .mc-seo-hero {
    margin-bottom: 1.5rem;
    background: $mc-white;
    overflow: hidden;
  }

  .mc-seo-hero-content {
    display: flex;
    align-items: center;
    gap: 2rem;
  }

  .mc-seo-hero-ring {
    flex-shrink: 0;
  }

  .mc-seo-hero-info {
    flex: 1;
    min-width: 0;

    h2 {
      font-family: $mc-font-heading;
      font-size: 1.25rem;
      font-weight: 600;
      color: $mc-text;
      margin: 0 0 0.25rem 0;
    }

    p {
      margin: 0 0 0.75rem 0;
    }
  }

  .mc-seo-hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  // ---------------------------------------------------------------------------
  // Score color helpers
  // ---------------------------------------------------------------------------
  .mc-text-good {
    color: $mc-mint-strong;
    font-weight: 700;
    font-family: $mc-font-heading;
    font-size: 1.125rem;
  }

  .mc-text-ok {
    color: $mc-primary;
    font-weight: 700;
    font-family: $mc-font-heading;
    font-size: 1.125rem;
  }

  .mc-text-bad {
    color: $mc-coral-strong;
    font-weight: 700;
    font-family: $mc-font-heading;
    font-size: 1.125rem;
  }

  // ---------------------------------------------------------------------------
  // Active Protections banner
  // ---------------------------------------------------------------------------
  .mc-seo-protections {
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
  }

  .mc-seo-protections-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    font-size: 0.8125rem;
    color: $mc-mint-strong;

    i {
      font-size: 1rem;
    }
  }

  .mc-seo-protections-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .mc-seo-protection-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: $mc-text-medium;
    padding: 4px 10px;
    background: $mc-base;
    border-radius: $mc-radius-pill;

    i {
      font-size: 0.75rem;
    }
  }

  // ---------------------------------------------------------------------------
  // Google SERP Preview
  // ---------------------------------------------------------------------------
  .mc-seo-serp-card {
    margin-bottom: 1.5rem;
    padding: 1.25rem;
  }

  .mc-seo-serp-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: $mc-text-light;
    margin-bottom: 0.75rem;
  }

  .mc-seo-serp-preview {
    background: $mc-white;
    border: 1px solid $mc-border-color;
    border-radius: $mc-radius-inset;
    padding: 1rem 1.25rem;
    box-shadow: $mc-shadow-inset;
  }

  .mc-seo-serp-url {
    font-size: 0.8125rem;
    color: $mc-mint-strong;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mc-seo-serp-title {
    font-size: 1.125rem;
    font-weight: 500;
    color: #1a0dab;
    line-height: 1.3;
    margin-bottom: 4px;
    cursor: pointer;

    &:hover {
      text-decoration: underline;
    }
  }

  .mc-seo-serp-desc {
    font-size: 0.875rem;
    color: $mc-text-medium;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  // ---------------------------------------------------------------------------
  // GEO intro banner
  // ---------------------------------------------------------------------------
  .mc-seo-geo-intro {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, rgba($mc-lavender, 0.06) 0%, rgba($mc-cyan, 0.06) 100%);
    border-left: 3px solid $mc-lavender;

    h3 {
      font-family: $mc-font-heading;
      font-size: 0.9375rem;
      font-weight: 600;
      color: $mc-text;
      margin: 0 0 0.25rem 0;
    }

    p {
      font-size: 0.8125rem;
      color: $mc-text-medium;
      line-height: 1.6;
      margin: 0;
    }
  }

  .mc-seo-geo-intro-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba($mc-lavender, 0.12);
    border-radius: $mc-radius-inset;
    font-size: 1.125rem;
  }

  .mc-seo-geo-intro-content {
    flex: 1;
    min-width: 0;
  }

  // ---------------------------------------------------------------------------
  // Card stagger animation
  // ---------------------------------------------------------------------------
  .mc-seo-check-card {
    opacity: 0;
    transform: translateY(12px);
    animation: mc-card-appear 0.4s $mc-ease-spring forwards;
  }

  @for $i from 1 through 10 {
    .mc-seo-category-grid .mc-seo-check-card:nth-child(#{$i + 1}) {
      animation-delay: #{$i * 80}ms;
    }
  }

  @keyframes mc-card-appear {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  // ---------------------------------------------------------------------------
  // Tab styling
  // ---------------------------------------------------------------------------
  .mc-seo-tabs {
    margin-bottom: 2rem;
  }

  .mc-tab-bar {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid $mc-base-alt;
    padding-bottom: 0;
  }

  .mc-tab {
    padding: 0.75rem 1.25rem;
    font-family: $mc-font-body;
    font-size: 0.875rem;
    font-weight: 500;
    color: $mc-text-light;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color $mc-transition-base, border-color $mc-transition-base;

    &:hover {
      color: $mc-text;
    }

    &.is-active {
      color: $mc-primary;
      border-bottom-color: $mc-primary;
      font-weight: 600;
    }
  }

  .mc-tab-panel {
    display: none;

    &.is-active {
      display: block;
    }
  }

  // ---------------------------------------------------------------------------
  // Tab count badges
  // ---------------------------------------------------------------------------
  .mc-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0 6px;
    margin-left: 4px;
    vertical-align: middle;
  }

  .mc-tab-count-warning {
    background: $mc-primary-light;
    color: $mc-primary-hover;
  }

  .mc-tab-count-error {
    background: $mc-coral-light;
    color: $mc-coral-strong;
  }

  // ---------------------------------------------------------------------------
  // Tab summary line
  // ---------------------------------------------------------------------------
  .mc-seo-tab-summary {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
  }

  // ---------------------------------------------------------------------------
  // Category card grid
  // ---------------------------------------------------------------------------
  .mc-seo-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.25rem;
  }

  // ---------------------------------------------------------------------------
  // Individual check card
  // ---------------------------------------------------------------------------
  .mc-seo-check-card {
    padding: 1.25rem;
    transition: transform $mc-transition-base, box-shadow $mc-transition-base;

    &:hover {
      transform: translateY(-2px);
      box-shadow: $mc-shadow-card-hover;
    }
  }

  .mc-seo-check-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .mc-seo-check-header-info {
    flex: 1;
    min-width: 0;

    .mc-heading-sm {
      margin: 0 0 0.25rem 0;
    }
  }

  .mc-seo-check-score {
    flex-shrink: 0;
    font-family: $mc-font-heading;
    font-weight: 700;
  }

  .mc-seo-check-progress {
    margin-bottom: 1rem;
  }

  // ---------------------------------------------------------------------------
  // Checklist items
  // ---------------------------------------------------------------------------
  .mc-seo-checklist {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .mc-seo-check-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid $mc-border-color;

    &:last-child {
      border-bottom: none;
      padding-bottom: 0;
    }

    &:first-child {
      padding-top: 0;
    }
  }

  .mc-seo-check-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.6875rem;

    &.is-pass {
      background: $mc-mint-light;
      color: $mc-mint-strong;
    }

    &.is-fail {
      background: $mc-coral-light;
      color: $mc-coral-strong;
    }

    &.is-warn {
      background: $mc-primary-light;
      color: $mc-primary-hover;
    }
  }

  .mc-seo-check-content {
    flex: 1;
    min-width: 0;
  }

  .mc-seo-check-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: $mc-text;
    margin-bottom: 0.125rem;
  }

  .mc-seo-check-desc {
    font-size: 0.8125rem;
    color: $mc-text-medium;
    line-height: 1.5;
  }

  .mc-seo-check-value {
    font-size: 0.75rem;
    color: $mc-text-light;
    font-family: monospace;
    margin-top: 0.25rem;
    padding: 2px 8px;
    background: $mc-base;
    border-radius: 4px;
    display: inline-block;
  }

  // ---------------------------------------------------------------------------
  // Fixable check items (clickable with expand panel)
  // ---------------------------------------------------------------------------
  .mc-seo-check-item.is-fixable {
    cursor: pointer;
    border-radius: $mc-radius-inset;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    margin: 0 -0.5rem;
    transition: background $mc-transition-base;

    &:hover {
      background: rgba($mc-primary, 0.04);
    }
  }

  .mc-seo-check-chevron {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: $mc-text-light;
    font-size: 0.625rem;
    transition: transform 0.3s $mc-ease-spring, color $mc-transition-base;

    .is-fixable:hover & {
      color: $mc-primary;
    }

    .is-expanded & {
      transform: rotate(180deg);
    }
  }

  .mc-seo-fix-panel {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s $mc-ease-spring, opacity 0.25s ease, margin 0.25s ease;
    margin-top: 0;

    .is-expanded & {
      max-height: 200px;
      opacity: 1;
      margin-top: 0.5rem;
    }
  }

  .mc-seo-fix-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: linear-gradient(135deg, rgba($mc-primary, 0.06) 0%, rgba($mc-primary, 0.02) 100%);
    border-radius: $mc-radius-inset;
    border-left: 2px solid $mc-primary;

    i {
      flex-shrink: 0;
      margin-top: 2px;
    }
  }

  .mc-seo-fix-tip {
    font-size: 0.8125rem;
    color: $mc-text;
    line-height: 1.5;
  }

  .mc-seo-fix-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    text-decoration: none;

    i {
      font-size: 0.625rem;
    }
  }

  // ---------------------------------------------------------------------------
  // Collapsed / expanded card (passing checks)
  // ---------------------------------------------------------------------------
  .mc-seo-check-card {
    .mc-seo-checklist,
    .mc-seo-check-progress {
      overflow: hidden;
      transition: max-height 0.35s $mc-ease-spring, opacity 0.25s ease;
      max-height: 600px;
      opacity: 1;
    }

    .mc-seo-collapse-toggle {
      display: none;
      width: 100%;
      border: none;
      background: none;
      cursor: pointer;
      padding: 0.375rem 0 0;
      border-top: 1px solid $mc-border-color;
      margin-top: 0.5rem;
      color: $mc-text-light;
      font-size: 0.75rem;
      font-family: $mc-font-body;
      text-align: center;
      transition: color $mc-transition-base;

      i {
        margin-left: 4px;
        transition: transform 0.3s $mc-ease-spring;
      }

      &:hover {
        color: $mc-primary;
      }
    }
  }

  .mc-seo-check-card.is-collapsible {
    .mc-seo-collapse-toggle {
      display: block;
    }
  }

  .mc-seo-check-card.is-collapsed {
    cursor: pointer;

    .mc-seo-checklist,
    .mc-seo-check-progress {
      max-height: 0;
      opacity: 0;
    }

    .mc-seo-check-header {
      margin-bottom: 0;
    }

    .mc-seo-collapse-toggle i {
      transform: rotate(180deg);
    }
  }

  // ---------------------------------------------------------------------------
  // Status border accent on cards
  // ---------------------------------------------------------------------------
  .mc-seo-check-pass {
    border-left: 3px solid $mc-mint-strong;
  }

  .mc-seo-check-warning {
    border-left: 3px solid $mc-primary;
  }

  .mc-seo-check-fail {
    border-left: 3px solid $mc-coral-strong;
  }

  // ---------------------------------------------------------------------------
  // Responsive
  // ---------------------------------------------------------------------------
  @media (max-width: 768px) {
    .mc-seo-hero-content {
      flex-direction: column;
      text-align: center;
    }

    .mc-seo-hero-badges {
      justify-content: center;
    }

    .mc-seo-category-grid {
      grid-template-columns: 1fr;
    }

    .mc-seo-page .mc-page-header {
      flex-direction: column;
      align-items: flex-start;
    }

    .mc-seo-section-header {
      flex-direction: column;
      align-items: flex-start;
    }

    .mc-seo-page-actions {
      margin-left: 0;
      width: 100%;
      flex-wrap: wrap;
    }

    .mc-seo-tooltip {
      position: fixed;
      bottom: 1rem;
      left: 1rem;
      right: 1rem;
      top: auto;
      width: auto;
      max-width: none;

      &::before {
        display: none;
      }
    }
  }
}
