/* StudyPass Admin Dashboard Stylesheet */

:root {
  --bg-dark: #09090b;
  --bg-card: #121215;
  --bg-elevated: #18181b;
  --border-subtle: #27272a;
  --border-focus: #f43f5e;
  
  --primary: #f43f5e;
  --primary-hover: #e11d48;
  --accent: #fb7185;
  
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --warning: #eab308;
  --warning-bg: rgba(234, 179, 8, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background Ambient Lighting */
.ambient-glow {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
}

.glow-top {
  top: -100px;
  right: 10%;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(244, 63, 94, 0.08) 0%, transparent 70%);
}

.glow-bottom {
  bottom: 0;
  left: 5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(225, 29, 72, 0.05) 0%, transparent 70%);
}

.font-mono {
  font-family: var(--font-mono);
}

/* Typography Helpers */
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-dim); }
.text-right { text-align: right; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  font-family: var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.25);
}

.btn-primary:hover {
  opacity: 0.94;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #27272a;
  border-color: #3f3f46;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.btn-accent {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.35);
  color: var(--accent);
}

.btn-accent:hover {
  background: rgba(244, 63, 94, 0.25);
}

.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
}

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

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 5px;
}

.btn-full {
  width: 100%;
}

.btn-icon-only {
  padding: 8px 12px;
}

/* =========================================================================
   AUTH SCREEN
   ========================================================================= */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  background: var(--bg-dark);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  position: relative;
  z-index: 2;
}

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

.auth-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

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

.auth-header p {
  font-size: 13px;
  color: var(--text-dim);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  padding: 10px 14px;
  padding-right: 40px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  font-family: var(--font-mono);
}

.password-wrap input:focus {
  border-color: var(--border-focus);
}

.btn-vis {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.6;
}

.btn-vis:hover { opacity: 1; }

.auth-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: center;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
}

.auth-footer a {
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.2s;
}

.auth-footer a:hover {
  color: var(--text-main);
}

/* =========================================================================
   DASHBOARD SCREEN
   ========================================================================= */
.dashboard-screen {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Nav */
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  background: rgba(244, 63, 94, 0.12);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.api-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  display: inline-block;
}

.status-dot.active {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.stat-icon {
  font-size: 16px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--text-dim);
}

/* Section Cards */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
}

.card-head {
  margin-bottom: 20px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.pill-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.card-head h3 {
  font-size: 17px;
  font-weight: 700;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-dim);
}

/* Generator Form */
.generator-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 200px;
}

.form-col.flex-2 { flex: 2; }
.form-col.flex-1 { flex: 1; }
.btn-col { min-width: 150px; }

.generator-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.label-opt {
  font-weight: 400;
  color: var(--text-dim);
}

.preset-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-chip {
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}

.preset-chip:hover {
  background: var(--bg-elevated);
  color: #ffffff;
}

.preset-chip.active {
  background: rgba(244, 63, 94, 0.15);
  border-color: var(--primary);
  color: #ffffff;
}

.form-input, .form-select {
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  font-family: var(--font-sans);
}

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

.form-input.font-mono {
  font-family: var(--font-mono);
}

.btn-generate {
  padding: 10px 18px;
  width: 100%;
}

/* Generated Result Banner */
.generated-result {
  margin-top: 16px;
  padding: 16px;
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: 12px;
}

.result-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.result-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.result-label {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.result-code {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.05em;
}

.result-meta {
  font-size: 11px;
  color: var(--text-dim);
}

/* =========================================================================
   TABLE SECTION
   ========================================================================= */
.table-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.table-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.table-title-group h3 {
  font-size: 17px;
  font-weight: 700;
}

.table-count {
  font-size: 12px;
  color: var(--text-dim);
}

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

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0.5;
}

.search-wrap input {
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  padding: 7px 12px 7px 30px;
  border-radius: 8px;
  font-size: 12.5px;
  width: 220px;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--border-focus);
}

.filter-select {
  padding: 7px 10px;
  font-size: 12px;
}

.table-container {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.keys-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.keys-table th {
  background: #151518;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.keys-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

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

.keys-table tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

.table-loading {
  text-align: center;
  padding: 40px !important;
  color: var(--text-dim);
}

/* Key Code Cell */
.key-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-code {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #ffffff;
  font-size: 12.5px;
}

.btn-copy-inline {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.5;
  transition: opacity 0.15s;
  padding: 2px 4px;
}

.btn-copy-inline:hover {
  opacity: 1;
}

/* Tier Badges */
.tier-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.tier-1day {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.tier-7day {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.tier-monthly {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.tier-lifetime {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-active .status-indicator {
  background: var(--success);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status-expired .status-indicator {
  background: var(--danger);
}

.status-unused .status-indicator {
  background: var(--warning);
}

.expiry-hint {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}

/* Devices cell */
.devices-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s;
}

.devices-pill:hover {
  border-color: #3f3f46;
  background: #27272a;
}

/* Actions cell */
.actions-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* Footer */
.admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 10px;
}

.admin-footer a {
  color: var(--text-dim);
  text-decoration: none;
}

.admin-footer a:hover {
  color: var(--accent);
}

/* =========================================================================
   MODAL
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h4 {
  font-size: 16px;
  font-weight: 700;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
}

.btn-close-modal:hover {
  color: #ffffff;
}

.modal-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.device-modal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.device-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-id-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #ffffff;
}

.device-sub {
  font-size: 10.5px;
  color: var(--text-dim);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #18181b;
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.25s ease-out;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .dashboard-screen {
    padding: 16px 12px 40px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .table-header-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .table-filters {
    flex-direction: column;
  }
  .search-wrap input {
    width: 100%;
  }
  .filter-select {
    width: 100%;
  }
}
