/* MeshOptixIQ Customer Portal Styles
 * Uses the same design system as the marketing site.
 * Update these variables to stay in sync with website/css/main.css
 */

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

:root {
  --bg-body: #121212;
  --bg-surface: rgba(255, 255, 255, 0.05);
  --bg-surface-hover: rgba(255, 255, 255, 0.08);
  --bg-card: #1a1a1a;

  --primary: #60A5FA;
  --primary-glow: rgba(96, 165, 250, 0.4);
  --secondary: #A78BFA;
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;

  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --text-accent: #93C5FD;

  --border-color: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(96, 165, 250, 0.3);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-lg: 16px;
  --radius-md: 8px;
  --radius-sm: 4px;

  --sidebar-width: 220px;
  --topbar-height: 64px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */

.portal-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 50;
}

.sidebar-logo {
  display: block;
  padding: 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-accent);
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
}

.sidebar-logo:hover {
  color: var(--text-main);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  list-style: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.2s, background 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--text-main);
  background: var(--bg-surface);
  text-decoration: none;
}

.sidebar-nav a.active {
  color: var(--primary);
  border-right: 2px solid var(--primary);
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.page-body {
  padding: 2rem;
  max-width: 960px;
}

/* ---- Auth Pages (login, signup, callback) ---- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.auth-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-accent);
  margin-bottom: 0.5rem;
}

.auth-tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* ---- Cards ---- */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.card-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, transform 0.1s;
  text-decoration: none;
}

.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--primary);
  color: #0f172a;
}

.btn--secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn--danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn--full { width: 100%; justify-content: center; }

.btn--lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
}

/* ---- Plan Badges ---- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge--starter { background: rgba(148,163,184,0.15); color: #94A3B8; }
.badge--pro     { background: rgba(96,165,250,0.15);  color: #60A5FA; }
.badge--enterprise { background: rgba(167,139,250,0.15); color: #A78BFA; }
.badge--active  { background: rgba(52,211,153,0.15); color: #34D399; }
.badge--expired { background: rgba(251,191,36,0.15); color: #FBBF24; }
.badge--revoked { background: rgba(248,113,113,0.15); color: #F87171; }
.badge--none    { background: rgba(148,163,184,0.15); color: #94A3B8; }

/* ---- License Key Display ---- */

.license-key-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
}

.license-key-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.05em;
}

/* ---- Table ---- */

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.portal-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

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

.portal-table tr:last-child td { border-bottom: none; }
.portal-table tr:hover td { background: var(--bg-surface); }

/* ---- Forms ---- */

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

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

.form-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ---- Modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.is-open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

/* ---- Alerts / Notices ---- */

.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert--info  { background: rgba(96,165,250,0.1); border: 1px solid rgba(96,165,250,0.2); color: var(--text-accent); }
.alert--warn  { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.2); color: #FBBF24; }
.alert--error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.2); color: var(--danger); }
.alert--ok    { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.2); color: var(--success); }

/* ---- Loading Spinner ---- */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  color: var(--text-muted);
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-body { padding: 1rem; }
}

/* ── Light Mode ──────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-body: #F8FAFC;
  --bg-surface: rgba(255, 255, 255, 0.7);
  --bg-surface-hover: rgba(255, 255, 255, 0.9);
  --bg-card: #ffffff;
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-accent: #2563EB;
  --border-color: rgba(148, 163, 184, 0.2);
  --border-hover: rgba(37, 99, 235, 0.2);
  --bg-input: #ffffff;
}

/* ── Theme Transition ────────────────────────────────────────────────────── */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ── Select / Dropdown Readability ───────────────────────────────────────── */
select.form-input {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394A3B8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}
select.form-input option {
  background-color: var(--bg-card, #1a1a1a);
  color: var(--text-main);
}
[data-theme="light"] select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23475569' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
}
[data-theme="light"] select.form-input option {
  background-color: #ffffff;
  color: #0F172A;
}

/* ── Theme Toggle Button ─────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text-main); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Floating toggle for auth / error pages */
.theme-toggle-float {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
}

/* ── Mobile Navigation ───────────────────────────────────────────────────── */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}
.hamburger:hover { color: var(--text-main); }

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
}
.mobile-overlay.is-open { display: block; }

@media (max-width: 768px) {
  .hamburger { display: block; }

  .sidebar {
    display: block !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
}
