/*
 * Shared UI Design System — Clawd Local Services
 *
 * Dark theme design tokens + common components.
 * Used by: CC Mobile, Project Dashboard, future services.
 *
 * Usage: Copy the :root block and any component sections you need.
 * Or <link rel="stylesheet" href="/shared.css"> if served from public/.
 */

/* ─── Design Tokens ──────────────────────────────────────────── */

:root {
  /* Backgrounds */
  --bg:           #1a1a2e;
  --bg-card:      #16213e;
  --bg-card-hover:#1a2747;
  --bg-input:     #0a0a1a;
  --bg-user:      #0f3460;   /* user message bubbles */
  --code-bg:      #0d1117;

  /* Text */
  --text:         #e0e0e0;
  --text-dim:     #888;
  --text-muted:   #555;

  /* Accent colors */
  --accent:       #e94560;   /* red — danger, blocked, waiting on human */
  --purple:       #7b68ee;   /* purple — in progress, active work */
  --green:        #4ecca3;   /* green — success, done, connected */
  --amber:        #f0ad4e;   /* amber — warning, in progress */
  --blue:         #4a9eff;   /* blue — queue, neutral, informational */

  /* Semantic column colors (Kanban) */
  --col-queue:    #4a9eff;
  --col-active:   #f0ad4e;
  --col-waiting:  #e94560;
  --col-done:     #4ecca3;

  /* Energy levels */
  --energy-low:   #4ecca3;
  --energy-med:   #f0ad4e;
  --energy-high:  #e94560;

  /* Borders & shapes */
  --border:       #2a2a4a;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-pill:  20px;

  /* Safe areas (notched devices) */
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-left:    env(safe-area-inset-left, 0px);
  --safe-right:   env(safe-area-inset-right, 0px);

  /* Shadows */
  --card-shadow:  0 2px 8px rgba(0, 0, 0, 0.3);
  --modal-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);

  /* Fonts */
  --font-sans:    -apple-system, 'SF Pro Text', system-ui, sans-serif;
  --font-mono:    'SF Mono', 'Menlo', 'Consolas', monospace;
}

/* ─── Reset ──────────────────────────────────────────────────── */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* ─── Connection Status ──────────────────────────────────────── */
/* <div class="conn-status"><div class="conn-dot"></div><span>Live</span></div> */

.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transition: background 0.3s;
}

.conn-dot.connected { background: var(--green); }

/* ─── Sticky Header ──────────────────────────────────────────── */

.header-sticky {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  border-bottom: 1px solid var(--border);
}

/* ─── Filter / Pill Bar ──────────────────────────────────────── */
/* Horizontal scrollable row of pill buttons */

.pill-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pill-bar::-webkit-scrollbar { display: none; }

.pill-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.pill-btn.active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(78, 204, 163, 0.1);
}

.pill-btn:active { transform: scale(0.95); }

/* ─── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.2s;
}

.card:hover { border-color: #3a3a6a; }

/* ─── Card Grid (responsive) ─────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: calc(var(--safe-bottom) + 24px);
}

@media (min-width: 768px)  { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

/* ─── Progress Bar ───────────────────────────────────────────── */
/* <div class="progress-bar"><div class="progress-fill green" style="width:73%"></div></div> */

.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  flex: 1;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-fill.green  { background: var(--green); }
.progress-fill.purple { background: var(--purple); }
.progress-fill.red    { background: var(--accent); }
.progress-fill.amber  { background: var(--amber); }
.progress-fill.gray   { background: var(--text-muted); }

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

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge.red    { background: var(--accent); color: #fff; }
.badge.green  { background: var(--green);  color: #000; }
.badge.purple { background: var(--purple); color: #fff; }
.badge.amber  { background: var(--amber);  color: #000; }
.badge.gray   { background: var(--text-muted); color: #ccc; }

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

.btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { border-color: var(--text-dim); color: var(--text); }
.btn:active { transform: scale(0.95); }
.btn.danger:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: #000;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary:active { opacity: 0.8; }

/* ─── Modal / Bottom Sheet ───────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--modal-shadow);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ─── Code Block ─────────────────────────────────────────────── */

.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ─── Animations ─────────────────────────────────────────────── */

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

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

/* ─── Utility ────────────────────────────────────────────────── */

.text-dim   { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-blue  { color: var(--blue); }
.text-red   { color: var(--accent); }
.text-amber { color: var(--amber); }
.mono       { font-family: var(--font-mono); }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Toast Notifications ───────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  pointer-events: none;
}

.toast-undo {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.toast-undo-btn {
  background: none;
  border: none;
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.toast-undo-btn:hover { background: rgba(78,204,163,0.15); }

.toast-undo-timer {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 0 0 10px 10px;
  position: absolute;
  bottom: 0;
  left: 0;
  overflow: hidden;
}
.toast-undo-timer-bar {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
}

/* ─── Context Menu ──────────────────────────────────────────── */

.ctx-menu {
  position: fixed;
  background: #1e1e3a;
  border: 1px solid #3a3a6a;
  border-radius: var(--radius-sm);
  padding: 4px 0;
  z-index: 10000;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

.ctx-item {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctx-item:hover { background: #2a2a5a; }
.ctx-item.danger { color: var(--accent); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ─── Overlay / Detail Panel ────────────────────────────────── */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  color: var(--text);
  font-size: 14px;
}

/* ─── Floating Action Buttons ───────────────────────────────── */

.float-actions {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  gap: 4px;
  align-items: center;
  padding: 4px 6px;
  background: rgba(26,26,46,0.92);
  border-radius: 6px;
  z-index: 2;
}

.card:hover .float-actions,
.float-actions-parent:hover .float-actions { display: flex; }

.action-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

/* ─── Section Header ────────────────────────────────────────── */

.section-hdr {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* ─── Input Fields ──────────────────────────────────────────── */

.input, textarea.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}

.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--blue);
}

/* ─── Hero Banner (next action, alerts) ─────────────────────── */

.hero-banner {
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.hero-banner.success { background: #1a3a2e; border: 1px solid #2a6a4a; }
.hero-banner.warning { background: #3a2a1e; border: 1px solid #6a4a2a; }
.hero-banner.danger  { background: #3a1a1e; border: 1px solid #6a2a2a; }
.hero-banner.info    { background: #1a2a3e; border: 1px solid #2a4a6a; }

/* ─── Age Decay (visual staleness) ──────────────────────────── */

.age-fresh { opacity: 1; }
.age-1     { opacity: 0.85; }
.age-2     { opacity: 0.65; }
.age-3     { opacity: 0.45; }
