/* ============================================
   LOWKEY MEDIA SERVER DESIGN SYSTEM
   A clean, minimalistic dark mode theme
   ============================================ */

/* ----------------------------------------
   CSS Custom Properties (Design Tokens)
   ---------------------------------------- */
:root {
  /* Background Colors */
  --bg-base: #0f0f0f;
  --bg-surface: #161618;
  --bg-elevated: #1c1c1e;
  --bg-card: #222224;
  --bg-hover: #2a2a2c;
  --bg-active: #333336;

  /* Border Colors */
  --border-subtle: #2a2a2c;
  --border-default: #38383a;
  --border-strong: #48484a;

  /* Text Colors */
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-muted: #6e6e73;
  --text-dim: #48484a;

  /* Accent Colors */
  --accent-primary: #00d4aa;
  --accent-primary-dim: rgba(0, 212, 170, 0.15);
  --accent-cyan: #61dafb;
  --accent-cyan-dim: rgba(97, 218, 251, 0.15);
  --accent-blue: #3b82f6;
  --accent-blue-dim: rgba(59, 130, 246, 0.15);
  --accent-purple: #a78bfa;
  --accent-purple-dim: rgba(167, 139, 250, 0.15);
  --accent-pink: #f472b6;
  --accent-pink-dim: rgba(244, 114, 182, 0.15);

  /* Status Colors */
  --status-success: #22c55e;
  --status-success-dim: rgba(34, 197, 94, 0.15);
  --status-warning: #eab308;
  --status-warning-dim: rgba(234, 179, 8, 0.15);
  --status-error: #ef4444;
  --status-error-dim: rgba(239, 68, 68, 0.15);
  --status-info: #3b82f6;
  --status-info-dim: rgba(59, 130, 246, 0.15);
  --status-pending: #f59e0b;
  --status-pending-dim: rgba(245, 158, 11, 0.15);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

  /* Font Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 9999px;

  /* Shadows - subtle and clean */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 8px rgba(0, 212, 170, 0.1);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Scrollbar */
  --scrollbar-thumb: #48484a;
  --scrollbar-thumb-hover: #5a5a5e;
}

/* ----------------------------------------
   Base Styles
   ---------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

/* ----------------------------------------
   Typography
   ---------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 {
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--text-lg);
}

p {
  margin: 0;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
}

/* ----------------------------------------
   Links
   ---------------------------------------- */
a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* ----------------------------------------
   Layout
   ---------------------------------------- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-5);
}

.container--narrow {
  max-width: 900px;
}

.container--wide {
  max-width: 1400px;
}

/* ----------------------------------------
   Page Header
   ---------------------------------------- */
.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-3) 0;
  padding: var(--space-3);
  background: linear-gradient(
    135deg,
    var(--bg-elevated) 0%,
    var(--bg-surface) 100%
  );
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--accent-primary);
}

/* ----------------------------------------
   Navigation
   ---------------------------------------- */
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

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

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

/* ----------------------------------------
   Cards
   ---------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-default);
}

.card--accent {
  border-left: 3px solid var(--accent-primary);
}

.card--accent-blue {
  border-left-color: var(--accent-blue);
}

.card--accent-purple {
  border-left-color: var(--accent-purple);
}

.card--accent-pink {
  border-left-color: var(--accent-pink);
}

.card--accent-cyan {
  border-left-color: var(--accent-cyan);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--bg-active);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.card-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.card-body {
  margin-top: var(--space-4);
}

/* ----------------------------------------
   Buttons
   ---------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.btn--primary {
  background: var(--accent-primary);
  color: #000;
  border-color: var(--accent-primary);
}

.btn--primary:hover:not(:disabled) {
  background: #00e6b8;
  border-color: #00e6b8;
}

.btn--secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

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

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn--ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn--danger {
  background: var(--status-error-dim);
  color: var(--status-error);
  border-color: transparent;
}

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

.btn--sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.btn--lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
}

/* Legacy button support */
button {
  font-family: var(--font-sans);
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ----------------------------------------
   Form Elements
   ---------------------------------------- */
.input,
input[type='text'],
input[type='number'],
input[type='email'],
input[type='password'],
input[type='url'],
textarea,
select {
  width: 100%;
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.input:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

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

label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
}

input[type='checkbox'] {
  width: auto;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.label {
  display: block;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.hint {
  color: var(--text-muted);
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}

/* ----------------------------------------
   Panels
   ---------------------------------------- */
.panel {
  background: linear-gradient(
    145deg,
    var(--bg-elevated) 0%,
    var(--bg-surface) 100%
  );
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.panel--accent {
  border-color: var(--accent-primary-dim);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ----------------------------------------
   Status Indicators
   ---------------------------------------- */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-dot--pending {
  background: var(--status-pending);
}

.status-dot--running {
  background: transparent;
  border: 2px solid var(--accent-cyan);
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

.status-dot--success {
  background: var(--status-success);
}

.status-dot--error {
  background: var(--status-error);
}

.status-dot--warning {
  background: var(--status-warning);
}

.status-dot--pulse {
  animation: pulse 2s ease-in-out infinite;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge--pending {
  background: var(--status-pending-dim);
  color: var(--status-pending);
}

.status-badge--running {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
}

.status-badge--success {
  background: var(--status-success-dim);
  color: var(--status-success);
}

.status-badge--error {
  background: var(--status-error-dim);
  color: var(--status-error);
}

/* Job Status (legacy support) */
.job-status {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  display: inline-block;
  flex-shrink: 0;
}

.job-status.Pending {
  background-color: var(--status-pending);
}

.job-status.InProgress {
  background-color: transparent;
  border: 2px solid var(--accent-cyan);
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

.job-status.Completed {
  background-color: var(--status-success);
}

.job-status.Cancelled {
  background-color: var(--status-warning);
}

.job-status.Error {
  background-color: var(--status-error);
}

.job-status.Paused {
  background-color: transparent;
  border: 2px solid var(--status-warning);
}

/* ----------------------------------------
   Messages
   ---------------------------------------- */
.message {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  animation: slideIn 0.2s ease;
}

.message--success {
  background: var(--status-success-dim);
  color: var(--status-success);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.message--error {
  background: var(--status-error-dim);
  color: var(--status-error);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.message--info {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
  border: 1px solid rgba(97, 218, 251, 0.25);
}

.message--warning {
  background: var(--status-warning-dim);
  color: var(--status-warning);
  border: 1px solid rgba(234, 179, 8, 0.25);
}

/* ----------------------------------------
   Tables
   ---------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.5px;
  background: var(--bg-surface);
}

.table tr:hover {
  background: var(--bg-hover);
}

/* Data Grid */
.data-grid {
  display: grid;
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-grid-header,
.data-grid-row {
  display: grid;
  gap: var(--space-2);
  background: var(--bg-surface);
}

.data-grid-header {
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-grid-row:hover {
  background: var(--bg-hover);
}

.data-grid-cell {
  padding: var(--space-3);
  display: flex;
  align-items: center;
  overflow: hidden;
}

/* ----------------------------------------
   Terminal / Code
   ---------------------------------------- */
.terminal {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.terminal-content {
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  overflow-x: auto;
}

.terminal-line {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-secondary);
}

/* Terminal Input */
#createForm {
  display: flex;
  align-items: center;
  margin: var(--space-4);
}

#uri {
  width: 100%;
  padding: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  caret-color: var(--accent-primary);
}

#uri:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

/* ----------------------------------------
   Grid Layouts
   ---------------------------------------- */
.grid {
  display: grid;
  gap: var(--space-5);
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

.grid--4 {
  grid-template-columns: repeat(4, minmax(200px, 1fr));
}

/* ----------------------------------------
   Connection Status
   ---------------------------------------- */
.connection-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
}

.connection-status .dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--status-success);
}

.connection-status.disconnected .dot {
  background: var(--status-error);
}

.connection-status.connecting .dot {
  background: var(--status-warning);
  animation: pulse 1s ease-in-out infinite;
}

/* ----------------------------------------
   Breadcrumbs
   ---------------------------------------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.breadcrumb-link {
  color: var(--accent-primary);
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.breadcrumb-link:hover {
  opacity: 1;
}

.breadcrumb-separator {
  color: var(--text-muted);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

/* ----------------------------------------
   Tags
   ---------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  background: var(--bg-active);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.tag-category {
  color: var(--text-muted);
  font-weight: 500;
}

/* ----------------------------------------
   Metrics
   ---------------------------------------- */
.metric {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--accent-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.metric-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ----------------------------------------
   Animations
   ---------------------------------------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

@keyframes slideIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ----------------------------------------
   Scrollbars
   ---------------------------------------- */
html,
body,
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ----------------------------------------
   Utility Classes
   ---------------------------------------- */
.text-primary {
  color: var(--text-primary);
}
.text-secondary {
  color: var(--text-secondary);
}
.text-muted {
  color: var(--text-muted);
}
.text-success {
  color: var(--status-success);
}
.text-error {
  color: var(--status-error);
}
.text-warning {
  color: var(--status-warning);
}
.text-accent {
  color: var(--accent-primary);
}

.bg-surface {
  background: var(--bg-surface);
}
.bg-elevated {
  background: var(--bg-elevated);
}
.bg-card {
  background: var(--bg-card);
}

.font-mono {
  font-family: var(--font-mono);
}
.font-bold {
  font-weight: 600;
}

.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-2 {
  gap: var(--space-2);
}
.gap-3 {
  gap: var(--space-3);
}
.gap-4 {
  gap: var(--space-4);
}

.mt-2 {
  margin-top: var(--space-2);
}
.mt-3 {
  margin-top: var(--space-3);
}
.mt-4 {
  margin-top: var(--space-4);
}
.mb-2 {
  margin-bottom: var(--space-2);
}
.mb-3 {
  margin-bottom: var(--space-3);
}
.mb-4 {
  margin-bottom: var(--space-4);
}

.rounded {
  border-radius: var(--radius-md);
}
.rounded-lg {
  border-radius: var(--radius-lg);
}

.hidden {
  display: none;
}

/* ----------------------------------------
   Responsive
   ---------------------------------------- */
@media screen and (max-width: 800px) {
  :root {
    --text-2xl: 1.25rem;
    --text-xl: 1.125rem;
    --space-5: 16px;
  }

  .container {
    padding: var(--space-3);
  }

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

  .nav {
    gap: var(--space-1);
    padding: var(--space-2);
  }

  .nav-link {
    padding: var(--space-2);
    font-size: var(--text-xs);
  }

  .card {
    padding: var(--space-4);
  }

  .panel {
    padding: var(--space-4);
  }

  .nav-user-section {
    width: 100%;
    margin-left: 0;
    margin-top: var(--space-2);
    padding-right: 0;
    justify-content: center;
  }
}
