/* ============================================================
   HardTech Mobile Panel — Design System
   Dark, Premium, Mobile-First
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Color Palette */
  --bg-base:        #080810;
  --bg-surface:     #0f0f1a;
  --bg-card:        #141428;
  --bg-elevated:    #1a1a35;
  --border:         rgba(99, 102, 241, 0.12);
  --border-hover:   rgba(99, 102, 241, 0.35);

  /* Accent Colors */
  --accent:         #6366f1;
  --accent-soft:    rgba(99, 102, 241, 0.12);
  --accent-glow:    rgba(99, 102, 241, 0.4);
  --cyan:           #22d3ee;
  --cyan-soft:      rgba(34, 211, 238, 0.1);
  --emerald:        #10b981;
  --emerald-soft:   rgba(16, 185, 129, 0.1);
  --amber:          #f59e0b;
  --amber-soft:     rgba(245, 158, 11, 0.1);
  --rose:           #f43f5e;
  --rose-soft:      rgba(244, 63, 94, 0.1);
  --violet:         #a855f7;
  --violet-soft:    rgba(168, 85, 247, 0.1);

  /* Text */
  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #4b5563;
  --text-accent:    #818cf8;

  /* Spacing & Radii */
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   18px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.25);

  /* Sidebar */
  --sidebar-w: 260px;
  --header-h:  64px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent); }

/* ============================================================
   LAYOUT
   ============================================================ */
.panel-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.sidebar-logo .logo-text { line-height: 1.2; }
.sidebar-logo .logo-text h2 { font-size: .95rem; font-weight: 700; color: var(--text-primary); }
.sidebar-logo .logo-text span { font-size: .72rem; color: var(--text-secondary); letter-spacing: .5px; }

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

.nav-section-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  transition: all .2s;
  cursor: pointer;
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-hover);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--rose);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

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

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
  transition: background .2s;
}
.user-card:hover { background: var(--bg-elevated); }

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .user-name { font-size: .82rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .user-role { font-size: .7rem; color: var(--text-secondary); }
.user-credits { font-size: .8rem; font-weight: 700; color: var(--accent); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Top Header ---- */
.top-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
}

.page-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.page-title p {
  font-size: .75rem;
  color: var(--text-secondary);
}

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

/* ---- Page body ---- */
.page-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: var(--border-hover); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Stat Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.accent::before  { background: var(--accent); }
.stat-card.cyan::before    { background: var(--cyan); }
.stat-card.emerald::before { background: var(--emerald); }
.stat-card.amber::before   { background: var(--amber); }
.stat-card.rose::before    { background: var(--rose); }
.stat-card.violet::before  { background: var(--violet); }

.stat-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.stat-icon.accent  { background: var(--accent-soft);  color: var(--accent); }
.stat-icon.cyan    { background: var(--cyan-soft);    color: var(--cyan); }
.stat-icon.emerald { background: var(--emerald-soft); color: var(--emerald); }
.stat-icon.amber   { background: var(--amber-soft);   color: var(--amber); }
.stat-icon.rose    { background: var(--rose-soft);    color: var(--rose); }
.stat-icon.violet  { background: var(--violet-soft);  color: var(--violet); }

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-label { font-size: .78rem; color: var(--text-secondary); font-weight: 500; }

.stat-delta {
  font-size: .72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}
.stat-delta.up   { color: var(--emerald); }
.stat-delta.down { color: var(--rose); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: .825rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}
.btn-primary:hover { background: #4f52e0; box-shadow: 0 0 24px var(--accent-glow); transform: translateY(-1px); color: #fff; }

.btn-ghost {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border-hover); background: var(--bg-elevated); color: var(--accent); }

.btn-danger {
  background: var(--rose-soft);
  color: var(--rose);
  border: 1px solid rgba(244,63,94,.2);
}
.btn-danger:hover { background: var(--rose); color: #fff; }

.btn-success {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid rgba(16,185,129,.2);
}
.btn-success:hover { background: var(--emerald); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: .77rem; }
.btn-lg { padding: 11px 22px; font-size: .925rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-md); }

/* ---- Badges / Pills ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: .7rem;
  font-weight: 600;
}
.badge-active   { background: var(--emerald-soft); color: var(--emerald); border: 1px solid rgba(16,185,129,.2); }
.badge-suspended{ background: var(--rose-soft);    color: var(--rose);    border: 1px solid rgba(244,63,94,.2); }
.badge-warning  { background: var(--amber-soft);   color: var(--amber);   border: 1px solid rgba(245,158,11,.2); }
.badge-inactive { background: var(--bg-elevated);  color: var(--text-muted); border: 1px solid var(--border); }
.badge-admin    { background: var(--violet-soft);  color: var(--violet);  border: 1px solid rgba(168,85,247,.2); }
.badge-master   { background: var(--accent-soft);  color: var(--accent);  border: 1px solid var(--border-hover); }
.badge-reseller { background: var(--cyan-soft);    color: var(--cyan);    border: 1px solid rgba(34,211,238,.2); }
.badge-online   { background: var(--emerald-soft); color: var(--emerald); border: 1px solid rgba(16,185,129,.2); animation: pulse-online 2s infinite; }
.badge-offline  { background: var(--bg-elevated);  color: var(--text-muted); border: 1px solid var(--border); }

@keyframes pulse-online {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
  50%       { box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
thead th { padding: 11px 14px; font-size: .75rem; font-weight: 600; color: var(--text-secondary); text-align: left; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:hover { background: var(--bg-elevated); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 13px 14px; font-size: .845rem; color: var(--text-primary); }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: .875rem;
  font-family: 'Inter', sans-serif;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform .25s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; transition: color .2s; }
.modal-close:hover { color: var(--text-primary); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: .845rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-error   { background: var(--rose-soft);    border: 1px solid rgba(244,63,94,.2);   color: var(--rose); }
.alert-success { background: var(--emerald-soft); border: 1px solid rgba(16,185,129,.2);  color: var(--emerald); }
.alert-warning { background: var(--amber-soft);   border: 1px solid rgba(245,158,11,.2);  color: var(--amber); }
.alert-info    { background: var(--accent-soft);  border: 1px solid var(--border-hover);  color: var(--accent); }

/* ---- Device Row Indicator ---- */
.device-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.device-status-dot.online  { background: var(--emerald); box-shadow: 0 0 6px var(--emerald); }
.device-status-dot.offline { background: var(--text-muted); }
.device-status-dot.suspended { background: var(--rose); }

/* ---- Grid layouts ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 10px; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }

/* ---- Separator ---- */
.sep { height: 1px; background: var(--border); margin: 20px 0; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
}

/* ---- Utility ---- */
.text-accent   { color: var(--accent); }
.text-cyan     { color: var(--cyan); }
.text-emerald  { color: var(--emerald); }
.text-amber    { color: var(--amber); }
.text-rose     { color: var(--rose); }
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.font-mono     { font-family: 'JetBrains Mono', 'Courier New', monospace; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Loading spinner ---- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
