/* =========================================================================
   AlcashX Admin Console — Modern Design System (Glassmorphic & Clean)
   ========================================================================= */

:root {
  --bg-main: #0B0F19;
  --bg-surface: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-hover: #1F2937;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3B82F6;
  
  --text-main: #F9FAFB;
  --text-muted: #9CA3AF;
  --text-dim: #6B7280;

  --accent-primary: #3B82F6;
  --accent-primary-hover: #2563EB;
  --accent-success: #10B981;
  --accent-warning: #F59E0B;
  --accent-danger: #EF4444;
  --accent-purple: #8B5CF6;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================================
   Utility & Helpers
   ========================================================================= */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }

/* =========================================================================
   Buttons & Badges
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  border: 1px solid transparent;
  outline: none;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1D4ED8, #1E40AF);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger-outline {
  background: transparent;
  color: var(--accent-danger);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--accent-danger);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 0.5rem;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.btn-icon:hover {
  background: var(--bg-hover);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34D399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #F87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #FBBF24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #A78BFA; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-accent { background: rgba(59, 130, 246, 0.15); color: #60A5FA; border: 1px solid rgba(59, 130, 246, 0.3); }

/* =========================================================================
   Auth Screen (Login)
   ========================================================================= */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: radial-gradient(circle at top, #1E293B, #0B0F19);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}
.logo-badge {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.auth-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.auth-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.auth-form .form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea,
.select-input,
.search-box input {
  width: 100%;
  background: #1F2937;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.select-input:focus,
.search-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  background: #111827;
}

.btn-block { width: 100%; margin-top: 0.5rem; }

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* =========================================================================
   Dashboard Layout
   ========================================================================= */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.brand-icon { font-size: 1.75rem; }
.brand-text h1 { font-size: 1.1rem; font-weight: 800; }

.nav-menu {
  flex: 1;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.user-details {
  display: flex;
  flex-direction: column;
}
.user-name { font-size: 0.8rem; font-weight: 700; }
.user-role { font-size: 0.65rem; color: var(--accent-success); font-weight: 700; }

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}
.page-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.025em; }
.page-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.top-actions { display: flex; gap: 0.75rem; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  backdrop-filter: blur(12px);
}
.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}
.icon-blue { background: rgba(59, 130, 246, 0.15); }
.icon-green { background: rgba(16, 185, 129, 0.15); }
.icon-purple { background: rgba(139, 92, 246, 0.15); }
.icon-amber { background: rgba(245, 158, 11, 0.15); }
.icon-red { background: rgba(239, 68, 68, 0.15); }

.kpi-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.kpi-value { font-size: 1.5rem; font-weight: 800; margin-top: 0.2rem; }

/* Table Card */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-toolbar {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
  display: flex;
  align-items: center;
}
.search-box span {
  position: absolute;
  left: 0.75rem;
  font-size: 0.85rem;
  pointer-events: none;
}
.search-box input {
  padding-left: 2.25rem;
}

.filter-group {
  display: flex;
  gap: 0.75rem;
}

.table-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}
.table-header h3 { font-size: 1.1rem; font-weight: 700; }

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  background: #161F30;
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.key-pill {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #60A5FA;
  background: rgba(59, 130, 246, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.copy-icon-btn {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.copy-icon-btn:hover { opacity: 1; }

.device-hash {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.table-pagination {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
}
.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.page-number {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0 0.5rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-header h3 { font-size: 1.2rem; font-weight: 800; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}
.modal-close:hover { color: var(--text-main); }

.modal-form .form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}
.toast {
  padding: 0.75rem 1.25rem;
  background: #1F2937;
  color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.2s ease-out;
}
.toast-success { border-color: rgba(16, 185, 129, 0.5); background: #064E3B; }
.toast-error { border-color: rgba(239, 68, 68, 0.5); background: #7F1D1D; }

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