/* dashboard.css - Consolidated Dashboard styles */
:root {
  --primary-color: #4361ee;
  --primary-dark: #3a56d4;
  --secondary-color: #7209b7;
  --success-color: #4cc9f0;
  --warning-color: #f72585;
  --danger-color: #f72585;
  --light-color: #f8f9fa;
  --dark-color: #212529;
  --gray-color: #6c757d;
  --border-color: #dee2e6;
  --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --card-shadow-hover: 0 10px 15px rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--dark-color);
  background-color: #f5f7fb;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.hidden {
  display: none !important;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.2;
}

h2 {
  font-size: 1.5rem;
  color: var(--dark-color);
}

/* Usage Table Styles */
.usage-table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #e1e5e9;
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.usage-table th {
  background: #f8f9fa;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  color: #495057;
  border-bottom: 1px solid #e1e5e9;
}

.usage-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f3f4;
}

.usage-row:hover {
  background: #f8f9fa;
}

.usage-row:last-child td {
  border-bottom: none;
}

/* Cell-specific styles */
.endpoint-cell {
  min-width: 200px;
}

.endpoint-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.endpoint-icon {
  font-size: 1rem;
}

.endpoint-name {
  font-weight: 500;
  color: #212529;
}

.credits-cell {
  text-align: center;
  min-width: 100px;
}

.credits-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.credits-used {
  background: #fff5f5;
  color: #e53e3e;
  border: 1px solid #fed7d7;
}

.credits-free {
  background: #f0fff4;
  color: #38a169;
  border: 1px solid #c6f6d5;
}

.date-cell {
  min-width: 150px;
}

.date-time {
  font-size: 0.875rem;
}

.date {
  color: #212529;
  font-weight: 500;
}

.time {
  color: #6c757d;
  font-size: 0.75rem;
}

.status-cell {
  min-width: 120px;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-completed {
  background: #e6f3ff;
  color: #1971c2;
}

.status-credits {
  background: #fff3cd;
  color: #856404;
}

.status-analytics {
  background: #d1ecf1;
  color: #0c5460;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}

.empty-message {
  color: #6c757d;
}

.empty-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .usage-table {
    font-size: 0.875rem;
  }
  
  .usage-table th,
  .usage-table td {
    padding: 8px 12px;
  }
  
  .endpoint-cell {
    min-width: 150px;
  }
}
/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  gap: 0.5rem;
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.25);
}

.btn.primary {
  background-color: var(--primary-color);
  color: white;
}

.btn.primary:hover {
  background-color: var(--primary-dark);
}

.btn.secondary {
  background-color: white;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.btn.secondary:hover {
  background-color: #f8f9fa;
}

.btn.small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn.full-width {
  width: 100%;
}

/* ===== HEADER ===== */
.topbar {
  background-color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 15px;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--dark-color);
  font-weight: 700;
  font-size: 1.25rem;
  gap: 0.5rem;
}

.logo {
  font-size: 1.5rem;
}

.menu {
  display: flex;
  gap: 1.5rem;
}

.menu a {
  text-decoration: none;
  color: var(--dark-color);
  font-weight: 500;
  transition: var(--transition);
}

.menu a:hover {
  color: var(--primary-color);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-email {
  font-weight: 500;
  color: var(--gray-color);
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-container {
  padding: 2rem 0;
  background: var(--light-color);
  min-height: calc(100vh - 60px);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.dashboard-card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  transition: var(--transition);
}

.dashboard-card:hover {
  box-shadow: var(--card-shadow-hover);
}

.dashboard-card.full-width {
  grid-column: 1 / -1;
}

.dashboard-card h2 {
  margin: 0 0 1.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
}

/* ===== CREDITS CARD ===== */
.credits-display {
  margin: 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.credit-balance {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.credit-amount {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

.credit-label {
  font-size: 0.875rem;
  color: var(--gray-color);
  margin-top: 0.5rem;
}

.credit-limits {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  gap: 0.5rem;
}

.limit-item {
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.limit-label {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-color);
  margin-bottom: 0.25rem;
}

.limit-value {
  display: block;
  font-weight: 600;
  color: #333;
}

.credits-actions {
  display: flex;
  gap: 0.75rem;
}

.credits-actions .btn {
  flex: 1;
}

/* ===== ALERTS ===== */
.alert {
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
}

.alert.warning {
  background-color: #fff3cd;
  border: 1px solid #ffeaa7;
  color: #856404;
}

.alert.success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.alert.info {
  background-color: #cce7ff;
  border: 1px solid #99ceff;
  color: #004085;
}

.alert-content {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.alert-text {
  flex: 1;
}

.alert-text strong {
  display: block;
  margin-bottom: 0.25rem;
}

.alert-text p {
  margin: 0;
  font-size: 0.875rem;
}

/* ===== API KEY SECTION ===== */
.api-key-display {
  background-color: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  font-family: monospace;
  word-break: break-all;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow-x: auto;
}

.api-key-copied {
  background: #d4edda !important;
  border-color: #c3e6cb !important;
  transition: all 0.3s ease;
}

/* ===== FORM STYLES ===== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.25);
}

.form-group input[readonly] {
  background-color: #f8f9fa;
  cursor: not-allowed;
}

.verification-status {
  margin-top: 0.5rem;
}

.status {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status.verified {
  background-color: #d4edda;
  color: #155724;
}

.status.unverified {
  background-color: #f8d7da;
  color: #721c24;
}

/* ===== USAGE LIST ===== */
.usage-list {
  max-height: 400px;
  overflow-y: auto;
}

.usage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.usage-item:last-child {
  border-bottom: none;
}

.usage-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.usage-endpoint {
  font-weight: 500;
  color: #333;
}

.usage-credits {
  font-size: 0.875rem;
  color: var(--danger-color);
  font-weight: 600;
}

.usage-time {
  font-size: 0.875rem;
  color: var(--gray-color);
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--gray-color);
}

.loading {
  text-align: center;
  padding: 1rem;
  color: var(--gray-color);
}

/* ===== QUICK ACTIONS ===== */
.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  gap: 0.5rem;
}

.action-btn:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.action-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 992px) {
  .dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .topbar-inner {
    flex-direction: column;
    gap: 1rem;
  }

  .menu {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .user-menu {
    width: 100%;
    justify-content: space-between;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .credits-display {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .credit-limits {
    flex-direction: column;
    gap: 1rem;
  }

  .limit-item {
    flex-direction: column;
    gap: 0.5rem;
  }

  .credits-actions {
    flex-direction: column;
  }

  .action-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .usage-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .alert-content {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 576px) {
  .action-buttons {
    grid-template-columns: 1fr;
  }
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #212529;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6c757d;
}

.modal-close:hover {
  color: #212529;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid #dee2e6;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ===== DARK MODE ===== */
:root[data-theme="dark"] body {
  background-color: #0f172a;
  color: #f1f5f9;
}

:root[data-theme="dark"] h2 {
  color: #f1f5f9;
}

:root[data-theme="dark"] .topbar {
  background-color: #1e293b;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .brand {
  color: #f1f5f9;
}

:root[data-theme="dark"] .menu a {
  color: #cbd5e1;
}

:root[data-theme="dark"] .user-email {
  color: #94a3b8;
}

:root[data-theme="dark"] .dashboard-container {
  background: #0f172a;
}

:root[data-theme="dark"] .dashboard-card {
  background: #1e293b;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .dashboard-card:hover {
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .dashboard-card h2 {
  color: #f1f5f9;
}

:root[data-theme="dark"] .credit-balance {
  border-bottom-color: #334155;
}

:root[data-theme="dark"] .limit-value {
  color: #f1f5f9;
}

/* Usage table */
:root[data-theme="dark"] .usage-table-container {
  border-color: #334155;
}

:root[data-theme="dark"] .usage-table {
  background: #1e293b;
}

:root[data-theme="dark"] .usage-table th {
  background: #0f172a;
  color: #94a3b8;
  border-bottom-color: #334155;
}

:root[data-theme="dark"] .usage-table td {
  border-bottom-color: #283448;
  color: #cbd5e1;
}

:root[data-theme="dark"] .usage-row:hover {
  background: #162032;
}

:root[data-theme="dark"] .endpoint-name {
  color: #f1f5f9;
}

:root[data-theme="dark"] .date {
  color: #f1f5f9;
}

:root[data-theme="dark"] .credits-used {
  background: #1f0d0d;
  color: #fca5a5;
  border-color: #3d1a1a;
}

:root[data-theme="dark"] .credits-free {
  background: #0d1f0d;
  color: #86efac;
  border-color: #1a3d1a;
}

:root[data-theme="dark"] .status-completed {
  background: #0a1830;
  color: #93c5fd;
}

:root[data-theme="dark"] .status-credits {
  background: #1c1a0a;
  color: #fcd34d;
}

:root[data-theme="dark"] .status-analytics {
  background: #071820;
  color: #67e8f9;
}

/* API key */
:root[data-theme="dark"] .api-key-display {
  background-color: #0f172a;
  border-color: #334155;
  color: #93c5fd;
}

:root[data-theme="dark"] .api-key-copied {
  background: #0d1f0d !important;
  border-color: #1a3d1a !important;
}

/* Forms */
:root[data-theme="dark"] .form-group input,
:root[data-theme="dark"] .form-group select {
  background-color: #0f172a;
  color: #f1f5f9;
  border-color: #334155;
}

:root[data-theme="dark"] .form-group input::placeholder {
  color: #64748b;
}

:root[data-theme="dark"] .form-group input:focus,
:root[data-theme="dark"] .form-group select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.35);
}

:root[data-theme="dark"] .form-group input[readonly] {
  background-color: #0b1120;
  color: #64748b;
}

:root[data-theme="dark"] .status.verified {
  background-color: #0d1f0d;
  color: #86efac;
}

:root[data-theme="dark"] .status.unverified {
  background-color: #1f0d0d;
  color: #fca5a5;
}

/* Usage list */
:root[data-theme="dark"] .usage-item {
  border-bottom-color: #334155;
}

:root[data-theme="dark"] .usage-endpoint {
  color: #f1f5f9;
}

/* Action buttons */
:root[data-theme="dark"] .action-btn {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

:root[data-theme="dark"] .action-btn:hover {
  border-color: var(--primary-color);
  background: #162032;
}

/* Buttons */
:root[data-theme="dark"] .btn.secondary {
  background-color: #1e293b;
  color: #93c5fd;
  border-color: var(--primary-color);
}

:root[data-theme="dark"] .btn.secondary:hover {
  background-color: #162032;
}

/* Alerts */
:root[data-theme="dark"] .alert.warning {
  background-color: #1c1a0a;
  border-color: #3d3200;
  color: #fcd34d;
}

:root[data-theme="dark"] .alert.success {
  background-color: #0a1c0f;
  border-color: #1a3d25;
  color: #86efac;
}

:root[data-theme="dark"] .alert.info {
  background-color: #0a1525;
  border-color: #1a3050;
  color: #93c5fd;
}

/* Modal */
:root[data-theme="dark"] .modal-content {
  background: #1e293b;
  color: #f1f5f9;
}

:root[data-theme="dark"] .modal-header {
  border-bottom-color: #334155;
}

:root[data-theme="dark"] .modal-header h3 {
  color: #f1f5f9;
}

:root[data-theme="dark"] .modal-close {
  color: #64748b;
}

:root[data-theme="dark"] .modal-close:hover {
  color: #f1f5f9;
}

:root[data-theme="dark"] .modal-footer {
  border-top-color: #334155;
}

/* Empty/loading states */
:root[data-theme="dark"] .empty-state,
:root[data-theme="dark"] .loading {
  color: #64748b;
}

/* ===== RESPONSIVE (additional) ===== */
@media (max-width: 480px) {
  .topbar-inner {
    padding: 0.75rem 12px;
  }

  .menu {
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .dashboard-card {
    padding: 1rem;
  }

  .action-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .credits-actions {
    flex-direction: column;
  }

  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }
}
