/*
 * Fleet AI — Shared Design System
 *
 * Semantic component classes built on CSS custom properties.
 * Dark mode: add/remove `html.dark` — all variables resolve automatically.
 * Tailwind handles layout; this file handles appearance.
 */

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

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Design tokens ──────────────────────────────────────────────────────────── */

:root {
  /* Backgrounds */
  --bg-primary:   #ffffff;          /* page background          */
  --bg-secondary: #f9fafb;          /* card background          */
  --bg-tertiary:  #f3f4f6;          /* hover states, subtle fills */

  /* Borders */
  --border:        #e5e7eb;
  --border-subtle: #f3f4f6;

  /* Text */
  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-tertiary:  #9ca3af;

  /* Accent — calm blue */
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-subtle: #eff6ff;         /* accent background tint   */

  /* Semantic colors */
  --success:        #16a34a;  --success-subtle: #f0fdf4;
  --warning:        #d97706;  --warning-subtle: #fffbeb;
  --danger:         #dc2626;  --danger-subtle:  #fef2f2;
  --info:           #2563eb;  --info-subtle:    #eff6ff;

  /* Shape */
  --radius-sm: 0.25rem;   /*  4px */
  --radius-md: 0.5rem;    /*  8px */
  --radius-lg: 0.75rem;   /* 12px */

  /* Elevation */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

/* Dark theme: true dark (not gray-blue) with same calm-blue accent */
html.dark {
  --bg-primary:   #0f0f0f;
  --bg-secondary: #171717;
  --bg-tertiary:  #222222;

  --border:        #2d2d2d;
  --border-subtle: #1e1e1e;

  --text-primary:   #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-tertiary:  #666666;

  --accent:        #3b82f6;
  --accent-hover:  #60a5fa;
  --accent-subtle: #172554;

  --success:        #22c55e;  --success-subtle: #052e16;
  --warning:        #f59e0b;  --warning-subtle: #451a03;
  --danger:         #ef4444;  --danger-subtle:  #450a0a;
  --info:           #3b82f6;  --info-subtle:    #172554;

  --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.3);
}

/* ── Base ───────────────────────────────────────────────────────────────────── */

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* ── Card ───────────────────────────────────────────────────────────────────── */

.fleet-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */

.fleet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 150ms, border-color 150ms, color 150ms, opacity 150ms;
  white-space: nowrap;
  user-select: none;
}
.fleet-btn:disabled,
.fleet-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.fleet-btn-primary {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.fleet-btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.fleet-btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border);
}
.fleet-btn-secondary:hover:not(:disabled) {
  background-color: var(--border);
}

.fleet-btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.fleet-btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.fleet-btn-danger {
  background-color: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.fleet-btn-danger:hover:not(:disabled) {
  background-color: var(--danger-subtle);
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */

.fleet-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.fleet-badge-success { background-color: var(--success-subtle); color: var(--success); }
.fleet-badge-warning { background-color: var(--warning-subtle); color: var(--warning); }
.fleet-badge-danger  { background-color: var(--danger-subtle);  color: var(--danger);  }
.fleet-badge-neutral { background-color: var(--bg-tertiary);    color: var(--text-secondary); }
.fleet-badge-info    { background-color: var(--info-subtle);    color: var(--info);    }

/* ── Status dots ────────────────────────────────────────────────────────────── */

.fleet-status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.fleet-status-dot-idle      { background-color: #9ca3af; }
.fleet-status-dot-executing { background-color: var(--accent); animation: fleet-dot-pulse 1.5s ease-in-out infinite; }
.fleet-status-dot-paused    { background-color: #f59e0b; }
.fleet-status-dot-offline   { background-color: var(--danger); }
.fleet-status-dot-online    { background-color: var(--success); }
.fleet-status-dot-remote    { background-color: var(--info); }

@keyframes fleet-dot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ── Inputs ─────────────────────────────────────────────────────────────────── */

.fleet-input,
.fleet-textarea {
  display: block;
  width: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  font-family: inherit;
  transition: border-color 150ms, box-shadow 150ms;
  outline: none;
}
.fleet-input::placeholder,
.fleet-textarea::placeholder {
  color: var(--text-tertiary);
}
.fleet-input:focus,
.fleet-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.fleet-textarea {
  resize: vertical;
  min-height: 5rem;
}

/* ── Stat card ──────────────────────────────────────────────────────────────── */

.fleet-stat {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.fleet-stat-value {
  display: block;
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}
.fleet-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.375rem;
}

/* ── Nav items ──────────────────────────────────────────────────────────────── */

.fleet-nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
  background: none;
  border: none;
  text-align: left;
}
.fleet-nav-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}
.fleet-nav-item-active,
.fleet-nav-item.active {
  background-color: var(--accent-subtle);
  color: var(--accent);
}
.fleet-nav-item-active:hover,
.fleet-nav-item.active:hover {
  background-color: var(--accent-subtle);
  color: var(--accent-hover);
}

/* ── Table ──────────────────────────────────────────────────────────────────── */

.fleet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.fleet-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-secondary);
}
.fleet-table tbody td {
  padding: 0.875rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.fleet-table tbody tr:last-child td {
  border-bottom: none;
}
.fleet-table tbody tr:hover td {
  background-color: var(--bg-secondary);
}

/* ── Tabs ───────────────────────────────────────────────────────────────────── */

.fleet-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  text-decoration: none;
  transition: color 150ms, border-color 150ms;
  white-space: nowrap;
  user-select: none;
}
.fleet-tab:hover {
  color: var(--text-primary);
}
.fleet-tab-active,
.fleet-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Empty state ────────────────────────────────────────────────────────────── */

.fleet-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}
.fleet-empty-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-lg);
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--text-tertiary);
}
.fleet-empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.375rem;
}
.fleet-empty-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 20rem;
  line-height: 1.6;
  margin: 0;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */

::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-tertiary); }
