// Analytics Dashboard Styles
.analytics-dashboard {
  padding: 20px;
  background: #f8f9fa;
  min-height: 100vh;
  position: relative;

  // Free user mode styling
  &.free-user-mode {

    .analytics-header,
    .form-selector,
    .metrics-overview,
    .analytics-content {
      position: relative;

      &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.05);
        border-radius: inherit;
        pointer-events: none;
        z-index: 1;
      }
    }

    .demo-card,
    .demo-row {
      position: relative;
      opacity: 0.8;

      &::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(102, 126, 234, 0.05);
        border-radius: inherit;
        pointer-events: none;
      }
    }
  }

  .analytics-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 16px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);

    .header-title {
      display: flex;
      align-items: center;
      gap: 20px;

      .header-icon {
        font-size: 48px;
        opacity: 0.9;
      }

      h2 {
        margin: 0;
        font-size: 32px;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 15px;
        color: aliceblue;

        .demo-badge {
          background: rgba(255, 255, 255, 0.2);
          color: white;
          padding: 4px 12px;
          border-radius: 20px;
          font-size: 12px;
          font-weight: 500;
          text-transform: uppercase;
          letter-spacing: 0.5px;
        }
      }

      p {
        margin: 5px 0 0 0;
        opacity: 0.9;
        font-size: 16px;
      }
    }

    .header-controls {
      display: flex;
      align-items: center;
      gap: 20px;

      .date-range-selector {
        display: flex;
        align-items: center;
        gap: 10px;
        background: rgba(255, 255, 255, 0.15);
        padding: 12px 16px;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        position: relative;

        select {
          background: transparent;
          border: none;
          color: white;
          font-size: 14px;
          font-weight: 500;
          cursor: pointer;
          margin-bottom: 0;

          &:disabled {
            opacity: 0.6;
            cursor: not-allowed;
          }

          option {
            background: #667eea;
            color: white;
          }
        }

        .control-lock {
          font-size: 16px;
          opacity: 0.7;
          margin-left: 5px;
        }
      }

      .compare-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        background: rgba(255, 255, 255, 0.15);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.2);
        padding: 12px 20px;
        border-radius: 10px;
        cursor: pointer;
        font-weight: 500;
        transition: all 0.3s ease;
        position: relative;

        &:hover:not(.disabled) {
          background: rgba(255, 255, 255, 0.25);
          transform: translateY(-2px);
        }

        &.active {
          background: rgba(255, 255, 255, 0.3);
          border-color: rgba(255, 255, 255, 0.5);
        }

        &.disabled {
          opacity: 0.6;
          cursor: not-allowed;
        }

        .control-lock {
          font-size: 16px;
          opacity: 0.7;
          margin-left: 5px;
        }
      }
    }

    @media (max-width: 768px) {
      flex-direction: column;
      gap: 20px;
      text-align: center;

      .header-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
      }
    }
  }

  .form-selector {
    background: white;
    padding: 30px;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

    h3 {
      margin: 0 0 20px 0;
      color: #2d3748;
      font-size: 20px;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 10px;

      .demo-label {
        background: #ffd93d;
        color: #333;
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.5px;
      }
    }

    .form-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 20px;

      .form-card {
        background: #f7fafc;
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        padding: 20px;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;

        &:hover {
          border-color: #cbd5e0;
          transform: translateY(-2px);
          box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
        }

        &.selected {
          border-color: #667eea;
          background: linear-gradient(135deg, #667eea10, #764ba210);
          box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);

          .selected-icon {
            position: absolute;
            top: 15px;
            right: 15px;
            color: #667eea;
            font-size: 24px;
          }
        }

        .form-card-header {
          h4 {
            margin: 0 0 8px 0;
            color: #2d3748;
            font-size: 18px;
            font-weight: 600;
          }

          .form-id {
            color: #718096;
            font-size: 14px;
            font-weight: 500;
          }
        }

        .demo-lock {
          position: absolute;
          top: 15px;
          right: 15px;
          color: #ffd93d;
          font-size: 20px;
          opacity: 0.8;
        }
      }
    }
  }

  .loading-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

    .spinner {
      width: 40px;
      height: 40px;
      border: 4px solid #e2e8f0;
      border-top: 4px solid #667eea;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin: 0 auto 20px;
    }

    p {
      color: #718096;
      font-size: 16px;
      margin: 0;
    }
  }

  .metrics-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;

    .metric-card {
      background: white;
      padding: 25px;
      border-radius: 16px;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
      display: flex;
      align-items: center;
      gap: 20px;
      transition: transform 0.3s ease;
      position: relative;

      &:hover {
        transform: translateY(-4px);
      }

      .metric-icon {
        width: 60px;
        height: 60px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;

        svg {
          font-size: 28px;
          color: white;
        }
      }

      .metric-content {
        h3 {
          margin: 0 0 5px 0;
          font-size: 28px;
          font-weight: 700;
          color: #2d3748;
        }

        p {
          margin: 0;
          color: #718096;
          font-size: 14px;
          font-weight: 500;
        }
      }

      .metric-lock {
        position: absolute;
        top: 15px;
        right: 15px;
        color: #ffd93d;
        font-size: 20px;
        opacity: 0.8;
      }

      &.views .metric-icon {
        background: linear-gradient(135deg, #4299e1, #3182ce);
      }

      &.submissions .metric-icon {
        background: linear-gradient(135deg, #ed8936, #dd6b20);
      }

      &.successes .metric-icon {
        background: linear-gradient(135deg, #48bb78, #38a169);
      }

      &.errors .metric-icon {
        background: linear-gradient(135deg, #f56565, #e53e3e);
      }

      &.redirects .metric-icon {
        background: linear-gradient(135deg, #9f7aea, #805ad5);
      }
    }
  }

  .analytics-content {
    display: grid;
    gap: 30px;

    .conversion-metrics {
      background: white;
      padding: 30px;
      border-radius: 16px;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

      h3 {
        margin: 0 0 25px 0;
        color: #2d3748;
        font-size: 20px;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 10px;

        .demo-label {
          background: #ffd93d;
          color: #333;
          padding: 2px 8px;
          border-radius: 12px;
          font-size: 11px;
          font-weight: 500;
          text-transform: uppercase;
          letter-spacing: 0.5px;
        }
      }

      .conversion-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 20px;

        .conversion-card {
          background: #f7fafc;
          padding: 25px;
          border-radius: 12px;
          border: 1px solid #e2e8f0;
          position: relative;

          h4 {
            margin: 0 0 20px 0;
            color: #2d3748;
            font-size: 18px;
            font-weight: 600;
          }

          .conversion-stats {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;

            .stat {
              text-align: center;

              .stat-label {
                display: block;
                color: #718096;
                font-size: 12px;
                font-weight: 500;
                text-transform: uppercase;
                letter-spacing: 0.5px;
                margin-bottom: 8px;
              }

              .stat-value {
                display: block;
                color: #2d3748;
                font-size: 24px;
                font-weight: 700;
                margin-bottom: 4px;
              }

              small {
                color: #a0aec0;
                font-size: 11px;
              }
            }
          }

          .card-lock {
            position: absolute;
            top: 15px;
            right: 15px;
            color: #ffd93d;
            font-size: 18px;
            opacity: 0.8;
          }
        }
      }
    }

    .detailed-analytics {
      background: white;
      padding: 30px;
      border-radius: 16px;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
      position: relative;

      h3 {
        margin: 0 0 25px 0;
        color: #2d3748;
        font-size: 20px;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 10px;

        .demo-label {
          background: #ffd93d;
          color: #333;
          padding: 2px 8px;
          border-radius: 12px;
          font-size: 11px;
          font-weight: 500;
          text-transform: uppercase;
          letter-spacing: 0.5px;
        }
      }

      .analytics-table {
        overflow-x: auto;
        position: relative;

        table {
          width: 100%;
          border-collapse: collapse;

          thead {
            background: #f7fafc;

            th {
              padding: 15px 12px;
              text-align: left;
              color: #4a5568;
              font-weight: 600;
              font-size: 14px;
              border-bottom: 2px solid #e2e8f0;
            }
          }

          tbody {
            tr {
              transition: background-color 0.2s ease;

              &:hover {
                background: #f7fafc;
              }

              &.demo-row {
                position: relative;
              }

              td {
                padding: 15px 12px;
                border-bottom: 1px solid #e2e8f0;
                color: #2d3748;
                font-size: 14px;

                &.form-name {
                  font-weight: 600;
                  color: #2d3748;
                }

                &.success {
                  color: #38a169;
                  font-weight: 600;
                }

                &.error {
                  color: #e53e3e;
                  font-weight: 600;
                }

                &.conversion-rate,
                &.success-rate {
                  font-weight: 600;
                  color: #667eea;
                }
              }
            }
          }
        }

        .table-overlay {
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          background: rgba(255, 255, 255, 0.9);
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          border-radius: 12px;
          backdrop-filter: blur(2px);

          .overlay-lock {
            font-size: 48px;
            color: #ffd93d;
            margin-bottom: 15px;
            opacity: 0.8;
          }

          p {
            color: #2d3748;
            font-size: 16px;
            font-weight: 600;
            margin: 0;
          }
        }
      }
    }
  }

  .no-data-state,
  .no-selection-state {
    text-align: center;
    padding: 80px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

    .no-data-icon,
    .no-selection-icon {
      font-size: 80px;
      color: #cbd5e0;
      margin-bottom: 20px;
    }

    h3 {
      margin: 0 0 15px 0;
      color: #2d3748;
      font-size: 24px;
      font-weight: 600;
    }

    p {
      color: #718096;
      font-size: 16px;
      line-height: 1.6;
      margin: 0 0 10px 0;
      max-width: 500px;
      margin-left: auto;
      margin-right: auto;
    }
  }

  @keyframes spin {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }

  // Responsive design
  @media (max-width: 768px) {
    padding: 15px;

    .pro-banner {
      .pro-banner-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;

        .upgrade-btn {
          width: 100%;
        }
      }
    }

    .metrics-overview {
      grid-template-columns: 1fr;
    }

    .form-selector .form-grid {
      grid-template-columns: 1fr;
    }

    .conversion-metrics .conversion-grid {
      grid-template-columns: 1fr;
    }

    .analytics-table {
      font-size: 12px;

      table {
        min-width: 600px;
      }
    }

    .analytics-header {
      .header-title h2 {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;

        .demo-badge {
          align-self: flex-start;
        }
      }
    }
  }

  // Additional hover effects for free users
  &.free-user-mode {

    .form-card:hover,
    .metric-card:hover,
    .conversion-card:hover {
      cursor: pointer;

      &::after {
        background: rgba(255, 215, 0, 0.1);
      }
    }

    .analytics-table:hover {
      cursor: pointer;

      .table-overlay {
        background: rgba(255, 255, 255, 0.95);
      }
    }
  }

  // Pulse animation for demo elements
  &.free-user-mode {

    .demo-lock,
    .metric-lock,
    .card-lock,
    .control-lock {
      animation: pulse 2s infinite;
    }
  }

  @keyframes pulse {

    0%,
    100% {
      opacity: 0.8;
    }

    50% {
      opacity: 1;
      transform: scale(1.1);
    }
  }
}