/* ================================================
   SmartWiFi QR — Custom Stylesheet
   ================================================ */

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

:root {
  /* Brand Colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --secondary: #0ea5e9;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Neutrals */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  --sidebar-text: #94a3b8;
  --sidebar-active: #6366f1;
  --sidebar-hover: rgba(99,102,241,0.12);

  /* Layout */
  --topbar-height: 64px;
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --border-radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* =====================
   SIDEBAR
   ===================== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg { color: white; width: 20px; height: 20px; }

.sidebar-logo-text .app-name {
  font-size: 15px; font-weight: 700; color: white; display: block; line-height: 1.2;
}
.sidebar-logo-text .app-version {
  font-size: 11px; color: var(--gray-400); font-weight: 500;
}

.sidebar-section {
  padding: 20px 12px 8px;
}

.sidebar-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--gray-500);
  padding: 0 8px; margin-bottom: 6px;
}

.sidebar-nav { list-style: none; padding: 0; margin: 0; }

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s ease;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: white;
}

.sidebar-nav a.active {
  background: linear-gradient(90deg, rgba(99,102,241,.25), rgba(99,102,241,.08));
  color: white;
  border-left: 3px solid var(--primary);
  padding-left: 9px;
}

.sidebar-nav a.active svg { color: var(--primary); }
.sidebar-nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
.sidebar-nav a:hover svg { opacity: 1; }

.sidebar-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px; text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--border-radius-sm);
  text-decoration: none;
  transition: background .2s;
}
.sidebar-user:hover { background: rgba(255,255,255,0.05); }

.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info .s-name { font-size: 13px; font-weight: 600; color: white; display: block; }
.sidebar-user-info .s-role { font-size: 11px; color: var(--gray-400); }

/* =====================
   MAIN CONTENT
   ===================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .3s;
}

.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 900;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-title {
  font-size: 16px; font-weight: 700; color: var(--gray-900);
}

.page-content {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* =====================
   STAT CARDS
   ===================== */
.stat-card {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 24px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-start; gap: 16px;
  transition: transform .2s, box-shadow .2s;
  text-decoration: none; color: inherit;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--border-radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 24px; height: 24px; }

.stat-icon.primary   { background: #eef2ff; color: var(--primary); }
.stat-icon.success   { background: #d1fae5; color: var(--success); }
.stat-icon.warning   { background: #fef3c7; color: var(--warning); }
.stat-icon.danger    { background: #fee2e2; color: var(--danger); }
.stat-icon.info      { background: #dbeafe; color: var(--info); }
.stat-icon.secondary { background: #f0f9ff; color: var(--secondary); }

.stat-content { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500); margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--gray-900); line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.stat-trend { font-size: 12px; font-weight: 600; margin-top: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* =====================
   CARDS
   ===================== */
.card-custom {
  background: white;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header-custom {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}

.card-header-custom h5 {
  font-size: 15px; font-weight: 700; color: var(--gray-900); margin: 0;
}

.card-body-custom { padding: 24px; }

/* =====================
   TABLE
   ===================== */
.table-custom { border-collapse: separate; border-spacing: 0; width: 100%; }
.table-custom thead th {
  background: var(--gray-50);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--gray-500);
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.table-custom tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background .15s;
}
.table-custom tbody tr:last-child { border-bottom: none; }
.table-custom tbody tr:hover { background: var(--gray-50); }
.table-custom tbody td { padding: 14px 16px; vertical-align: middle; }

/* =====================
   BADGES
   ===================== */
.badge-custom {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .2px;
}

.badge-primary   { background: var(--primary-light); color: var(--primary-dark); }
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-info      { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); }

/* =====================
   BUTTONS
   ===================== */
.btn-primary-custom {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border: none;
  padding: 9px 20px;
  border-radius: var(--border-radius-sm);
  font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer; text-decoration: none;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(99,102,241,.3);
}

.btn-primary-custom:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99,102,241,.4);
  color: white; text-decoration: none;
}

.btn-outline-custom {
  background: transparent;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  transition: all .2s;
}
.btn-outline-custom:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; background: var(--primary-light); }

.btn-danger-custom {
  background: transparent; color: var(--danger);
  border: 1.5px solid #fecaca;
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  transition: all .2s;
}
.btn-danger-custom:hover { background: #fee2e2; border-color: var(--danger); color: var(--danger); text-decoration: none; }

/* =====================
   FORMS
   ===================== */
.form-label-custom {
  font-size: 13px; font-weight: 600; color: var(--gray-700);
  margin-bottom: 6px; display: block;
}

.form-control-custom {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  font-size: 14px; color: var(--gray-800);
  font-family: inherit;
  background: white;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.form-control-custom:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

.form-control-custom::placeholder { color: var(--gray-400); }

/* =====================
   ALERT / FLASH
   ===================== */
.alert-custom {
  border-radius: var(--border-radius-sm);
  padding: 13px 18px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
  margin-bottom: 20px;
}

.alert-custom.success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.alert-custom.error   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.alert-custom.warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.alert-custom.info    { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* =====================
   QR CODE DISPLAY
   ===================== */
.qr-display {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  text-align: center;
  display: inline-block;
}

.qr-display img {
  border-radius: var(--border-radius-sm);
  max-width: 200px;
}

/* =====================
   CONNECT PAGE
   ===================== */
.connect-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.connect-page::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 50%, rgba(99,102,241,0.15) 0%, transparent 60%),
              radial-gradient(circle at 70% 50%, rgba(14,165,234,0.1) 0%, transparent 60%);
  pointer-events: none;
}

.connect-card {
  background: rgba(255,255,255,0.97);
  border-radius: 24px;
  padding: 40px 36px;
  max-width: 420px; width: 100%;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  text-align: center;
  position: relative; z-index: 1;
  backdrop-filter: blur(10px);
}

.connect-logo { max-height: 64px; margin-bottom: 20px; }
.connect-company { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-400); margin-bottom: 4px; }
.connect-title { font-size: 26px; font-weight: 800; color: var(--gray-900); margin-bottom: 4px; }
.connect-dept { font-size: 13px; color: var(--gray-500); margin-bottom: 28px; }

.connect-wifi-box {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 12px;
  text-align: left;
}
.connect-wifi-label { font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--gray-400); margin-bottom: 4px; }
.connect-wifi-value { font-size: 20px; font-weight: 700; color: var(--gray-900); font-family: 'SF Mono', 'Fira Code', monospace; letter-spacing: 1px; }

.connect-password-row { display: flex; align-items: center; gap: 10px; }
.connect-password-text { flex: 1; font-size: 18px; font-weight: 700; color: var(--gray-900); font-family: monospace; letter-spacing: 2px; word-break: break-all; }

.btn-connect {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 15px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border: none; border-radius: 14px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  margin-top: 24px;
  box-shadow: 0 4px 20px rgba(99,102,241,.4);
}
.btn-connect:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(99,102,241,.5); color: white; text-decoration: none; }

.btn-copy {
  background: var(--gray-100); border: none; border-radius: 8px;
  padding: 8px 12px; cursor: pointer; color: var(--gray-600);
  font-size: 13px; font-weight: 600; transition: all .2s;
  display: flex; align-items: center; gap: 5px;
  flex-shrink: 0;
}
.btn-copy:hover { background: var(--primary-light); color: var(--primary); }
.btn-copy.copied { background: #d1fae5; color: var(--success); }

.device-tip {
  background: linear-gradient(135deg, #fef3c7, #fef9ec);
  border: 1px solid #fcd34d;
  border-radius: 12px; padding: 14px 18px;
  font-size: 13px; color: #92400e;
  text-align: left; margin-top: 16px;
}

/* =====================
   CHART CONTAINERS
   ===================== */
.chart-wrapper { position: relative; }
.chart-wrapper canvas { max-height: 300px; }

/* =====================
   PAGE HEADER
   ===================== */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-header-left .page-title {
  font-size: 22px; font-weight: 800; color: var(--gray-900); margin: 0;
  line-height: 1.3;
}
.page-header-left .page-subtitle {
  font-size: 13.5px; color: var(--gray-500); margin-top: 3px;
}
.page-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* =====================
   SEARCH / FILTER BAR
   ===================== */
.search-bar {
  position: relative; display: flex; align-items: center;
}
.search-bar input {
  padding: 9px 14px 9px 40px;
  border: 1.5px solid var(--gray-200); border-radius: var(--border-radius-sm);
  font-size: 13.5px; outline: none; transition: border-color .2s;
  min-width: 220px; background: white;
}
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.08); }
.search-icon { position: absolute; left: 12px; color: var(--gray-400); width: 16px; height: 16px; }

/* =====================
   AUTH LAYOUT
   ===================== */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute; top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(ellipse at 40% 50%, rgba(99,102,241,.12) 0%, transparent 50%),
              radial-gradient(ellipse at 60% 50%, rgba(14,165,234,.08) 0%, transparent 50%);
  animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  from { transform: scale(1) rotate(0deg); }
  to   { transform: scale(1.1) rotate(5deg); }
}

.auth-card {
  background: white;
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%; max-width: 440px;
  box-shadow: 0 32px 100px rgba(0,0,0,0.4);
  position: relative; z-index: 1;
  animation: slideUp .4s ease;
}

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

.auth-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px; justify-content: center;
}

.auth-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}

.auth-logo-icon svg { color: white; width: 22px; height: 22px; }
.auth-logo-text { font-size: 20px; font-weight: 800; color: var(--gray-900); }

.auth-title { font-size: 22px; font-weight: 800; color: var(--gray-900); margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--gray-500); margin-bottom: 28px; }

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

.form-input-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--gray-700); margin-bottom: 7px;
}

.form-input {
  width: 100%; padding: 12px 40px 12px 14px;
  border: 1.5px solid var(--gray-200); border-radius: var(--border-radius-sm);
  font-size: 14.5px; color: var(--gray-800); font-family: inherit;
  outline: none; transition: all .2s; background: white;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(99,102,241,.12);
}

.form-input::placeholder { color: var(--gray-400); }

.input-icon {
  position: absolute; right: 13px; top: 70%; transform: translateY(-50%);
  color: var(--gray-400); width: 17px; height: 17px;
}

.btn-auth {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border: none; border-radius: var(--border-radius-sm);
  font-size: 14.5px; font-weight: 700; cursor: pointer;
  font-family: inherit; margin-top: 8px;
  transition: all .2s;
  box-shadow: 0 4px 16px rgba(99,102,241,.35);
}

.btn-auth:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(99,102,241,.45); }

/* =====================
   SKELETON LOADER
   ===================== */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }

/* =====================
   TOOLTIPS
   ===================== */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900); color: white;
  font-size: 11.5px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
[data-tooltip]:hover::after { opacity: 1; }

/* =====================
   MISC UTILITIES
   ===================== */
.text-muted-custom { color: var(--gray-400); font-size: 12.5px; }
.divider { height: 1px; background: var(--gray-100); margin: 20px 0; }

.empty-state {
  text-align: center; padding: 60px 24px;
}
.empty-state-icon {
  width: 72px; height: 72px;
  background: var(--gray-100); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: var(--gray-400);
}
.empty-state h5 { font-size: 16px; font-weight: 700; color: var(--gray-700); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--gray-400); margin-bottom: 20px; }

/* =====================
   SIDEBAR TOGGLE
   ===================== */
.sidebar-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); padding: 6px; border-radius: 8px;
  transition: all .2s;
  display: none;
}
.sidebar-toggle-btn:hover { background: var(--gray-100); color: var(--gray-700); }

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 991px) {
  .sidebar-toggle-btn { display: flex; align-items: center; justify-content: center; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }

  .page-content { padding: 20px 16px; }
  .stat-value { font-size: 22px; }
}

@media (max-width: 576px) {
  .stat-card { flex-direction: column; gap: 10px; }
  .page-header { flex-direction: column; }
  .auth-card { padding: 32px 24px; }
}

/* =====================
   MOBILE OVERLAY
   ===================== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
.sidebar-overlay.active { display: block; }
