/* ===========================================================================
   style.css — Peaceful ASMR Vibes Auto Dashboard
   Dark, calm theme — ASMR-appropriate color palette
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
  --bg-deep:    #0a0a0f;
  --bg-surface: #12121a;
  --bg-card:    #1a1a24;
  --bg-elevated:#22222e;
  --border:     #2a2a3a;
  --border-light: #3a3a4a;

  --text-primary:   #e8e8ee;
  --text-secondary: #9090a0;
  --text-muted:     #606070;

  --accent:      #7c6ff0;   /* soft indigo */
  --accent-dim:  #5a4fc0;
  --accent-glow: rgba(124, 111, 240, 0.15);

  --green:      #4ade80;
  --green-dim:  #22c55e;
  --red:        #f87171;
  --red-dim:    #ef4444;
  --yellow:     #fbbf24;
  --yellow-dim: #f59e0b;
  --blue:       #60a5fa;
  --blue-dim:   #3b82f6;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;

  --sidebar-w:  220px;
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
                Ubuntu, Cantarell, sans-serif;
  --font-mono:  'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;

  --shadow:     0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
}

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

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow: hidden;
}

::selection {
  background: var(--accent);
  color: #fff;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

a { color: var(--accent); text-decoration: none; }
code { font-family: var(--font-mono); font-size: 12px; }
pre { font-family: var(--font-mono); }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* --------------------------------------------------------------------------
   App layout
   -------------------------------------------------------------------------- */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.brand-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}

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

.nav-tab.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Footer */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.status-ok     { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.status-fail   { background: var(--red);   box-shadow: 0 0 6px var(--red); }
.status-dot.status-warn   { background: var(--yellow); }
.status-dot.status-unknown { background: var(--text-muted); }

.user-badge {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}
.user-role {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-card);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Main content
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--bg-deep);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}
.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Panel header
   -------------------------------------------------------------------------- */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.panel-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.last-sync {
  font-size: 12px;
  color: var(--text-muted);
}

.queue-summary {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Grid helpers
   -------------------------------------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.recent-activity {
  margin-top: 16px;
}

/* --------------------------------------------------------------------------
   API cards
   -------------------------------------------------------------------------- */
.api-cards {
  margin-bottom: 20px;
}

.api-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s;
}

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

.api-card-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.api-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.api-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.api-card-status {
  font-size: 12px;
  font-weight: 500;
}
.api-card-status.status-ok    { color: var(--green); }
.api-card-status.status-fail  { color: var(--red); }
.api-card-status.status-warn  { color: var(--yellow); }
.api-card-status.status-not_configured { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Quick stats
   -------------------------------------------------------------------------- */
.quick-stats {
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

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

.table .empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px !important;
  font-style: italic;
}

.code-sm {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 3px;
}

/* --------------------------------------------------------------------------
   Status pills
   -------------------------------------------------------------------------- */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
}

.status-pill.status-pending   { background: rgba(96,165,250,0.15); color: var(--blue); }
.status-pill.status-generating { background: rgba(251,191,36,0.15); color: var(--yellow); }
.status-pill.status-ready     { background: rgba(74,222,128,0.15); color: var(--green); }
.status-pill.status-posted    { background: rgba(74,222,128,0.15); color: var(--green); }
.status-pill.status-failed    { background: rgba(248,113,113,0.15); color: var(--red); }
.status-pill.status-ok        { background: rgba(74,222,128,0.15); color: var(--green); }
.status-pill.status-fail      { background: rgba(248,113,113,0.15); color: var(--red); }
.status-pill.status-warn      { background: rgba(251,191,36,0.15); color: var(--yellow); }
.status-pill.status-unknown   { background: rgba(96,165,250,0.15); color: var(--blue); }

/* --------------------------------------------------------------------------
   Toggle switch
   -------------------------------------------------------------------------- */
.status-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.status-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 20px;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.2s;
}

.status-toggle input:checked + .toggle-slider {
  background: var(--green-dim);
}

.status-toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: #fff;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dim);
}

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

.btn-danger {
  background: rgba(248,113,113,0.1);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn-danger:hover {
  background: rgba(248,113,113,0.2);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239090a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   Batch config
   -------------------------------------------------------------------------- */
.batch-config {
  margin-bottom: 20px;
}

.batch-progress {
  margin: 16px 0;
}

.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.batch-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Analytics chart
   -------------------------------------------------------------------------- */
.chart-placeholder {
  min-height: 200px;
}

.chart-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 10px;
}

.chart-bar-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-track {
  height: 20px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  min-width: 2px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
}

.chart-bar-value {
  font-size: 11px;
  font-family: var(--font-mono);
  color: #fff;
  font-weight: 600;
}

.chart-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Monitor
   -------------------------------------------------------------------------- */
.monitor-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mon-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.mon-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.mon-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Code block
   -------------------------------------------------------------------------- */
.code-block {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
}
.modal-close:hover {
  background: var(--border);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  max-width: 360px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast-info    { background: var(--bg-elevated); border: 1px solid var(--border-light); color: var(--text-primary); }
.toast-success { background: rgba(74,222,128,0.15); border: 1px solid rgba(74,222,128,0.3); color: var(--green); }
.toast-error   { background: rgba(248,113,113,0.15); border: 1px solid rgba(248,113,113,0.3); color: var(--red); }
.toast-warn    { background: rgba(251,191,36,0.15);  border: 1px solid rgba(251,191,36,0.3);  color: var(--yellow); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    min-width: 60px;
  }
  .brand-title, .brand-sub, .nav-tab span:last-child,
  .sidebar-footer, .nav-tab .nav-icon { display: none; }
  .nav-tab { justify-content: center; padding: 12px; }
  .nav-tab .nav-icon { display: block !important; font-size: 20px; }
  .main-content { padding: 14px; }
  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
