/* ═══════════════════════════════════════════════════
   PS-AUTH Dashboard — Premium Dark Theme
   ═══════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a2e;
  --bg-input: #16162a;
  --border: #2a2a45;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #55557a;
  --accent: #7c3aed;
  --accent-hover: #9333ea;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --gradient-purple: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  --gradient-blue: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
  --gradient-green: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  --gradient-orange: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ═══ SCREENS ═══ */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ═══ LOGIN ═══ */
.login-container {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 100vh; position: relative;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,58,237,0.15) 0%, transparent 60%);
}
.login-glow {
  position: absolute; top: -200px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,0.15) 0%, transparent 70%);
  animation: pulse-glow 4s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 48px 40px; width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5); position: relative; z-index: 1;
  animation: slideUp 0.6s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-logo {
  font-size: 48px; text-align: center; margin-bottom: 8px;
  filter: drop-shadow(0 0 20px var(--accent-glow));
}
.login-card h1 {
  text-align: center; font-size: 28px; font-weight: 800;
  background: var(--gradient-purple); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 32px; }
.login-footer { text-align: center; margin-top: 20px; }

/* ═══ FORMS ═══ */
.input-group { margin-bottom: 16px; }
.input-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.input-group input, .input-group select {
  width: 100%; padding: 12px 16px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 14px; font-family: inherit;
  transition: var(--transition); outline: none;
}
.input-group input:focus, .input-group select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-group input::placeholder { color: var(--text-muted); }

.btn-primary {
  width: 100%; padding: 14px; background: var(--gradient-purple);
  border: none; border-radius: var(--radius-sm); color: white;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: var(--transition); position: relative;
  font-family: inherit;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 10px 20px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px; cursor: pointer;
  transition: var(--transition); font-family: inherit;
}
.btn-secondary:hover { border-color: var(--accent); background: var(--bg-card); }

.btn-link {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 13px; font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }

.btn-sm {
  padding: 6px 12px; font-size: 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-primary); cursor: pointer; transition: var(--transition);
  font-family: inherit;
}
.btn-sm:hover { border-color: var(--accent); }
.btn-sm.danger { border-color: var(--danger); color: var(--danger); }
.btn-sm.danger:hover { background: rgba(239,68,68,0.1); }
.btn-sm.success { border-color: var(--success); color: var(--success); }
.btn-sm.success:hover { background: rgba(16,185,129,0.1); }

.error-text { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; }
.success-text { color: var(--success); font-size: 13px; margin-top: 12px; text-align: center; }

.btn-loader {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-inline {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
}
.form-inline .input-group { flex: 1; min-width: 150px; }
.form-inline .btn-primary { width: auto; padding: 12px 24px; margin-bottom: 16px; }

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: 260px; background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 24px 16px; position: fixed;
  left: 0; top: 0; bottom: 0; z-index: 10;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 12px; padding: 0 12px 24px;
  border-bottom: 1px solid var(--border); margin-bottom: 24px;
}
.logo-icon { font-size: 28px; }
.logo-text {
  font-size: 20px; font-weight: 800;
  background: var(--gradient-purple); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-menu { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: none; background: none; color: var(--text-secondary);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
  transition: var(--transition); text-align: left; width: 100%;
  font-family: inherit;
}
.nav-item:hover { background: rgba(124,58,237,0.1); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; font-weight: 600; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 16px; }
.user-info { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--gradient-purple);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; }
.user-meta span:first-child { font-weight: 600; font-size: 14px; }
.user-role {
  font-size: 11px; color: var(--accent); text-transform: uppercase;
  font-weight: 700; letter-spacing: 1px;
}
.btn-logout {
  width: 100%; padding: 10px; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  cursor: pointer; font-size: 13px; transition: var(--transition);
  font-family: inherit;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ═══ MAIN CONTENT ═══ */
.main-content {
  margin-left: 260px; padding: 32px; min-height: 100vh;
}
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.page-title {
  font-size: 24px; font-weight: 700; margin-bottom: 24px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}

/* ═══ STATS ═══ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
  padding: 24px; border-radius: var(--radius); position: relative;
  overflow: hidden; color: white;
}
.stat-card.gradient-purple { background: var(--gradient-purple); }
.stat-card.gradient-blue { background: var(--gradient-blue); }
.stat-card.gradient-green { background: var(--gradient-green); }
.stat-card.gradient-orange { background: var(--gradient-orange); }
.stat-value { font-size: 36px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; opacity: 0.85; margin-top: 8px; }
.stat-icon {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  font-size: 40px; opacity: 0.3;
}

/* ═══ CARDS & TABLES ═══ */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
}
.card h3 { font-size: 16px; margin-bottom: 16px; color: var(--text-primary); }

.toolbar {
  display: flex; gap: 12px; margin-bottom: 16px; align-items: center;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px; font-size: 12px;
  text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); font-weight: 600;
}
.data-table td {
  padding: 12px 16px; font-size: 13px; border-bottom: 1px solid rgba(42,42,69,0.5);
  color: var(--text-secondary);
}
.data-table tr:hover td { background: rgba(124,58,237,0.05); }

.credit-cost {
  font-weight: 700; color: var(--warning); text-align: center;
}

.role-badge {
  padding: 4px 10px; border-radius: 20px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  display: inline-block;
}
.role-badge.free { background: rgba(136,136,168,0.2); color: var(--text-secondary); }
.role-badge.plus { background: rgba(59,130,246,0.2); color: var(--info); }
.role-badge.vip { background: rgba(245,158,11,0.2); color: var(--warning); }
.role-badge.admin { background: rgba(124,58,237,0.2); color: var(--accent); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot.active { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.inactive { background: var(--danger); }

/* ═══ KEYS LIST ═══ */
.keys-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.key-chip {
  padding: 8px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: 'Courier New', monospace;
  font-size: 13px; cursor: pointer; transition: var(--transition);
  color: var(--success);
}
.key-chip:hover { border-color: var(--accent); transform: scale(1.02); }

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; width: 480px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5); animation: slideUp 0.3s ease;
}
.modal-card h3 { font-size: 18px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }
.modal-actions .btn-primary { width: auto; padding: 10px 24px; }
.modal-actions .btn-secondary { padding: 10px 24px; }

/* ═══ TOAST ═══ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  display: flex; flex-direction: column-reverse; gap: 8px;
}
.toast {
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-size: 13px; color: white; min-width: 280px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(100px); } }

/* ═══ QUICK CREDIT ═══ */
.quick-credit-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid rgba(42,42,69,0.5);
}
.quick-credit-info { display: flex; align-items: center; gap: 12px; }
.quick-credit-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--gradient-blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.quick-credit-meta span { display: block; }
.quick-credit-meta span:first-child { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.quick-credit-meta span:last-child { font-size: 12px; color: var(--text-muted); }
.quick-credit-actions { display: flex; gap: 8px; align-items: center; }
.quick-credit-actions span { font-weight: 700; color: var(--warning); min-width: 60px; text-align: right; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr; }
}
