/* Reset and Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
  font-family: "Geist", sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  background: #f8fafc;
  color: #334155;
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
}

/* Navigation */
.navbar {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 2rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  height: 70px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-logo {
  width: 32px;
  height: 32px;
}

.nav-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-link {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 500;
  color: #64748b;
}

.nav-link:hover,
.nav-link.active {
  color: #3b82f6;
  background: #eff6ff;
}

.nav-auth {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-indicator {
  background: #10b981;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

.logout-btn {
  background: #ef4444;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.2s;
}

.logout-btn:hover {
  background: #dc2626;
}

/* Main Content */
.main-content {
  margin-top: 70px;
  min-height: calc(100vh - 70px);
}

.dashboard-section {
  display: none;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-section.active {
  display: block;
}

.section-header {
  margin-bottom: 2rem;
}

.section-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.section-header p {
  color: #64748b;
  font-size: 1.125rem;
}

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

.stat-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
}

.stat-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.stat-icon {
  font-size: 2rem;
  background: #eff6ff;
  padding: 0.75rem;
  border-radius: 10px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
}

.stat-label {
  font-size: 0.875rem;
  color: #64748b;
  font-weight: 500;
}

/* Dashboard Widgets */
.dashboard-widget {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 2rem;
  overflow: hidden;
}

.widget-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.widget-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.refresh-btn, .search-btn, .export-btn, .save-btn {
  background: #3b82f6;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.2s;
  font-size: 0.875rem;
}

.refresh-btn:hover, .search-btn:hover, .export-btn:hover, .save-btn:hover {
  background: #2563eb;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 300px;
}

.search-box input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
}

.search-box input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#plan-filter, #limit-select {
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

#plan-filter:focus, #limit-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Tables */
.table-container {
  overflow-x: auto;
}

/* Sortable columns */
.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.2s;
}

.sortable:hover {
  background-color: #f8f9fa;
}

.sort-indicator {
  display: inline-block;
  margin-left: 8px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 4px solid #ccc;
  transition: all 0.2s;
}

.sort-indicator.asc {
  border-bottom: 4px solid #3b82f6;
  border-top: none;
}

.sort-indicator.desc {
  border-top: 4px solid #3b82f6;
  border-bottom: none;
}

.sort-indicator:not(.asc):not(.desc) {
  opacity: 0.3;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th,
.users-table td {
  text-align: left;
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.users-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #374151;
  font-size: 0.875rem;
}

.users-table td {
  font-size: 0.875rem;
}

.users-table tr:hover {
  background: #f8fafc;
}

.user-count {
  background: #e2e8f0;
  color: #64748b;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
}

/* Activity List */
.activity-list {
  padding: 1.5rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  font-size: 1.25rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-description {
  font-size: 0.875rem;
  font-weight: 500;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.activity-time {
  color: #64748b;
  font-size: 0.75rem;
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
}

.chart-widget {
  min-height: 400px;
}

.chart-container {
  padding: 1.5rem;
  height: 300px;
}

.time-range-selector {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 0.25rem;
}

.time-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s;
  color: #64748b;
}

.time-btn.active,
.time-btn:hover {
  background: white;
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
}

.settings-form {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #374151;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
}

.form-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.tools-list {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tool-btn {
  background: #6b7280;
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.2s;
  text-align: left;
}

.tool-btn:hover {
  background: #4b5563;
}

.tool-btn.danger {
  background: #ef4444;
}

.tool-btn.danger:hover {
  background: #dc2626;
}

/* Loading States */
.loading {
  text-align: center;
  color: #64748b;
  padding: 2rem;
  font-style: italic;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  flex-direction: column;
  gap: 1rem;
}

.loading-overlay.show {
  display: flex;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  color: #64748b;
  font-weight: 500;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 2rem;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.modal-close {
  background: none;
  color: #64748b;
  font-size: 1.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #374151;
  background: #f1f5f9;
}

.modal-body {
  padding: 1.5rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

.page-btn {
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.page-btn:hover,
.page-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
  .navbar {
    padding: 0 1rem;
  }
  
  .nav-container {
    flex-direction: column;
    height: auto;
    padding: 1rem 0;
    gap: 1rem;
  }
  
  .nav-links {
    gap: 1rem;
  }
  
  .main-content {
    margin-top: 120px;
  }
  
  .dashboard-section {
    padding: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    min-width: auto;
  }
  
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* Action Buttons */
.action-btn {
  background: #10b981;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-right: 0.5rem;
  transition: background 0.2s;
}

.action-btn:hover {
  background: #059669;
}

.action-btn.danger {
  background: #ef4444;
}

.action-btn.danger:hover {
  background: #dc2626;
}

/* Status Badges */
.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.status-badge.starter {
  background: #f3f4f6;
  color: #374151;
}

.status-badge.pro {
  background: #dbeafe;
  color: #1d4ed8;
}

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

/* Pagination Styles */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding: 20px 0;
}

.pagination-btn {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  color: #495057;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  min-width: 40px;
  text-align: center;
  font-weight: 500;
}

.pagination-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.pagination-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.pagination-btn:disabled {
  background: #f8f9fa;
  border-color: #dee2e6;
  color: #6c757d;
  cursor: not-allowed;
  opacity: 0.5;
}

.pagination-ellipsis {
  color: #6c757d;
  padding: 8px 4px;
  font-size: 14px;
}

.pagination-info {
  color: #6c757d;
  font-size: 14px;
  margin-left: 16px;
  white-space: nowrap;
  font-weight: 500;
}
