/* ========================================
   Nezlu Admin Dashboard
   © 2026 Intelliquinte L.L.C.
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;500&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400&display=swap');

:root {
  --black: #0a0a0a;
  --white: #fafafa;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  --primary: #0a0a0a;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --info: #2563eb;
  
  --font-display: 'EB Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --sidebar-width: 240px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
code, pre { font-family: var(--font-mono); }

/* Utility */
.hidden { display: none !important; }
.text-muted { color: var(--gray-500); }

/* ========================================
   Loading Screen
   ======================================== */

.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--gray-50);
  z-index: 1000;
}

.loading-screen p {
  color: var(--gray-500);
  font-size: 13px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--gray-900);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   Login Screen
   ======================================== */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--gray-100);
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 40px;
  background: var(--white);
  border: 1px solid var(--gray-200);
}

.login-card h1 {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.login-card > p {
  color: var(--gray-500);
  margin-bottom: 24px;
}

.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--gray-400);
  text-align: center;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  transition: all 0.15s ease;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--gray-800);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ========================================
   Forms
   ======================================== */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  transition: border-color 0.15s;
}

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

.error-msg {
  padding: 10px 12px;
  background: #fef2f2;
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 2px solid var(--danger);
}

.error-msg:empty {
  display: none;
}

/* ========================================
   Admin Layout
   ======================================== */

.admin-app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: var(--white);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--gray-800);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header h2 {
  font-size: 1.25rem;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  background: var(--gray-700);
  border-radius: 4px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--gray-400);
  border-radius: 6px;
  margin-bottom: 4px;
  transition: all 0.15s;
}

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

.nav-item:hover {
  background: var(--gray-800);
  color: var(--white);
}

.nav-item.active {
  background: var(--gray-800);
  color: var(--white);
}

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

.user-info {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-800);
}

.user-info span {
  display: block;
  font-size: 12px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  min-height: 100vh;
}

/* ========================================
   Pages
   ======================================== */

.page {
  display: none;
}

.page.active {
  display: block;
}

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

.page-header h1 {
  font-size: 1.75rem;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--gray-500);
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  padding: 20px;
}

.stat-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--gray-900);
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  padding: 24px;
  margin-bottom: 24px;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  max-width: 300px;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  background: var(--white);
}

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

.toolbar select {
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  min-width: 160px;
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
}

.data-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-50);
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table td {
  font-size: 13px;
}

.data-table code {
  font-size: 11px;
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 3px;
}

.actions-cell {
  display: flex;
  gap: 8px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  background: var(--gray-900);
  color: var(--white);
  border-radius: 3px;
}

/* Status Badges */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 4px;
}

.status-active {
  background: #dcfce7;
  color: var(--success);
}

.status-trialing {
  background: #fef3c7;
  color: var(--warning);
}

.status-canceled,
.status-suspended,
.status-revoked {
  background: #fee2e2;
  color: var(--danger);
}

.status-past_due {
  background: #ffedd5;
  color: #ea580c;
}

/* Activity List */
.activity-list {
  max-height: 300px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

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

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-300);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-dot.new-user { background: var(--success); }
.activity-dot.subscription { background: var(--info); }
.activity-dot.canceled { background: var(--danger); }

.activity-text {
  flex: 1;
}

.activity-text strong {
  font-weight: 500;
}

.activity-time {
  font-size: 12px;
  color: var(--gray-400);
}

/* Chart */
.chart-placeholder {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  border: 1px dashed var(--gray-300);
}

.simple-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 24px;
  height: 200px;
  padding: 20px;
  width: 100%;
}

.chart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 60px;
}

.chart-bar .bar {
  width: 100%;
  background: var(--gray-900);
  min-height: 4px;
  position: relative;
  transition: height 0.3s var(--ease);
}

.chart-bar .bar-value {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
}

.chart-bar .bar-label {
  font-size: 11px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Code Block */
.code-block {
  background: var(--gray-900);
  color: var(--gray-100);
  padding: 16px;
  overflow-x: auto;
}

.code-block pre {
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ========================================
   Modal
   ======================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  background: var(--white);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
  font-size: 1.125rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--gray-400);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--gray-900);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* Detail List */
.detail-list {
  display: grid;
  gap: 16px;
}

.detail-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
}

.detail-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: 14px;
}

.detail-value code {
  font-size: 11px;
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 3px;
  word-break: break-all;
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  background: var(--gray-900);
  color: var(--white);
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.3s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.toast-info {
  background: var(--info);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .page-header-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .toolbar {
    flex-direction: column;
  }
  
  .search-input {
    max-width: none;
  }
  
  .data-table {
    display: block;
    overflow-x: auto;
  }
  
  .detail-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
