/* =====================================================
   Halo Dashboard CSS v1.0 — Pure Native CSS
   ===================================================== */

/* ── Login View ────────────────────────────────────────────── */
.login-view {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: #f8fafc; display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: white; width: 100%; max-width: 400px; border-radius: 12px;
  padding: 32px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); border: 1px solid var(--border);
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-logo { font-size: 40px; line-height: 1; display: inline-block; margin-bottom: 12px; }
.login-header h2 { font-size: 24px; font-weight: 600; color: #0f172a; margin-bottom: 4px; }
.login-header p { color: #64748b; font-size: 14px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; font-weight: 500; margin-bottom: 6px; color: #334155; }
.login-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; transition: border-color .2s; }
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; min-height: 18px; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; background: #f1f5f9; color: #1e293b; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }

:root {
  --sidebar-w: 220px;
  --sidebar-collapsed: 60px;
  --topbar-h: 56px;
  --sidebar-bg: #1e293b;
  --sidebar-hover: rgba(255,255,255,.07);
  --sidebar-active: rgba(99,102,241,.25);
  --sidebar-active-border: #6366f1;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --border: #e2e8f0;
  --bg-white: #ffffff;
  --text-muted: #64748b;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  transition: width 0.2s ease;
  overflow: hidden;
}
.sidebar--collapsed { width: var(--sidebar-collapsed); }
.sidebar--collapsed .nav-label,
.sidebar--collapsed .sidebar-logo { display: none; }
.sidebar--collapsed .nav-item { justify-content: center; padding: 0.75rem; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  height: var(--topbar-h);
}
.sidebar-logo { font-weight: 800; font-size: 1.1rem; color: #f8fafc; white-space: nowrap; }
.sidebar-toggle {
  background: none; border: none;
  color: #94a3b8; font-size: 1.1rem; padding: 0.25rem;
  border-radius: var(--radius);
  transition: color 0.15s;
}
.sidebar-toggle:hover { color: #f8fafc; }

.sidebar-nav { flex: 1; padding: 0.75rem 0.5rem; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  color: #94a3b8; font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active {
  background: var(--sidebar-active);
  color: #a5b4fc;
  border-left-color: var(--sidebar-active-border);
}
.nav-icon { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }

/* ── Main wrapper ── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}
.main-wrapper--collapsed { margin-left: var(--sidebar-collapsed); }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1rem; font-weight: 700; color: #1e293b; }
.topbar-menu-btn { display: none; background: none; border: none; font-size: 1.25rem; color: var(--text-muted); }
.topbar-status { font-size: 0.75rem; color: var(--success); font-weight: 600; }

/* ── Page content ── */
.page-content { padding: 1.5rem; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 0.9rem; font-weight: 700; }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

/* ── Stat grid ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 1rem;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon--purple { background: #ede9fe; }
.stat-icon--blue   { background: #dbeafe; }
.stat-icon--green  { background: #d1fae5; }
.stat-icon--orange { background: #ffedd5; }
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1; color: #0f172a; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.stat-sub   { font-size: 0.75rem; color: var(--success); margin-top: 0.125rem; }

/* ── Queue bars ── */
.queue-section { margin-bottom: 1.5rem; }
.queue-bars { display: flex; flex-direction: column; gap: 0.75rem; }
.queue-bar { display: flex; align-items: center; gap: 0.75rem; }
.queue-bar-label { width: 80px; font-size: 0.8rem; color: var(--text-muted); }
.queue-bar-track { flex: 1; height: 8px; background: #f1f5f9; border-radius: 99px; overflow: hidden; }
.queue-bar-fill  { height: 100%; border-radius: 99px; transition: width 0.5s ease; min-width: 4px; }
.queue-bar-fill--pending    { background: var(--info); }
.queue-bar-fill--done       { background: var(--success); }
.queue-bar-fill--failed     { background: var(--danger); }
.queue-bar-fill--processing { background: var(--warning); }
.queue-bar-count { width: 50px; text-align: right; font-size: 0.8rem; font-weight: 600; }

/* ── Data table ── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left; padding: 0.625rem 0.875rem;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted); font-weight: 700;
  white-space: nowrap;
}
.data-table td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.data-table .col-actions { width: 100px; text-align: right; white-space: nowrap; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px; font-size: 0.7rem; font-weight: 700;
  white-space: nowrap;
}
.badge--active       { background: #d1fae5; color: #065f46; }
.badge--paused       { background: #fef3c7; color: #92400e; }
.badge--failed       { background: #fee2e2; color: #991b1b; }
.badge--provisioning { background: #dbeafe; color: #1e40af; }
.badge--done         { background: #d1fae5; color: #065f46; }
.badge--pending      { background: #e0e7ff; color: #3730a3; }
.badge--processing   { background: #fef3c7; color: #92400e; }
.badge--neutral      { background: #f1f5f9; color: var(--text-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius); font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary        { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-ghost          { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover    { background: #f8fafc; color: #1e293b; }
.btn-danger         { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #dc2626; }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger); color: #fff; }
.btn-success        { background: var(--success); color: #fff; }
.btn-success:hover  { background: #059669; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* ── Toolbar (above tables) ── */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; gap: 0.75rem; flex-wrap: wrap;
}
.toolbar-left  { display: flex; gap: 0.5rem; align-items: center; }
.toolbar-right { display: flex; gap: 0.5rem; align-items: center; }

/* ── Search input ── */
.search-input {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.875rem; outline: none; min-width: 220px;
}
.search-input:focus { border-color: var(--primary); }

/* ── Pagination ── */
.pagination {
  display: flex; gap: 0.25rem; align-items: center;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}
.pagination-info { flex: 1; font-size: 0.8rem; color: var(--text-muted); }
.page-btn {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-white); font-size: 0.8rem; font-weight: 600;
  transition: all 0.15s;
}
.page-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; pointer-events: none; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.375rem; color: #374151; }
.form-input, .form-select {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.875rem; outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 480px; max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95); transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1rem;
  color: var(--text-muted); width: 28px; height: 28px;
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #f1f5f9; color: #1e293b; }
.modal-body { padding: 1.25rem; }

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 999; display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #1e293b; color: #f8fafc;
  border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow-md);
  min-width: 260px; max-width: 360px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1);
}
.toast--show { transform: translateX(0); }
.toast--success { border-left: 4px solid var(--success); }
.toast--error   { border-left: 4px solid var(--danger); }
.toast--info    { border-left: 4px solid var(--info); }

/* ── Loading spinner ── */
.loading-spinner { display: flex; justify-content: center; padding: 4rem; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 4rem 1rem; color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 0.9rem; }

/* ── Chart ── */
.chart-wrapper { padding: 0.5rem; }
.chart-canvas { width: 100%; height: 200px; }

/* ── Generator status ── */
.gen-status-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem;
}
.gen-status-dot {
  width: 12px; height: 12px;
  border-radius: 50%; flex-shrink: 0;
  animation: pulse 2s infinite;
}
.gen-status-dot--running { background: var(--success); }
.gen-status-dot--stopped { background: var(--text-muted); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.gen-actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .topbar-menu-btn { display: block; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 1rem; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}
