/* EAM Memory Editor — Dark Premium Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0f1117; --surface: #1a1d27; --surface-alt: #22252f;
  --border: rgba(255, 255, 255, 0.08); --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eaed; --text-muted: #9ca3af; --text-soft: #6b7280;
  --accent: #f97316; --accent-hover: #ea580c; --accent-light: rgba(249, 115, 22, 0.12);
  --green: #22c55e; --green-light: rgba(34, 197, 94, 0.1);
  --red: #ef4444; --red-light: rgba(239, 68, 68, 0.1);
  --yellow: #f59e0b; --yellow-light: rgba(245, 158, 11, 0.08);
  --purple: #7c3aed; --purple-light: rgba(124, 58, 237, 0.08);
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.3);
  --transition: 160ms ease;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}

/* Header */
#header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 16px; font-weight: 600; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 16px; }

/* Badges */
.badge {
  font-size: 12px; padding: 2px 8px; border-radius: 12px;
  background: var(--surface-alt); color: var(--text-muted);
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-dim { background: var(--surface-alt); color: var(--text-soft); }

/* Health */
.health-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px;
}
.health-dot.green { background: var(--green); }
.health-dot.yellow { background: var(--yellow); }
.health-dot.red { background: var(--red); }
#health-indicator { font-size: 13px; color: var(--text-muted); cursor: pointer; }
#health-panel {
  position: fixed; top: 60px; right: 24px; width: 300px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px; z-index: 100;
  box-shadow: var(--shadow-md);
}
#health-panel h3 { margin-bottom: 12px; font-size: 14px; }
.health-score { font-size: 32px; font-weight: 700; text-align: center; margin: 8px 0 16px; color: var(--accent); }
.health-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}

/* Search bar */
#search-bar {
  display: flex; gap: 8px; padding: 16px 24px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
#search-input {
  flex: 1; padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; outline: none; transition: var(--transition);
}
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15); }
#search-input::placeholder { color: var(--text-soft); }
#filter-source {
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13px; outline: none;
}
#filter-source:focus { border-color: var(--accent); }
#btn-write {
  padding: 9px 18px; border-radius: var(--radius-sm); border: none;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
#btn-write:hover { background: var(--accent-hover); }

/* Main content */
#main-content { display: flex; height: calc(100vh - 120px); }
#results-panel { flex: 1; overflow-y: auto; padding: 16px 24px; }
#results-header {
  display: flex; justify-content: space-between; margin-bottom: 12px;
  font-size: 13px; color: var(--text-muted);
}
#detail-panel {
  width: 400px; border-left: 1px solid var(--border);
  background: var(--surface); overflow-y: auto; padding: 16px;
}
#detail-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
#detail-header h3 { font-size: 14px; }
#btn-close-detail {
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer;
}
#btn-close-detail:hover { color: var(--text); }

/* Memory cards */
.memory-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 8px;
  cursor: pointer; transition: var(--transition); box-shadow: var(--shadow-xs);
}
.memory-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.card-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.card-content { font-size: 13px; color: var(--text); line-height: 1.6; word-break: break-word; }
.card-footer { margin-top: 8px; font-size: 11px; color: var(--text-soft); }
.score { font-size: 12px; color: var(--text-muted); }

/* Source badges */
.source-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px;
}
.source-TEXT { background: var(--accent-light); color: var(--accent); }
.source-INTERACTION { background: var(--purple-light); color: var(--purple); }
.source-SPEECH { background: var(--green-light); color: var(--green); }
.source-SCREEN_EVENT { background: var(--yellow-light); color: var(--yellow); }
.source-SCREEN_DIGEST { background: var(--yellow-light); color: var(--yellow); }

/* Detail panel */
.detail-id { font-family: monospace; font-size: 11px; color: var(--text-soft); margin-bottom: 8px; word-break: break-all; }
.detail-source { display: inline-block; margin-bottom: 8px; }
.detail-score { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.detail-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-body {
  font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  padding: 12px; background: var(--surface-alt); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Buttons */
.btn-small {
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); font-size: 12px; cursor: pointer;
  transition: var(--transition);
}
.btn-small:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.btn-small:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-accent { border-color: var(--accent); color: var(--accent); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; width: 500px; max-width: 90vw;
  box-shadow: var(--shadow-md);
}
.modal-content h3 { margin-bottom: 16px; font-size: 16px; font-weight: 600; }
.modal-content textarea, .modal-content input, .modal-content select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; font-family: inherit; resize: vertical; outline: none;
  transition: var(--transition);
}
.modal-content textarea:focus, .modal-content input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15); }
.modal-content textarea::placeholder, .modal-content input::placeholder { color: var(--text-soft); }
.modal-row { display: flex; gap: 8px; margin-top: 8px; }
.modal-row select { width: 40%; }
.modal-row input { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.btn-primary {
  padding: 9px 20px; border-radius: var(--radius-sm); border: none;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
  font-size: 14px; transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  padding: 9px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  cursor: pointer; font-size: 14px; transition: var(--transition);
}
.btn-secondary:hover { background: var(--surface-alt); color: var(--text); }

/* Utility */
.hidden { display: none !important; }
.empty { text-align: center; padding: 48px; color: var(--text-muted); font-size: 14px; }
