/* License System - Custom Styles */

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #3b82f6;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --radius: 0.5rem;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: #f3f4f6;
}

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

.fade-in { animation: fadeIn .25s ease both; }
.spin { animation: spin 1s linear infinite; }

/* ── Layout ─────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.page { min-height: 100vh; display: flex; flex-direction: column; }
.main-content { flex: 1; padding: 2rem 0; }

/* ── Navbar ─────────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .875rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.navbar-logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--brand);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.navbar-links { display: flex; align-items: center; gap: 1.5rem; }
.navbar-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: color .15s;
}
.navbar-links a:hover { color: var(--brand); }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-weight: 600; font-size: 1.05rem; color: var(--text); }
.card-body { padding: 1.5rem; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.125rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: .9rem;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #e5e7eb; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-outline { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn-outline:hover:not(:disabled) { background: #eff6ff; }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: .375rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: .5625rem .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-input.error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.form-hint { color: var(--text-muted); font-size: .8rem; margin-top: .25rem; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .625rem;
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 600;
}

.badge-green { background: #dcfce7; color: #16a34a; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-yellow { background: #fef3c7; color: #d97706; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-purple { background: #f3e8ff; color: #9333ea; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  padding: .875rem 1.125rem;
  border-radius: var(--radius);
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  margin-bottom: 1rem;
}

.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #d97706; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #2563eb; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-container { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: #f9fafb;
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: .875rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text);
}

tbody tr:hover { background: #f9fafb; }
tbody tr:last-child td { border-bottom: none; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border-radius: .75rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-weight: 600; font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-muted);
  line-height: 1;
  padding: .25rem;
  border-radius: .25rem;
}
.modal-close:hover { background: #f3f4f6; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
}

/* ── Sidebar layout (Admin) ─────────────────────────────────────── */
.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 57px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-section-title {
  padding: .375rem 1.25rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .625rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover { background: #f9fafb; color: var(--text); }
.sidebar-link.active { background: #eff6ff; color: var(--brand); border-left-color: var(--brand); }
.sidebar-link i { width: 16px; text-align: center; }

.dashboard-content { padding: 2rem; overflow-y: auto; }

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }

.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-label { font-size: .8rem; color: var(--text-muted); }

/* ── Pricing Cards ──────────────────────────────────────────────── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.pricing-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: .75rem;
  padding: 2rem;
  position: relative;
  transition: transform .2s, box-shadow .2s;
}

.pricing-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.pricing-card.popular { border-color: var(--brand); }

.pricing-card .popular-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  color: #fff;
  padding: .2rem .875rem;
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.pricing-name { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.pricing-price { font-size: 2.5rem; font-weight: 800; color: var(--text); margin: .5rem 0; }
.pricing-price sup { font-size: 1.25rem; font-weight: 600; }
.pricing-period { font-size: .875rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.pricing-features { list-style: none; padding: 0; margin: 0 0 1.5rem 0; }
.pricing-features li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem 0;
  font-size: .9rem;
}
.pricing-features li i { color: var(--success); font-size: .8rem; }

/* ── License Key ────────────────────────────────────────────────── */
.license-key {
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--brand);
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  padding: .625rem 1rem;
  border-radius: var(--radius);
  display: inline-block;
  user-select: all;
  cursor: copy;
}

/* ── Device list ────────────────────────────────────────────────── */
.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}

.device-info { display: flex; align-items: center; gap: .875rem; }
.device-icon {
  width: 40px;
  height: 40px;
  border-radius: .5rem;
  background: #eff6ff;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

.device-name { font-weight: 600; font-size: .9rem; }
.device-meta { font-size: .8rem; color: var(--text-muted); }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs { border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; display: flex; gap: 0; }
.tab-btn {
  padding: .75rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Loading ────────────────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 1rem;
  color: var(--text-muted);
}

.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: .25rem;
}
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Auth pages ─────────────────────────────────────────────────── */
.auth-container {
  max-width: 420px;
  margin: 3rem auto;
  padding: 0 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo .logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: #fff;
  font-size: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .75rem;
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.auth-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: .25rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 1.75rem; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.mobile-open { display: block; position: fixed; z-index: 80; width: 240px; height: 100vh; top: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; margin: 0; border-radius: .75rem .75rem 0 0; position: fixed; bottom: 0; }
}

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