:root {
  /* Dark Theme Variables */
  --bg-app: #0b1120;
  /* Deep Slate/Black */
  --bg-panel: rgba(30, 41, 59, 0.8);
  /* Glassy Slate 800 */
  --bg-card: #1e293b;
  /* Slate 800 */
  --bg-input: #334155;
  /* Slate 700 */

  --primary-glow: #818cf8;
  --primary: #6366f1;
  /* Indigo 500 - Brighter for dark mode */
  --primary-hover: #818cf8;

  --secondary: #94a3b8;

  --text-main: #f1f5f9;
  /* Slate 100 */
  --text-muted: #cbd5e1;
  /* Slate 300 */
  --text-dim: #64748b;

  --border: #334155;
  /* Slate 700 */
  --border-hover: #475569;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 24px;

  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.2);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  /* Prevent scrolling on body, let main content scroll */
}

#app {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

p {
  line-height: 1.6;
  color: var(--text-muted);
}

/* Utilities */
.animate-fade-in {
  animation: fadeIn 0.6s var(--ease-out) forwards;
}

.animate-slide-in {
  animation: slideIn 0.4s var(--ease-out) forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* Glass/Card Components */
.glass-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: all 0.3s var(--ease-out);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

/* Buttons */
button {
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

button.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

button.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 10px -1px rgba(79, 70, 229, 0.3);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

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

button.secondary:hover {
  border-color: var(--text-main);
  color: var(--text-main);
  background: var(--bg-input);
}

button.danger {
  background: #fee2e2;
  color: #ef4444;
  border: 1px solid #fecaca;
}

button.danger:hover {
  background: #fecaca;
}

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

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

input,
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.925rem;
  transition: all 0.2s;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  background: var(--bg-card);
}

/* Dashboard Layout (Mobile First) */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  text-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
  /* Glow effect for text */
}

.brand img {
  height: 28px;
  /* Make logo white/bright if it's dark, adds a glow */
  filter: brightness(0) invert(1) drop-shadow(0 0 5px rgba(129, 140, 248, 0.6));
}

/* Mobile Navigation Toggle */
.mobile-toggle {
  display: block;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

@media (min-width: 768px) {
  .mobile-toggle {
    display: none;
  }
}

/* Sidebar Content (Nav + Profile) */
.sidebar-content {
  display: none;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

/* Open state for mobile */
.sidebar-content.show {
  display: flex;
  position: absolute;
  top: 72px;
  left: 0;
  right: 0;
  background: var(--bg-card);
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--bg-app);
  position: relative;
}

/* Desktop Navigation (Media Query) */
@media (min-width: 768px) {
  .app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
  }

  .sidebar {
    border-bottom: none;
    border-right: 1px solid var(--border);
    flex-direction: column;
    padding: 2rem 1.5rem;
    justify-content: flex-start;
  }

  .brand {
    margin-bottom: 3rem;
    align-items: center;
  }

  .sidebar-content {
    display: flex !important;
    flex: 1;
    /* Take remaining height */
    position: static;
    border: none;
    box-shadow: none;
    padding: 0;
    animation: none;
  }

  /* Make nav menu expand to push footer down */
  .nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .main-content {
    padding: 2rem 3rem;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-input);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  font-weight: 600;
}

/* Login View (Light) */
.login-view {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  position: relative;
}

.login-bg {
  display: none;
  /* remove blobs for cleaner light look or keep faint */
}

.login-content {
  width: 100%;
  max-width: 400px;
  padding: 1rem;
}

/* Data Table */
table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: var(--bg-input);
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

td {
  padding: 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

tr:last-child td {
  border-bottom: none;
}

/* Chips */
.chips-wrap {
  background: var(--bg-input);
  border: 1px solid var(--border);
  min-height: 48px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

.chips-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chip {
  background: rgba(99, 102, 241, 0.2);
  color: #e0e7ff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 1rem;
  line-height: 1;
}

.chip-remove:hover {
  opacity: 1;
}

.chips-input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  height: auto;
  min-width: 120px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  color: var(--text-main);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  min-width: 300px;
}

.toast-error {
  border-left-color: #ef4444;
}

.toast-success {
  border-left-color: #22c55e;
}

/* Mobile Tweaks */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

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

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    width: auto;
  }

  .toast {
    min-width: auto;
    width: 100%;
  }
}