/* ===================================
   CSS Variables & Base Styles
   =================================== */
:root {
  --bg-primary: #0a0a12;
  --bg-secondary: #12121c;
  --bg-card: rgba(20, 20, 32, 0.9);
  --bg-hover: rgba(40, 40, 60, 0.4);
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #5a5a70;
  --accent-blue: #5a9cff;
  --accent-green: #2dd465;
  --accent-red: #f05555;
  --accent-purple: #b366f9;
  --accent-orange: #ff8833;
  --border-color: rgba(255, 255, 255, 0.06);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --radius-sm: 5px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.4;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

/* ===================================
   Login Screen
   =================================== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
  background: linear-gradient(135deg, #0a0a12 0%, #12121c 50%, #0f1525 100%);
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.logo {
  font-size: 36px;
  margin-bottom: 12px;
}

.login-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 12px;
}

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

.input-group input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: all 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.06);
}

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

.error-message {
  color: var(--accent-red);
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

/* ===================================
   Buttons
   =================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-blue) 0%, #4080e0 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(90, 156, 255, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

/* ===================================
   Dashboard Layout
   =================================== */
.dashboard {
  padding: 16px 20px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-small {
  font-size: 20px;
}

.header-left h1 {
  font-size: 15px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon {
  font-size: 12px;
}

/* Live indicator */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--accent-green);
  padding: 4px 8px;
  background: rgba(45, 212, 101, 0.1);
  border-radius: 4px;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.stat-icon.blue {
  background: rgba(90, 156, 255, 0.15);
}

.stat-icon.green {
  background: rgba(45, 212, 101, 0.15);
}

.stat-icon.red {
  background: rgba(240, 85, 85, 0.15);
}

.stat-icon.purple {
  background: rgba(179, 102, 249, 0.15);
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===================================
   Filters Card
   =================================== */
.filters-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

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

.search-input {
  width: 100%;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
}

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

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

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group label {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-select,
.date-input {
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
  min-width: 100px;
}

.filter-select:focus,
.date-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* ===================================
   Logs Table
   =================================== */
.logs-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

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

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

.logs-table th,
.logs-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.logs-table th {
  background: rgba(255, 255, 255, 0.02);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  position: sticky;
  top: 0;
}

.logs-table tbody tr {
  transition: background 0.15s;
}

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

.logs-table td {
  font-size: 12px;
}

.logs-table tbody tr:last-child td {
  border-bottom: none;
}

.loading-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 30px !important;
}

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
}

/* New row animation */
.logs-table tbody tr.new-row {
  animation: highlightNew 2s ease-out;
}

@keyframes highlightNew {
  0% {
    background: rgba(90, 156, 255, 0.2);
  }

  100% {
    background: transparent;
  }
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.status-badge.success {
  background: rgba(45, 212, 101, 0.12);
  color: var(--accent-green);
}

.status-badge.failed {
  background: rgba(240, 85, 85, 0.12);
  color: var(--accent-red);
}

.status-badge.pending {
  background: rgba(255, 136, 51, 0.12);
  color: var(--accent-orange);
}

/* Event Badge */
.event-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.event-badge.add_to_cart {
  background: rgba(90, 156, 255, 0.12);
  color: var(--accent-blue);
}

.event-badge.purchase {
  background: rgba(179, 102, 249, 0.12);
  color: var(--accent-purple);
}

/* Details Button */
.details-btn {
  padding: 3px 8px;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.details-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

/* CID/TXID styling */
.mono {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 11px;
  color: var(--text-secondary);
}

.time-cell {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ===================================
   Pagination
   =================================== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
}

.pagination-info {
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-info {
  color: var(--text-muted);
}

/* ===================================
   Modal
   =================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 75vh;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.modal-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(75vh - 60px);
}

.detail-row {
  display: flex;
  margin-bottom: 10px;
  font-size: 12px;
}

.detail-label {
  width: 100px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.detail-value {
  flex: 1;
  word-break: break-all;
  color: var(--text-secondary);
}

.detail-value.mono {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 10px;
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .dashboard {
    padding: 12px;
  }

  .header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-group {
    min-width: 100%;
  }

  .filter-group {
    width: 100%;
    justify-content: space-between;
  }

  .filter-select,
  .date-input {
    flex: 1;
  }

  .pagination {
    flex-direction: column;
    gap: 8px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 10px;
  }
}