// WooCommerce Analytics Dashboard Styles
// wooanalytics.scss

// Variables
$primary-color: #008080;
$secondary-color: #10b981;
$danger-color: #ef4444;
$warning-color: #f59e0b;
$success-color: #10b981;
$text-dark: #1f2937;
$text-medium: #6b7280;
$text-light: #9ca3af;
$background-light: #f9fafb;
$background-gradient-start: #f8fafc;
$background-gradient-end: #eff6ff;
$card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
$card-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
$border-radius: 12px;
$border-radius-lg: 16px;

// Mixins
@mixin card {
  border-radius: $border-radius-lg;
  box-shadow: $card-shadow-lg;
  padding: 2rem;
}

@mixin flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

@mixin transition {
  transition: all 0.3s ease;
}

// Main Container
.woo-analytics-container {
  min-height: 100vh;
  background: linear-gradient(135deg, $background-gradient-start 0%, $background-gradient-end 100%);
  padding: 2rem;

  @media (max-width: 768px) {
    padding: 1rem;
  }
}

// Dashboard Wrapper
.woo-analytics-dashboard {
  max-width: 1400px;
  margin: 0 auto;
}

// Loading State
.analytics-loading {
  @include card;
  text-align: center;
  padding: 3rem;

  .loading-content {
    max-width: 500px;
    margin: 0 auto;

    h3 {
      font-size: 1.75rem;
      font-weight: 700;
      color: $text-dark;
      margin-bottom: 0.5rem;
    }

    p {
      color: $text-medium;
      margin-bottom: 2rem;
    }
  }

  .loading-spinner {
    @include flex-center;
    margin-bottom: 1.5rem;
    position: relative;
    width: 64px;
    height: 64px;
    margin-left: auto;
    margin-right: auto;

    .spinner-ring {
      position: absolute;
      width: 64px;
      height: 64px;
      border: 4px solid #e5e7eb;
      border-top-color: $primary-color;
      border-radius: 50%;
      animation: spin 1s linear infinite;

      &:nth-child(2) {
        width: 52px;
        height: 52px;
        border-top-color: $secondary-color;
        animation-delay: 0.15s;
      }

      &:nth-child(3) {
        width: 40px;
        height: 40px;
        border-top-color: $warning-color;
        animation-delay: 0.3s;
      }
    }
  }

  .loading-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;

    .step {
      display: flex;
      align-items: center;
      gap: 1rem;
      padding: 1rem;
      border-radius: $border-radius;
      @include transition;

      &.completed {
        background: #dcfce7;

        .step-number {
          background: $success-color;
          color: white;

          &::after {
            content: '✓';
          }
        }
      }

      &.active {
        background: #dbeafe;

        .step-number {
          background: $primary-color;
          color: white;
        }
      }

      &.pending {
        background: $background-light;

        .step-number {
          background: #d1d5db;
          color: white;
        }
      }

      .step-number {
        @include flex-center;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-weight: 700;
        font-size: 0.875rem;
        flex-shrink: 0;
        @include transition;
      }

      .step-text {
        color: $text-dark;
        font-size: 0.95rem;
      }
    }
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

// Analytics Disabled State
.analytics-disabled {
  @include card;
  max-width: 1000px;
  margin: 0 auto;

  .disabled-content {
    text-align: center;

    .disabled-icon {
      @include flex-center;
      width: 80px;
      height: 80px;
      background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
      border-radius: 50%;
      margin: 0 auto 1.5rem;

      svg {
        width: 40px;
        height: 40px;
        color: $primary-color;
      }
    }

    h2 {
      font-size: 2rem;
      font-weight: 700;
      color: $text-dark;
      margin-bottom: 0.75rem;
    }

    .disabled-description {
      font-size: 1.125rem;
      color: $text-medium;
      max-width: 600px;
      margin: 0 auto 3rem;
    }
  }

  .features-preview {
    margin-bottom: 3rem;

    h3 {
      font-size: 1.25rem;
      font-weight: 600;
      color: $text-dark;
      margin-bottom: 1.5rem;
    }

    .features-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
      gap: 1.5rem;

      .feature-item {
        display: flex;
        gap: 1rem;
        padding: 1.5rem;
        border-radius: $border-radius;
        text-align: left;
        @include transition;

        &:nth-child(1) {
          background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
        }

        &:nth-child(2) {
          background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
        }

        &:nth-child(3) {
          background: linear-gradient(135deg, #e9d5ff 0%, #d8b4fe 100%);
        }

        &:nth-child(4) {
          background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
        }

        &:nth-child(5) {
          background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
        }

        &:nth-child(6) {
          background: linear-gradient(135deg, #b9a5f5 0%, #a78bfa 100%);
        }

        .feature-icon {
          width: 32px;
          height: 32px;
          flex-shrink: 0;
          margin-top: 0.25rem;
        }

        .feature-text {
          h4 {
            font-size: 1rem;
            font-weight: 600;
            color: $text-dark;
            margin-bottom: 0.25rem;
          }

          p {
            font-size: 0.875rem;
            color: $text-medium;
            line-height: 1.5;
          }
        }
      }
    }
  }

  .activation-section {
    background: linear-gradient(135deg, $background-light 0%, #e5e7eb 100%);
    border-radius: $border-radius;
    padding: 2rem;

    h3 {
      font-size: 1.25rem;
      font-weight: 600;
      color: $text-dark;
      margin-bottom: 1rem;
    }

    >p {
      color: $text-medium;
      margin-bottom: 1.5rem;
    }

    .activation-steps {
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
      margin-bottom: 2rem;

      .step-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;

        .step-number {
          @include flex-center;
          width: 32px;
          height: 32px;
          background: $primary-color;
          color: white;
          border-radius: 50%;
          font-weight: 700;
          font-size: 0.875rem;
          flex-shrink: 0;
        }

        span:last-child {
          color: $text-dark;

          strong {
            font-weight: 600;
          }
        }
      }
    }

    .enable-analytics-btn {
      display: block;
      width: 100%;
      background: $primary-color;
      color: white;
      font-weight: 600;
      padding: 0.75rem 1.5rem;
      border-radius: $border-radius;
      text-decoration: none;
      text-align: center;
      border: none;
      @include transition;

      &:hover {
        background: darken($primary-color, 10%);
      }
    }
  }
}

// Error States
.analytics-error {
  @include card;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;

  .error-content {
    .error-icon {
      @include flex-center;
      width: 80px;
      height: 80px;
      background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
      border-radius: 50%;
      margin: 0 auto 1.5rem;
      color: $danger-color;

      svg {
        width: 40px;
        height: 40px;
      }
    }

    h2 {
      font-size: 2rem;
      font-weight: 700;
      color: $text-dark;
      margin-bottom: 0.75rem;
    }

    p {
      font-size: 1.125rem;
      color: $text-medium;
      margin-bottom: 2rem;
    }

    .error-actions {
      display: flex;
      gap: 1rem;
      justify-content: center;
      flex-wrap: wrap;

      .install-woo-button,
      .retry-button {
        padding: 0.75rem 1.5rem;
        border-radius: $border-radius;
        font-weight: 600;
        text-decoration: none;
        border: none;
        cursor: pointer;
        @include transition;
      }

      .install-woo-button {
        background: $primary-color;
        color: white;

        &:hover {
          background: darken($primary-color, 10%);
        }
      }

      .retry-button {
        background: #e5e7eb;
        color: $text-dark;

        &:hover {
          background: #d1d5db;
        }
      }
    }
  }
}

.analytics-no-data {
  @include card;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;

  .no-data-content {
    .no-data-icon {
      @include flex-center;
      width: 80px;
      height: 80px;
      background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
      border-radius: 50%;
      margin: 0 auto 1.5rem;
      color: $primary-color;

      svg {
        width: 40px;
        height: 40px;
      }
    }

    h3 {
      font-size: 1.75rem;
      font-weight: 700;
      color: $text-dark;
      margin-bottom: 0.75rem;
    }

    >p {
      font-size: 1.125rem;
      color: $text-medium;
      margin-bottom: 2rem;
      line-height: 1.6;
    }

    .no-data-suggestions {
      background: linear-gradient(135deg, $background-light 0%, #e5e7eb 100%);
      border-radius: $border-radius;
      padding: 1.5rem;
      margin-bottom: 2rem;
      text-align: left;

      h4 {
        font-size: 1.125rem;
        font-weight: 600;
        color: $text-dark;
        margin-bottom: 1rem;
        text-align: center;
      }

      ul {
        list-style: none;
        padding: 0;
        margin: 0;

        li {
          color: $text-medium;
          padding: 0.5rem 0;
          font-size: 0.95rem;
          line-height: 1.5;

          &:not(:last-child) {
            border-bottom: 1px solid #e5e7eb;
          }
        }
      }
    }

    .retry-button {
      padding: 0.75rem 1.5rem;
      background: $primary-color;
      color: white;
      border: none;
      border-radius: $border-radius;
      font-weight: 600;
      cursor: pointer;
      @include transition;

      &:hover {
        background: darken($primary-color, 10%);
      }
    }
  }
}

// Header
.analytics-header {
  @include card;
  background: linear-gradient(135deg, #008080 0%, #024343 100%);
  margin-bottom: 2rem;

  h1 {
    font-size: 2rem;
    font-weight: 700;
    color: $text-dark;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;

    .header-icon {
      width: 48px;
      height: 48px;
      padding: 10px;
      background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
      border-radius: $border-radius;
      color: $primary-color;
    }
  }

  .last-updated {
    color: $text-medium;
    font-size: 0.95rem;
    padding-left: 64px;
  }
}

// Analytics Sections
.analytics-section {
  margin-bottom: 3rem;

  h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: $text-dark;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
  }
}

// Analytics Grid
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.analytics-card {
  @include card;
  @include transition;

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  }

  .card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;

    .card-icon {
      width: 40px;
      height: 40px;
      padding: 8px;
      border-radius: 10px;
      flex-shrink: 0;
      background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
      color: $primary-color;
    }

    h3 {
      font-size: 1rem;
      font-weight: 600;
      color: $text-medium;
    }
  }

  .card-content {
    .main-value {
      font-size: 2rem;
      font-weight: 700;
      color: $text-dark;
      margin-bottom: 0.75rem;
    }

    .sub-value {
      color: $text-medium;
      font-size: 0.875rem;
      margin-bottom: 0.75rem;
    }

    .order-breakdown {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;

      .status {
        padding: 0.25rem 0.5rem;
        border-radius: 6px;
        font-size: 0.75rem;
        font-weight: 600;

        &.completed {
          background: #dcfce7;
          color: #166534;
        }

        &.processing {
          background: #dbeafe;
          color: #1e40af;
        }

        &.pending {
          background: #fef3c7;
          color: #92400e;
        }

        &.cancelled {
          background: #fee2e2;
          color: #991b1b;
        }

        &.refunded {
          background: #f3e8ff;
          color: #7c3aed;
        }

        &.on-hold {
          background: #fef3c7;
          color: #92400e;
        }

        &.failed {
          background: #fee2e2;
          color: #991b1b;
        }
      }
    }
  }
}

// Customer Analytics
.customer-analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.customer-card {
  @include card;

  h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: $text-dark;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
  }

  .customer-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    .stat {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .label {
        color: $text-medium;
        font-size: 0.875rem;
      }

      .value {
        font-weight: 700;
        font-size: 1.125rem;
        color: $text-dark;
      }
    }
  }
}

// Revenue Overview Cards (Legacy - keeping for compatibility)
.revenue-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;

  .revenue-card {
    @include card;
    @include transition;

    &:hover {
      transform: translateY(-4px);
      box-shadow: 0 25px 30px -10px rgba(0, 0, 0, 0.15);
    }

    .card-header {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin-bottom: 1rem;

      .card-icon {
        width: 40px;
        height: 40px;
        padding: 8px;
        border-radius: 10px;
        flex-shrink: 0;
      }

      h3 {
        font-size: 1rem;
        font-weight: 600;
        color: $text-medium;
      }
    }

    &:nth-child(1) .card-icon {
      background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
      color: $success-color;
    }

    &:nth-child(2) .card-icon {
      background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
      color: $primary-color;
    }

    &:nth-child(3) .card-icon {
      background: linear-gradient(135deg, #e9d5ff 0%, #d8b4fe 100%);
      color: #a855f7;
    }

    &:nth-child(4) .card-icon {
      background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
      color: $warning-color;
    }

    .card-content {
      .main-value {
        font-size: 2rem;
        font-weight: 700;
        color: $text-dark;
        margin-bottom: 0.5rem;
      }

      .growth-indicator {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        font-size: 0.875rem;
        font-weight: 600;

        &.positive {
          color: $success-color;
        }

        &.negative {
          color: $danger-color;
        }

        svg {
          width: 16px;
          height: 16px;
        }
      }

      .sub-value {
        color: $text-medium;
        font-size: 0.875rem;
      }
    }
  }
}

// Charts Section
.analytics-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;

  @media (max-width: 1024px) {
    grid-template-columns: 1fr;
  }

  .chart-container {
    @include card;

    .chart-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 1.5rem;

      h3 {
        font-size: 1.25rem;
        font-weight: 600;
        color: $text-dark;
      }

      .period-selector {
        display: flex;
        gap: 0.5rem;

        button {
          padding: 0.5rem 1rem;
          border-radius: $border-radius;
          border: none;
          font-weight: 600;
          font-size: 0.875rem;
          cursor: pointer;
          background: $background-light;
          color: $text-medium;
          @include transition;

          &:hover {
            background: #e5e7eb;
          }

          &.active {
            background: $primary-color;
            color: white;
          }
        }
      }
    }

    .chart-content {
      // Recharts styles are handled by the library
      position: relative;
    }
  }
}

// Top Products Table
.top-products-table {
  @include card;

  h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: $text-dark;
    margin-bottom: 1.5rem;
  }

  .table-container {
    overflow-x: auto;

    table {
      width: 100%;
      border-collapse: collapse;

      thead {
        tr {
          border-bottom: 2px solid #e5e7eb;

          th {
            padding: 0.75rem 1rem;
            text-align: left;
            font-weight: 600;
            color: $text-dark;
            font-size: 0.875rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;

            &:not(:first-child) {
              text-align: right;
            }
          }
        }
      }

      tbody {
        tr {
          border-bottom: 1px solid #f3f4f6;
          @include transition;

          &:hover {
            background: $background-light;
          }

          td {
            padding: 1rem;
            color: $text-dark;

            &:not(.product-name):not(.rank-cell) {
              text-align: right;
            }

            &.rank-cell {
              text-align: center;

              .rank {
                @include flex-center;
                width: 32px;
                height: 32px;
                background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
                color: $primary-color;
                border-radius: $border-radius;
                font-weight: 700;
                font-size: 0.875rem;
                margin: 0 auto;
              }
            }

            &.product-name {
              font-weight: 500;
              text-align: left;
            }

            &.revenue-cell {
              font-weight: 600;
              color: $success-color;
            }
          }
        }
      }
    }
  }
}

// Responsive Design
@media (max-width: 768px) {
  .analytics-header {
    h1 {
      font-size: 1.5rem;
      flex-direction: column;
      align-items: flex-start;
    }

    .last-updated {
      padding-left: 0;
    }
  }

  .revenue-overview {
    grid-template-columns: 1fr;
  }

  .analytics-charts {
    grid-template-columns: 1fr;

    .chart-container {
      .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
      }
    }
  }

  .top-products-table {
    .table-container {
      table {
        font-size: 0.875rem;

        thead th,
        tbody td {
          padding: 0.5rem;
        }
      }
    }
  }

  .analytics-disabled {
    .features-grid {
      grid-template-columns: 1fr;
    }

    .activation-section {
      padding: 1.5rem;
    }
  }
}

// Glass Effect Styles for Preview Mode
.analytics-preview-mode {
  .preview-badge {
    display: inline-block;
    background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 100%);
    color: #92400e;
    padding: 0.5rem 1rem;
    border-radius: $border-radius;
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.5rem;
    border: 1px solid #f59e0b;
  }

  .glass-effect-container {
    position: relative;
    overflow: hidden;

    &:hover .glass-overlay {
      opacity: 1;
      visibility: visible;
    }

    .glass-overlay {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(255, 255, 255, 0.95);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: $border-radius-lg;
      opacity: 0;
      visibility: hidden;
      @include transition;
      @include flex-center;
      z-index: 10;

      .glass-content {
        text-align: center;
        padding: 2rem;
        max-width: 400px;

        h4 {
          font-size: 1.25rem;
          font-weight: 700;
          color: $text-dark;
          margin-bottom: 0.75rem;
        }

        p {
          color: $text-medium;
          line-height: 1.6;
          margin-bottom: 1rem;
          font-size: 0.95rem;
        }

        .enable-hint {
          background: linear-gradient(135deg, $primary-color, darken($primary-color, 10%));
          color: white;
          padding: 0.75rem 1.5rem;
          border-radius: $border-radius;
          font-weight: 600;
          font-size: 0.875rem;
          box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
        }
      }
    }

    // Disable interactions for preview elements
    input,
    button,
    .sortable {
      pointer-events: none;
      opacity: 0.7;
    }

    .tab-button {
      pointer-events: none;
      opacity: 0.8;
    }
  }

  // Chart placeholders
  .chart-placeholder {
    height: 300px;
    @include flex-center;
    background: linear-gradient(135deg, $background-light 0%, #e5e7eb 100%);
    border-radius: $border-radius;

    .placeholder-chart {
      width: 80%;
      height: 80%;
      position: relative;

      &.horizontal {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        padding: 1rem;

        .product-bar {
          display: flex;
          align-items: center;
          gap: 1rem;

          .product-name {
            min-width: 120px;
            font-size: 0.875rem;
            color: $text-medium;
            font-weight: 500;
          }

          .bar {
            height: 20px;
            background: linear-gradient(90deg, $primary-color, $secondary-color);
            border-radius: 10px;
            opacity: 0.7;

            &.abandoned {
              background: linear-gradient(90deg, $danger-color, #f87171);
            }
          }
        }
      }

      &.line-chart {
        @include flex-center;

        svg {
          opacity: 0.6;
        }

        .chart-lines {
          width: 100%;
          height: 100%;
        }
      }

      .chart-bars {
        display: flex;
        align-items: flex-end;
        justify-content: space-around;
        height: 100%;
        padding: 1rem;

        .bar {
          width: 20px;
          background: linear-gradient(180deg, $primary-color, $secondary-color);
          border-radius: 4px 4px 0 0;
          opacity: 0.7;
          @include transition;
        }

        &.stacked {
          .bar-stack {
            display: flex;
            flex-direction: column;
            align-items: center;
            height: 100%;
            width: 30px;
            justify-content: flex-end;

            .bar-segment {
              width: 100%;
              border-radius: 2px;

              &.completed {
                background: $success-color;
              }

              &.processing {
                background: $primary-color;
              }

              &.pending {
                background: $warning-color;
              }
            }
          }
        }
      }

      .placeholder-pie-chart {
        width: 150px;
        height: 150px;
        border-radius: 50%;
        margin: 0 auto;

        .pie-segment {
          width: 100%;
          height: 100%;
          border-radius: 50%;
          opacity: 0.7;
        }
      }
    }
  }

  // Activation guide at bottom
  .activation-guide {
    @include card;
    margin-top: 3rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #0ea5e9;

    .guide-content {
      text-align: center;

      h3 {
        font-size: 1.5rem;
        font-weight: 700;
        color: $text-dark;
        margin-bottom: 1rem;
      }

      >p {
        color: $text-medium;
        margin-bottom: 2rem;
        font-size: 1.125rem;
      }

      .activation-steps {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 2rem;
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;

        .step-item {
          display: flex;
          align-items: center;
          gap: 1rem;
          padding: 1rem;
          background: white;
          border-radius: $border-radius;
          box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

          .step-number {
            @include flex-center;
            width: 32px;
            height: 32px;
            background: $primary-color;
            color: white;
            border-radius: 50%;
            font-weight: 700;
            font-size: 0.875rem;
            flex-shrink: 0;
          }

          span:last-child {
            color: $text-dark;
            text-align: left;

            strong {
              font-weight: 600;
              color: $primary-color;
            }
          }
        }
      }

      .enable-analytics-btn {
        display: inline-block;
        background: linear-gradient(135deg, $primary-color, darken($primary-color, 10%));
        color: white;
        font-weight: 700;
        padding: 1rem 2rem;
        border-radius: $border-radius;
        text-decoration: none;
        border: none;
        cursor: pointer;
        font-size: 1.125rem;
        box-shadow: 0 8px 16px rgba(0, 115, 170, 0.3);
        @include transition;

        &:hover {
          transform: translateY(-2px);
          box-shadow: 0 12px 20px rgba(0, 115, 170, 0.4);
        }
      }
    }
  }
}

// Enhanced glass effect animations
@keyframes glassAppear {
  0% {
    opacity: 0;
    transform: scale(0.95);
    backdrop-filter: blur(0px);
  }

  100% {
    opacity: 1;
    transform: scale(1);
    backdrop-filter: blur(10px);
  }
}

.glass-effect-container:hover .glass-overlay {
  animation: glassAppear 0.3s ease-out;
}

// Print Styles
@media print {
  .woo-analytics-container {
    background: white;
    padding: 0;
  }

  .revenue-card,
  .chart-container,
  .top-products-table {
    box-shadow: none;
    page-break-inside: avoid;
  }

  .period-selector {
    display: none;
  }

  .glass-overlay,
  .preview-badge,
  .activation-guide {
    display: none !important;
  }
}

// ModalStyles
.analytics-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  @include flex-center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.analytics-modal {
  background: white;
  border-radius: $border-radius-lg;
  box-shadow: $card-shadow-lg;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e5e7eb;

    h3 {
      font-size: 1.25rem;
      font-weight: 600;
      color: $text-dark;
      margin: 0;
    }

    .close-icon {
      width: 24px;
      height: 24px;
      color: $text-medium;
      cursor: pointer;
      @include transition;

      &:hover {
        color: $text-dark;
      }
    }
  }

  .modal-content {
    padding: 2rem;
  }
}

// Modal Content Styles
.modal-stats {
  .stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;

    .stat-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 1rem;
      border-radius: $border-radius;
      background: $background-light;

      &.completed {
        background: #dcfce7;
        border-left: 4px solid $success-color;
      }

      &.processing {
        background: #dbeafe;
        border-left: 4px solid $primary-color;
      }

      &.pending {
        background: #fef3c7;
        border-left: 4px solid $warning-color;
      }

      &.cancelled,
      &.refunded {
        background: #fee2e2;
        border-left: 4px solid $danger-color;
      }

      &.on-hold {
        background: #f3f4f6;
        border-left: 4px solid $text-medium;
      }

      .stat-label {
        color: $text-medium;
        font-size: 0.875rem;
        font-weight: 500;
      }

      .stat-value {
        font-weight: 700;
        font-size: 1.125rem;
        color: $text-dark;
      }
    }
  }

  .revenue-breakdown,
  .period-summary,
  .customer-breakdown,
  .trends-summary,
  .products-summary {
    margin-bottom: 1.5rem;

    h4,
    h5 {
      font-size: 1.125rem;
      font-weight: 600;
      color: $text-dark;
      margin-bottom: 1rem;
    }

    .revenue-item,
    .summary-item,
    .trend-item,
    .product-stat {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0.75rem 0;
      border-bottom: 1px solid #f3f4f6;

      &:last-child {
        border-bottom: none;
      }

      .revenue-label,
      .summary-label,
      .trend-label,
      .product-label {
        color: $text-medium;
        font-size: 0.875rem;
      }

      .revenue-value,
      .summary-value,
      .trend-value,
      .product-value {
        font-weight: 600;
        color: $text-dark;
      }
    }

    .revenue-sources {
      margin-top: 1rem;
      padding: 1rem;
      background: $background-light;
      border-radius: $border-radius;

      .source-item {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        font-size: 0.875rem;

        span:first-child {
          color: $text-dark;
          font-weight: 500;
        }

        span:last-child {
          color: $text-medium;
        }
      }
    }

    .summary-grid,
    .customer-grid,
    .trends-grid,
    .products-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 1rem;
    }

    .customer-period {
      padding: 1rem;
      background: $background-light;
      border-radius: $border-radius;

      .customer-stats {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;

        span {
          display: flex;
          justify-content: space-between;
          font-size: 0.875rem;
          color: $text-dark;
        }
      }
    }
  }

  .modal-description {
    padding: 1rem;
    background: linear-gradient(135deg, $background-light 0%, #e5e7eb 100%);
    border-radius: $border-radius;

    p {
      color: $text-medium;
      font-size: 0.875rem;
      line-height: 1.6;
      margin: 0;
    }
  }
}

// Info Icons
.info-icon,
.section-info-icon,
.chart-info-icon,
.table-info-icon {
  width: 20px;
  height: 20px;
  color: $text-medium;
  cursor: pointer;
  @include transition;

  &:hover {
    color: $primary-color;
    transform: scale(1.1);
  }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;

  h2 {
    margin: 0;
    padding: 0;
    border: none;
  }
}

.chart-header {
  .chart-info-icon {
    margin-left: auto;
  }
}

.card-header {
  .info-icon {
    margin-left: auto;
  }
}

// Enhanced Top Products Table
.top-products-table {
  .table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;

    .table-title {
      display: flex;
      align-items: center;
      gap: 0.75rem;

      h3 {
        margin: 0;
      }
    }

    .table-controls {
      display: flex;
      align-items: center;
      gap: 1rem;

      .search-box {
        position: relative;

        .search-icon {
          position: absolute;
          left: 0.75rem;
          top: 50%;
          transform: translateY(-50%);
          width: 16px;
          height: 16px;
          color: $text-medium;
        }

        input {
          padding: 0.5rem 0.75rem 0.5rem 2.5rem;
          border: 1px solid #d1d5db;
          border-radius: $border-radius;
          font-size: 0.875rem;
          width: 200px;
          @include transition;

          &:focus {
            outline: none;
            border-color: $primary-color;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
          }

          &::placeholder {
            color: $text-light;
          }
        }
      }
    }
  }

  .table-container {
    table {
      thead {
        th {
          &.sortable {
            cursor: pointer;
            user-select: none;
            position: relative;
            @include transition;

            &:hover {
              background: $background-light;
            }

            &.active {
              background: $background-light;
              color: $primary-color;
            }

            .sort-icon {
              width: 14px;
              height: 14px;
              margin-left: 0.25rem;
              opacity: 0.5;
              @include transition;
            }

            &:hover .sort-icon,
            &.active .sort-icon {
              opacity: 1;
            }
          }
        }
      }

      tbody {
        .actions-cell {
          text-align: center;

          .edit-product-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            background: $primary-color;
            color: white;
            border: none;
            border-radius: $border-radius;
            cursor: pointer;
            @include transition;

            &:hover {
              background: darken($primary-color, 10%);
              transform: scale(1.05);
            }

            svg {
              width: 16px;
              height: 16px;
            }
          }
        }
      }
    }
  }

  .pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 1rem;

    .pagination-info {
      color: $text-medium;
      font-size: 0.875rem;
    }

    .pagination-controls {
      display: flex;
      align-items: center;
      gap: 0.5rem;

      .pagination-btn {
        padding: 0.5rem 0.75rem;
        border: 1px solid #d1d5db;
        background: white;
        color: $text-dark;
        border-radius: $border-radius;
        font-size: 0.875rem;
        cursor: pointer;
        @include transition;

        &:hover:not(:disabled) {
          background: $background-light;
          border-color: $primary-color;
        }

        &.active {
          background: $primary-color;
          color: white;
          border-color: $primary-color;
        }

        &:disabled {
          opacity: 0.5;
          cursor: not-allowed;
        }
      }
    }
  }
}

// Mobile Responsive for New Features
@media (max-width: 768px) {
  .analytics-modal {
    width: 95%;
    max-height: 90vh;

    .modal-header {
      padding: 1rem 1.5rem;

      h3 {
        font-size: 1.125rem;
      }
    }

    .modal-content {
      padding: 1.5rem;
    }
  }

  .modal-stats {
    .stat-grid {
      grid-template-columns: 1fr;
    }

    .summary-grid,
    .customer-grid,
    .trends-grid,
    .products-grid {
      grid-template-columns: 1fr;
    }
  }

  .top-products-table {
    .table-header {
      flex-direction: column;
      align-items: stretch;

      .table-controls {
        justify-content: stretch;

        .search-box input {
          width: 100%;
        }
      }
    }

    .pagination {
      flex-direction: column;
      align-items: stretch;
      text-align: center;

      .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
      }
    }
  }

  // Mobile glass effect adjustments
  .analytics-preview-mode {
    .glass-effect-container {

      // On mobile, show glass overlay on tap instead of hover
      &:active .glass-overlay {
        opacity: 1;
        visibility: visible;
      }

      .glass-overlay {
        .glass-content {
          padding: 1.5rem;

          h4 {
            font-size: 1.125rem;
          }

          p {
            font-size: 0.875rem;
          }

          .enable-hint {
            padding: 0.5rem 1rem;
            font-size: 0.8rem;
          }
        }
      }
    }

    .chart-placeholder {
      height: 250px;

      .placeholder-chart {
        &.horizontal {
          padding: 0.5rem;

          .product-bar {
            .product-name {
              min-width: 80px;
              font-size: 0.8rem;
            }

            .bar {
              height: 16px;
            }
          }
        }

        .chart-bars {
          padding: 0.5rem;

          .bar {
            width: 16px;
          }
        }

        .placeholder-pie-chart {
          width: 120px;
          height: 120px;
        }
      }
    }

    .activation-guide {
      margin-top: 2rem;

      .guide-content {
        h3 {
          font-size: 1.25rem;
        }

        >p {
          font-size: 1rem;
        }

        .activation-steps {
          .step-item {
            padding: 0.75rem;

            .step-number {
              width: 28px;
              height: 28px;
              font-size: 0.8rem;
            }

            span:last-child {
              font-size: 0.9rem;
            }
          }
        }

        .enable-analytics-btn {
          padding: 0.75rem 1.5rem;
          font-size: 1rem;
        }
      }
    }

    .preview-badge {
      font-size: 0.8rem;
      padding: 0.4rem 0.8rem;
    }
  }
}

// Enhanced Modal Styles for Detailed Tables
.modal-table-container {
  max-height: 400px;
  overflow-y: auto;
  margin: 20px 0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;

  .modal-products-table,
  .modal-daily-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;

    thead {
      background: #f8f9fa;
      position: sticky;
      top: 0;
      z-index: 1;

      th {
        padding: 12px 8px;
        text-align: left;
        font-weight: 600;
        color: #333;
        border-bottom: 2px solid #dee2e6;
        white-space: nowrap;
      }
    }

    tbody {
      tr {
        border-bottom: 1px solid #f0f0f0;
        transition: background-color 0.2s ease;

        &:hover {
          background-color: #f8f9fa;
        }

        &:last-child {
          border-bottom: none;
        }
      }

      td {
        padding: 10px 8px;
        vertical-align: middle;

        &.rank-cell {
          text-align: center;
          width: 60px;

          .rank {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 12px;
            background: #e9ecef;
            color: #495057;
            font-weight: 600;
            font-size: 12px;

            &.top-performer {
              background: linear-gradient(135deg, #ffd700, #ffed4e);
              color: #b8860b;
              box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
            }
          }
        }

        &.product-name-cell {
          max-width: 200px;

          strong {
            color: #2c3e50;
            display: block;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }
        }

        &.quantity-cell,
        &.orders-cell {
          text-align: center;
          font-weight: 600;
          color: #495057;
        }

        &.price-cell,
        &.revenue-cell,
        &.avg-cell {
          text-align: right;
          font-weight: 600;
          color: #28a745;
        }

        &.date-cell {
          font-weight: 500;
          color: #495057;
          white-space: nowrap;
        }

        &.completed-cell {
          text-align: center;
          color: #28a745;
          font-weight: 600;
        }

        &.processing-cell {
          text-align: center;
          color: #ffc107;
          font-weight: 600;
        }

        &.performance-cell {
          width: 120px;

          .performance-bar {
            position: relative;
            height: 20px;
            background: #e9ecef;
            border-radius: 10px;
            overflow: hidden;

            .performance-fill {
              height: 100%;
              background: linear-gradient(90deg, #28a745, #20c997);
              border-radius: 10px;
              transition: width 0.3s ease;
            }

            .performance-text {
              position: absolute;
              top: 50%;
              left: 50%;
              transform: translate(-50%, -50%);
              font-size: 11px;
              font-weight: 600;
              color: #333;
              text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
            }
          }
        }
      }
    }
  }
}

// Enhanced Modal Content Sections
.products-detailed-table,
.daily-breakdown-table {
  margin-top: 30px;

  h4 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
  }
}

.revenue-orders-summary {
  margin-bottom: 25px;

  h4 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
  }
}

.revenue-orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;

  .summary-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #007cba;

    .summary-label {
      display: block;
      font-size: 13px;
      color: #6c757d;
      margin-bottom: 5px;
      font-weight: 500;
    }

    .summary-value {
      display: block;
      font-size: 16px;
      font-weight: 700;
      color: #2c3e50;
    }
  }
}

// Responsive adjustments for modal tables
@media (max-width: 768px) {
  .modal-table-container {

    .modal-products-table,
    .modal-daily-table {
      font-size: 12px;

      thead th {
        padding: 8px 4px;
      }

      tbody td {
        padding: 8px 4px;

        &.product-name-cell {
          max-width: 150px;
        }

        &.performance-cell {
          width: 80px;

          .performance-bar {
            height: 16px;

            .performance-text {
              font-size: 10px;
            }
          }
        }
      }
    }
  }

  .revenue-orders-grid {
    grid-template-columns: 1fr;
    gap: 10px;

    .summary-item {
      padding: 12px;

      .summary-label {
        font-size: 12px;
      }

      .summary-value {
        font-size: 14px;
      }
    }
  }
}