.ai-settings-page {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--p-surface-500);

  &.compact {
    padding: 2rem;
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 0.75rem;
  color: var(--p-surface-400);

  i {
    font-size: 2.5rem;
  }

  p {
    font-size: 0.9rem;
  }
}

.tab-icon {
  margin-inline-end: 0.4rem;
}

// ===== Settings Section =====
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 1rem;
}

.section-card {
  background: var(--p-surface-0);
  border: 1px solid var(--p-surface-200);
  border-radius: 12px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  background: var(--p-surface-50);
  border-bottom: 1px solid var(--p-surface-200);

  i {
    font-size: 1rem;
    color: var(--p-primary-500);
  }

  h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--p-surface-800);
    flex: 1;
  }
}

.section-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 1rem;

  label {
    flex: 0 0 200px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--p-surface-700);
  }

  > :not(label) {
    flex: 1;
  }
}

.save-bar {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.5rem;
}

// ===== Filter Bar =====
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;

  label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--p-surface-500);
  }
}

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

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--p-surface-0);
  border: 1px solid var(--p-surface-200);
  border-radius: 12px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  i {
    font-size: 1.25rem;
    color: #fff;
  }

  &.requests {
    background: linear-gradient(135deg, #1a237e, #3949ab);
  }

  &.tokens {
    background: linear-gradient(135deg, #00695c, #26a69a);
  }

  &.cost-usd {
    background: linear-gradient(135deg, #e65100, #ff9800);
  }

  &.cost-egp {
    background: linear-gradient(135deg, #4a148c, #7c43bd);
  }

  &.cached {
    background: linear-gradient(135deg, #0277bd, #4fc3f7);
  }
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.stat-value {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--p-surface-900);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--p-surface-500);
  font-weight: 500;
}

// ===== Dark Mode =====
:host-context(.dark) {
  .section-card {
    background: var(--p-surface-800);
    border-color: var(--p-surface-700);
  }

  .section-header {
    background: var(--p-surface-900);
    border-color: var(--p-surface-700);

    h3 {
      color: var(--p-surface-100);
    }
  }

  .form-row label {
    color: var(--p-surface-300);
  }

  .stat-card {
    background: var(--p-surface-800);
    border-color: var(--p-surface-700);
  }

  .stat-value {
    color: var(--p-surface-100);
  }
}

// ===== Mobile =====
@media (max-width: 768px) {
  .ai-settings-page {
    padding: 1rem;
  }

  .form-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;

    label {
      flex: none;
    }

    > :not(label) {
      width: 100%;
    }
  }

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

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
