/* ============================================================
   MoltSearch Developer Portal - Stylesheet
   Dark theme: #0a0a0a bg, #1a1a2e cards, #e94560 accent
   ============================================================ */

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

:root {
  --bg: #0a0a0a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #22223a;
  --bg-sidebar: #0e0e16;
  --bg-input: #151520;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --accent-dim: rgba(233, 69, 96, 0.15);
  --success: #16c784;
  --success-dim: rgba(22, 199, 132, 0.15);
  --warning: #f39c12;
  --info: #3498db;
  --danger: #e94560;
  --text: #e0e0e0;
  --text-secondary: #9a9ab0;
  --text-muted: #6b6b80;
  --border: #2a2a3e;
  --border-light: #333350;
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

/* ---- Auth Pages (Login/Register) ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 40px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-logo h1 span { color: var(--accent); }

.auth-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.auth-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Form Elements ---- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input::placeholder { color: var(--text-muted); }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.form-check label {
  font-size: 13px;
  color: var(--text-secondary);
}

.form-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--accent-dim); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

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

/* ---- Layout (Dashboard pages) ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-size: 18px;
  font-weight: 800;
}

.sidebar-logo h1 span { color: var(--accent); }

.sidebar-logo p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.sidebar-footer .user-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.stat-card .stat-value.accent { color: var(--accent); }
.stat-card .stat-value.success { color: var(--success); }

/* ---- Tables ---- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

thead {
  background: rgba(255,255,255,0.03);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active {
  background: var(--success-dim);
  color: var(--success);
}

.badge-revoked {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ---- Code Snippet ---- */
.code-snippet {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  position: relative;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text-secondary);
}

.code-snippet .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.code-snippet .copy-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.code-snippet .copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

/* ---- Key Display ---- */
.key-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--success);
  margin-bottom: 12px;
  word-break: break-all;
}

/* ---- Credit Packages ---- */
.packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.package-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.package-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.package-card.popular {
  border-color: var(--accent);
  position: relative;
}

.package-card.popular::before {
  content: 'Best Value';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.package-card h4 {
  font-size: 16px;
  margin-bottom: 8px;
}

.package-card .price {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.package-card .credits {
  font-size: 14px;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 12px;
}

.package-card .per-credit {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

.toast .toast-message { font-size: 13px; flex: 1; }
.toast .toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Loading Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 40%; margin-bottom: 12px; }
.skeleton-stat { height: 40px; width: 60%; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 480px;
}

.modal h3 { font-size: 18px; margin-bottom: 16px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* ---- Chart Container ---- */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.chart-container h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .packages-grid { grid-template-columns: 1fr; }
  .auth-container { padding: 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
