/* AI Dashboard Styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --bg-color: #f9fafb;
  --surface-color: #ffffff;
  --border-color: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.dashboard-header {
  background-color: var(--surface-color);
  padding: 24px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.dashboard-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.last-updated {
  font-size: 14px;
  color: var(--text-secondary);
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.refresh-btn:hover {
  background-color: var(--primary-hover);
}

/* Filters Section */
.filters-section {
  background-color: var(--surface-color);
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.search-group {
  flex: 1;
  min-width: 250px;
}

.filter-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.filter-select,
.search-input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  background-color: white;
  transition: border-color 0.2s;
}

.filter-select:focus,
.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.clear-btn {
  padding: 8px 16px;
  background-color: var(--text-secondary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  align-self: flex-end;
}

.clear-btn:hover {
  background-color: var(--text-primary);
}

/* Stats Section */
.stats-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--surface-color);
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-color);
}

/* Table Container */
.table-container {
  background-color: var(--surface-color);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

/* Loading Spinner */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

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

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-spinner p {
  margin-top: 16px;
  color: var(--text-secondary);
}

/* Error Message */
.error-message {
  padding: 20px;
  background-color: #fef2f2;
  border-left: 4px solid var(--danger-color);
  color: #991b1b;
  margin: 20px;
  border-radius: 4px;
}

/* Access Table */
.access-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.access-table thead {
  background-color: var(--bg-color);
  border-bottom: 2px solid var(--border-color);
}

.access-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.access-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.access-table th.sortable:hover {
  background-color: #f3f4f6;
}

.sort-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  color: var(--text-secondary);
}

.sort-icon::after {
  content: '↕';
}

.sort-asc .sort-icon::after {
  content: '↑';
  color: var(--primary-color);
}

.sort-desc .sort-icon::after {
  content: '↓';
  color: var(--primary-color);
}

.access-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.access-table tbody tr:hover {
  background-color: var(--bg-color);
}

.access-table td {
  padding: 14px 16px;
}

.platform-col {
  text-align: center;
  width: 80px;
}

.status-col {
  width: 120px;
}

/* Access Badges */
.access-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 16px;
  cursor: help;
}

.access-badge.active {
  background-color: #d1fae5;
  color: var(--success-color);
}

.access-badge.revoked,
.access-badge.none {
  background-color: #fee2e2;
  color: var(--danger-color);
}

.access-badge.expired {
  background-color: #fef3c7;
  color: var(--warning-color);
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.active {
  background-color: #d1fae5;
  color: #065f46;
}

.status-badge.revoked {
  background-color: #fee2e2;
  color: #991b1b;
}

.status-badge.expired {
  background-color: #fef3c7;
  color: #92400e;
}

.no-data {
  text-align: center;
  padding: 40px !important;
  color: var(--text-secondary);
  font-style: italic;
}

/* Footer */
.dashboard-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.dashboard-footer a {
  color: var(--primary-color);
  text-decoration: none;
}

.dashboard-footer a:hover {
  text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .access-table {
    font-size: 13px;
  }

  .access-table th,
  .access-table td {
    padding: 10px 12px;
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .filters {
    flex-direction: column;
  }

  .filter-group,
  .search-group {
    width: 100%;
  }

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

  .table-container {
    overflow-x: auto;
  }

  .access-table {
    min-width: 900px;
  }
}

@media (max-width: 480px) {
  .dashboard-header h1 {
    font-size: 22px;
  }

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