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

body {
  background: #111;
  color: #eee;
  font-family: sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Navigation
───────────────────────────────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 48px;
  background: #1a1a2e;
  border-bottom: 2px solid #e94560;
}

.nav-title {
  font-size: 18px;
  font-weight: bold;
  color: #e94560;
  margin-right: auto;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: #ccc;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 4px 10px;
  border-radius: 4px;
  transition: color 0.2s, background-color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #fff;
  background: #e94560;
}

.nav-logout {
  color: #ccc;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #555;
  transition: color 0.2s, border-color 0.2s;
}

.nav-logout:hover {
  color: #fff;
  border-color: #e94560;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Layout
───────────────────────────────────────────────────────────────────────────── */
.container {
  padding: 20px;
  max-width: 1400px;
  margin: 0;  
  width: 100%;  
}

/* ─────────────────────────────────────────────────────────────────────────────
   Flash Messages
───────────────────────────────────────────────────────────────────────────── */
.flash-messages {
  margin-bottom: 16px;
}

.flash {
  padding: 10px 16px;
  border-radius: 4px;
  margin-bottom: 8px;
  font-size: 13px;
}

.flash-success {
  background: rgba(0, 200, 0, 0.15);
  border: 1px solid rgba(0, 200, 0, 0.4);
  color: #6fdc6f;
}

.flash-error {
  background: rgba(255, 60, 60, 0.15);
  border: 1px solid rgba(255, 60, 60, 0.4);
  color: #ff8080;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Threat Bar
───────────────────────────────────────────────────────────────────────────── */
.threat-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #1a1a2e;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 1px solid #333;
}

.threat-bar select {
  background: #222;
  color: #eee;
  border: 1px solid #444;
  padding: 4px 8px;
  border-radius: 4px;
}

.threat-bar button {
  background: #2a2a4a;
  color: #eee;
  border: 1px solid #555;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.threat-bar button:hover { background: #3a3a6a; }

/* ─────────────────────────────────────────────────────────────────────────────
   Level & Severity Colors
───────────────────────────────────────────────────────────────────────────── */
.level-normal,
.level-informational { color: #00c800; font-weight: bold; }
.level-elevated      { color: #ffc800; font-weight: bold; }
.level-high          { color: #ff7800; font-weight: bold; }
.level-emergency     { color: #ff2020; font-weight: bold; }
.level-unknown       { color: #aaa; }

/* ─────────────────────────────────────────────────────────────────────────────
   Badges
───────────────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-emergency  { background: rgba(255, 32, 32, 0.2);  color: #ff6060; border: 1px solid #ff2020; }
.badge-high       { background: rgba(255, 120, 0, 0.2);  color: #ffaa60; border: 1px solid #ff7800; }
.badge-elevated   { background: rgba(255, 200, 0, 0.2);  color: #ffe080; border: 1px solid #ffc800; }
.badge-info       { background: rgba(60, 160, 255, 0.2); color: #80c8ff; border: 1px solid #3ca0ff; }
.badge-active     { background: rgba(0, 200, 0, 0.15);   color: #6fdc6f; border: 1px solid #00c800; }
.badge-inactive   { background: rgba(100, 100, 100, 0.2);color: #888;    border: 1px solid #555; }
.badge-op         { background: rgba(100, 100, 200, 0.2);color: #aaaaff; border: 1px solid #6666cc; font-size: 10px; }
.badge-type       { background: rgba(60, 160, 160, 0.2); color: #80d0d0; border: 1px solid #3ca0a0; font-size: 10px; }

/* ─────────────────────────────────────────────────────────────────────────────
   Tables
───────────────────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: #1a1a2e;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid #333;
  color: #aaa;
  text-transform: uppercase;
  font-size: 11px;
  white-space: nowrap;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid #222;
  vertical-align: top;
}

tr:hover td { background: #1a1a1a; }

td.actions { white-space: nowrap; }
.nowrap     { white-space: nowrap; }
.transcript { max-width: 300px; }

/* Row status colors */
tr.status-verified  td { background: rgba(0, 200, 0, 0.05); }
tr.status-dismissed td { background: rgba(100, 100, 100, 0.1); color: #666; }

/* Empty / loading / error states */
td.loading { color: #666; font-style: italic; text-align: center; padding: 20px; }
td.empty   { color: #666; font-style: italic; text-align: center; padding: 20px; }
td.error   { color: #ff6060; text-align: center; padding: 20px; }

/* ─────────────────────────────────────────────────────────────────────────────
   Buttons
───────────────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-sm { padding: 3px 8px; font-size: 12px; }

.btn-primary {
  background: #2a2a6a;
  color: #fff;
  border-color: #4444aa;
}
.btn-primary:hover { background: #3a3a8a; border-color: #6666cc; }

.btn-secondary {
  background: #222;
  color: #eee;
  border-color: #444;
}
.btn-secondary:hover { background: #333; border-color: #666; }

.btn-danger {
  background: rgba(255, 32, 32, 0.15);
  color: #ff6060;
  border-color: #aa2222;
}
.btn-danger:hover { background: rgba(255, 32, 32, 0.3); border-color: #ff2020; }

/* Buttons inside table cells */
td button,
td .btn {
  padding: 3px 8px;
  font-size: 12px;
  margin-right: 4px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Forms — Shared
───────────────────────────────────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
input[type="time"],
input[type="date"],
input[type="password"],
select,
textarea {
  background: #1a1a2e;
  color: #eee;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  width: 100%;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="time"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #e94560;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Forms — Panel (add/edit panels above tables)
───────────────────────────────────────────────────────────────────────────── */
.form-panel {
  background: #16162a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.form-panel h3 {
  font-size: 15px;
  color: #e94560;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px 20px;
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #aaa;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.form-error {
  color: #ff6060;
  font-size: 12px;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(255, 60, 60, 0.1);
  border: 1px solid rgba(255, 60, 60, 0.3);
  border-radius: 4px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Forms — Inline Edit (condition rows)
───────────────────────────────────────────────────────────────────────────── */
.inline-edit-cell {
  background: #12122a;
  padding: 12px 16px;
  border-bottom: 2px solid #e94560;
}

.inline-edit-form {
  width: 100%;
}

.form-grid-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.form-row-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  flex: 1 1 160px;
}

.form-row-inline label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #aaa;
  white-space: nowrap;
}

.ie-error {
  font-size: 12px;
  color: #ff6060;
  margin-left: 10px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Admin Page Headers
───────────────────────────────────────────────────────────────────────────── */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.admin-header h2 {
  font-size: 18px;
  color: #fff;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Condition Builder
───────────────────────────────────────────────────────────────────────────── */
.condition-builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.condition-builder-header h3 {
  font-size: 15px;
  color: #e94560;
}

.condition-builder-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.condition-hint {
  font-size: 12px;
  color: #888;
  margin-bottom: 12px;
  font-style: italic;
}

/* Drag & drop */
.drag-handle {
  cursor: grab;
  color: #555;
  font-size: 16px;
  text-align: center;
  user-select: none;
}

.drag-handle:active { cursor: grabbing; }

tr.dragging td { opacity: 0.4; }

tr.drag-over td { border-top: 2px solid #e94560; }

/* OR group add-row */
.group-add-row td {
  background: #0e0e20;
  border-bottom: 1px dashed #333;
  padding: 6px 10px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Filter Form
───────────────────────────────────────────────────────────────────────────── */
.filters { margin: 0.75rem 0; }

.filter-form .filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 120px;
  flex: 1 1 120px;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  opacity: 0.7;
  white-space: nowrap;
}

.filter-actions {
  flex: 0 1 auto;
  flex-direction: row;
  align-items: flex-end;
  min-width: unset;
}

@media (max-width: 600px) {
  .filter-group,
  .filter-actions { flex: 1 1 100%; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Login
───────────────────────────────────────────────────────────────────────────── */
.login-box {
  max-width: 360px;
  margin: 100px auto;
  background: #1a1a2e;
  padding: 40px;
  border-radius: 8px;
  border: 1px solid #333;
  text-align: center;
}

.login-box h2 {
  margin-bottom: 24px;
  font-size: 22px;
}

.login-box input {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}

.login-box button {
  width: 100%;
  padding: 10px;
  background: #2a2a6a;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 15px;
  cursor: pointer;
}

.login-box button:hover { background: #3a3a8a; }

.login-error {
  color: #ff6060;
  color: #ff6060;
  margin-bottom: 12px;
  font-size: 13px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Hit Detail / Audio
───────────────────────────────────────────────────────────────────────────── */
audio {
  width: 200px;
  vertical-align: middle;
}

.hit-detail {
  background: #16162a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.hit-detail h2 {
  font-size: 16px;
  color: #e94560;
  margin-bottom: 16px;
}

.hit-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 20px;
  margin-bottom: 16px;
}

.hit-meta-item label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #aaa;
  display: block;
  margin-bottom: 2px;
}

.hit-meta-item span {
  font-size: 13px;
  color: #eee;
}

.hit-transcript {
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: #ddd;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Pagination
───────────────────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid #333;
  color: #aaa;
}

.pagination a:hover {
  background: #1a1a2e;
  color: #fff;
  border-color: #555;
}

.pagination span.current {
  background: #e94560;
  color: #fff;
  border-color: #e94560;
}

.pagination span.disabled {
  opacity: 0.35;
  cursor: default;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Utility
───────────────────────────────────────────────────────────────────────────── */
.text-muted   { color: #666; }
.text-success { color: #6fdc6f; }
.text-danger  { color: #ff6060; }
.text-warning { color: #ffc800; }
.text-info    { color: #80c8ff; }

.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-8        { gap: 8px; }
.gap-16       { gap: 16px; }

/* ─────────────────────────────────────────────────────────────────────────────
   Scrollbar (Webkit)
───────────────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ─────────────────────────────────────────────────────────────────────────────
   Sequence Builder
───────────────────────────────────────────────────────────────────────────── */

/* Step list container */
.sequence-steps-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 16px;
}

/* Individual step card */
.sequence-step-card {
  background: #12122a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 14px 16px;
  position: relative;
  cursor: grab;
  transition: border-color 0.15s;
}

.sequence-step-card:active  { cursor: grabbing; }
.sequence-step-card.dragging { opacity: 0.4; }
.sequence-step-card.drag-over { border-color: #e94560; }

/* Connector between steps */
.sequence-step-connector {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  color: #888;
  font-size: 12px;
  user-select: none;
}

.sequence-step-connector::before,
.sequence-step-connector::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #333;
}

.connector-label {
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 10px;
  padding: 2px 10px;
  white-space: nowrap;
  font-size: 11px;
  color: #aaa;
}

/* Step header row */
.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.step-number {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  color: #888;
  min-width: 48px;
}

.step-drag-handle {
  color: #555;
  font-size: 16px;
  cursor: grab;
  user-select: none;
  margin-right: 4px;
}

.step-drag-handle:active { cursor: grabbing; }

.step-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.step-controls label {
  font-size: 11px;
  color: #aaa;
  text-transform: uppercase;
  white-space: nowrap;
}

.step-controls select,
.step-controls input[type="number"] {
  width: auto;
  min-width: 80px;
  padding: 4px 8px;
  font-size: 12px;
}

.step-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

/* Phrase group inside a step */
.phrase-group {
  background: #0e0e20;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  padding: 10px 12px;
  margin-top: 6px;
}

.phrase-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.phrase-group-header span {
  font-size: 11px;
  text-transform: uppercase;
  color: #888;
  font-weight: bold;
}

.phrase-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 28px;
}

.phrase-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1a1a3a;
  border: 1px solid #3a3a6a;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  color: #ccc;
}

.phrase-tag button {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}

.phrase-tag button:hover { color: #ff6060; }

.phrase-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.phrase-add-row input {
  flex: 1;
  padding: 4px 8px;
  font-size: 12px;
}

/* Empty states within builder */
.steps-empty {
  color: #666;
  font-style: italic;
  font-size: 13px;
  padding: 16px 0;
  text-align: center;
}

/* Nested sequence selector */
.nested-seq-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.nested-seq-row label {
  font-size: 11px;
  color: #aaa;
  text-transform: uppercase;
  white-space: nowrap;
}

.nested-seq-row select {
  flex: 1;
  padding: 4px 8px;
  font-size: 12px;
}

/* Split layout for sequences page */
.seq-layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) 1fr;
  gap: 20px;
  align-items: start;
  width: 100%;
}

@media (max-width: 900px) {
  .seq-layout {
    grid-template-columns: 1fr;
  }
}

.seq-list-panel,
.seq-editor-panel {
  background: #16162a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 20px;
  width: 100%;
}

.seq-list-panel h3,
.seq-editor-panel h3 {
  font-size: 15px;
  color: #e94560;
  margin-bottom: 16px;
}

.seq-editor-panel h4 {
  font-size: 13px;
  color: #aaa;
  text-transform: uppercase;
  margin: 16px 0 10px;
  border-top: 1px solid #2a2a4a;
  padding-top: 12px;
}

/* Selected row in sequence list */
tr.seq-selected td {
  background: rgba(233, 69, 96, 0.08);
}
