/* ==========================================================================
   Lab Design System
   Dark glass-morphism theme with #22d3a0 accent
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
  /* Backgrounds */
  --bg-base: #050507;
  --bg-elevated: #0c0c10;
  --bg-card: rgba(255, 255, 255, 0.02);
  --bg-card-solid: #0f0f14;
  --bg-card-hover: rgba(255, 255, 255, 0.04);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-card: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(255, 255, 255, 0.1);

  /* Text */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-tertiary: rgba(255, 255, 255, 0.35);
  --text-muted: rgba(255, 255, 255, 0.35);

  /* Palette */
  --accent: #22d3a0;
  --accent-glow: rgba(34, 211, 160, 0.15);
  --accent-hover: #0d9668;
  --cyan: #22d3ee;
  --purple: #a78bfa;
  --orange: #fb923c;
  --pink: #f472b6;
  --red: #ef4444;
  --blue: #60a5fa;
  --green: #22d3a0;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;

  /* Legacy aliases */
  --bg-primary: var(--bg-base);
  --bg-secondary: var(--bg-elevated);
}

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

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(34, 211, 160, 0.06), transparent),
    radial-gradient(ellipse 60% 40% at 70% 70%, rgba(139, 92, 246, 0.04), transparent),
    radial-gradient(ellipse 50% 30% at 90% 20%, rgba(251, 146, 60, 0.03), transparent),
    var(--bg-base);
}

a { color: inherit; text-decoration: none; }

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

/* Sidebar */
.lab-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--bg-elevated) 0%, rgba(5,5,7,0.97) 100%);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}

.lab-sidebar::-webkit-scrollbar { width: 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(34, 211, 160, 0.3);
  text-decoration: none;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-glow);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.logout-btn:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Mobile hamburger */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(10, 10, 12, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 150;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.hamburger-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.hamburger-btn:hover {
  background: var(--bg-card-hover);
}

.mobile-title {
  font-size: 16px;
  font-weight: 600;
}

/* Main content area */
.lab-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.lab-content {
  padding: var(--space-xl) 40px;
  max-width: 1400px;
}

/* ---------- Typography ---------- */

.hero-title {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.1;
}

.hero-title .gradient {
  background: linear-gradient(135deg, var(--accent) 0%, var(--cyan) 50%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* ---------- Glass Card ---------- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-2xl);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%);
  pointer-events: none;
}

/* ---------- Form Elements ---------- */
input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: all 0.2s;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- Buttons ---------- */
button, .btn {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(34, 211, 160, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(34, 211, 160, 0.35);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

/* ---------- Grid Layouts ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

/* ---------- Status Indicators ---------- */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.status-dot.checking {
  background: var(--orange);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---------- Loading ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 12, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ---------- Progress Bar ---------- */
.progress-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.3s ease;
}

/* ---------- Tags ---------- */
.tag {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.tag.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(34, 211, 160, 0.3);
}

/* ---------- Dashboard Cards ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
}

.tool-card {
  background: var(--bg-card);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-2xl);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%);
  pointer-events: none;
}

.tool-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-3px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.tool-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 16px;
}

.tool-card-icon.green  { background: linear-gradient(135deg, #22d3a0, #0d9488); box-shadow: 0 8px 24px rgba(34,211,160,0.35); }
.tool-card-icon.purple { background: linear-gradient(135deg, #a78bfa, #7c3aed); box-shadow: 0 8px 24px rgba(139,92,246,0.35); }
.tool-card-icon.orange { background: linear-gradient(135deg, #fb923c, #ea580c); box-shadow: 0 8px 24px rgba(251,146,60,0.35); }
.tool-card-icon.pink   { background: linear-gradient(135deg, #f472b6, #db2777); box-shadow: 0 8px 24px rgba(244,114,182,0.35); }
.tool-card-icon.cyan   { background: linear-gradient(135deg, #22d3ee, #0891b2); box-shadow: 0 8px 24px rgba(34,211,238,0.35); }
.tool-card-icon.blue   { background: linear-gradient(135deg, #60a5fa, #2563eb); box-shadow: 0 8px 24px rgba(96,165,250,0.35); }
.tool-card-icon.amber  { background: linear-gradient(135deg, #fbbf24, #d97706); box-shadow: 0 8px 24px rgba(251,191,36,0.35); }
.tool-card-icon.indigo { background: linear-gradient(135deg, #818cf8, #4f46e5); box-shadow: 0 8px 24px rgba(129,140,248,0.35); }

.tool-card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.tool-card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.tool-card-arrow {
  margin-top: 16px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: translateX(-8px);
  transition: all 0.25s ease;
}

.tool-card:hover .tool-card-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.9);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .lab-sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .lab-sidebar.open {
    transform: translateX(0);
  }

  .mobile-header {
    display: flex;
  }

  .lab-main {
    margin-left: 0;
    padding-top: var(--header-height);
  }

  .lab-content {
    padding: var(--space-md) var(--space-md);
  }

  .hero-title {
    font-size: 28px;
  }

  .page-subtitle {
    margin-bottom: 20px;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
