/* ================================================================
   TWNN Log — dark theme
   Modal handles outer overflow
   ================================================================ */

.twnnLogPanel {
  --twnn-log-bg: #111827;
  --twnn-log-surface: #18212f;
  --twnn-log-surface-hover: #202b3b;
  --twnn-log-border: #334155;
  --twnn-log-border-soft: #283548;

  --twnn-log-text: #e5e7eb;
  --twnn-log-text-muted: #9ca3af;

  --twnn-log-accent: #3b82f6;
  --twnn-log-accent-soft: rgba(59, 130, 246, 0.18);

  --twnn-log-info: #3b82f6;
  --twnn-log-info-soft: rgba(59, 130, 246, 0.12);

  --twnn-log-warn: #f59e0b;
  --twnn-log-warn-soft: rgba(245, 158, 11, 0.12);

  --twnn-log-error: #ef4444;
  --twnn-log-error-soft: rgba(239, 68, 68, 0.12);

  --twnn-log-debug: #94a3b8;
  --twnn-log-debug-soft: rgba(148, 163, 184, 0.1);

  --twnn-log-task: #10b981;
  --twnn-log-task-soft: rgba(16, 185, 129, 0.12);

  display: flex;
  flex-direction: column;
  min-width: 0;

  color: var(--twnn-log-text);
  background: var(--twnn-log-bg);

  border: 1px solid var(--twnn-log-border);
  border-radius: 10px;

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  font-size: 14px;
  line-height: 1.45;
}

/* Header */

.twnnLogHead {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 14px;

  padding: 12px 14px;

  background: linear-gradient(
    180deg,
    #18212f,
    #141c28
  );

  border-bottom: 1px solid var(--twnn-log-border);
}

.twnnLogTitle {
  display: flex;
  align-items: center;
  gap: 8px;

  font-size: 15px;
  font-weight: 700;
}

.twnnLogTitle::before {
  content: "";
  width: 9px;
  height: 9px;

  background: var(--twnn-log-accent);
  border-radius: 50%;

  box-shadow: 0 0 0 4px var(--twnn-log-accent-soft);
}

.twnnLogCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 24px;
  padding: 1px 7px;

  color: var(--twnn-log-text-muted);
  background: #202a39;
  border: 1px solid var(--twnn-log-border);
  border-radius: 999px;

  font-size: 11px;
  font-weight: 600;
}

.twnnLogBusy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  min-width: 0;
  color: var(--twnn-log-text-muted);
}

.twnnLogBusyLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  font-size: 12px;
  font-weight: 600;
}

.twnnLogHeadActions {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Buttons */

.twnnLogPanel button {
  appearance: none;

  padding: 5px 10px;

  color: var(--twnn-log-text);
  background: #172030;

  border: 1px solid var(--twnn-log-border);
  border-radius: 7px;

  font: inherit;
  font-size: 12px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    transform 80ms ease,
    box-shadow 120ms ease;
}

.twnnLogPanel button:hover {
  background: #243044;
  border-color: #526074;
}

.twnnLogPanel button:active {
  transform: translateY(1px);
}

.twnnLogPanel button:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.25);
  outline-offset: 1px;
  border-color: var(--twnn-log-accent);
}

.twnnLogClearBtn {
  color: #fca5a5 !important;
  background: rgba(127, 29, 29, 0.25) !important;
  border-color: rgba(248, 113, 113, 0.4) !important;
}

.twnnLogClearBtn:hover {
  color: #fecaca !important;
  background: rgba(153, 27, 27, 0.4) !important;
}

/* Filters */

.twnnLogFilters {
  display: flex;
  flex-direction: column;
  gap: 9px;

  padding: 11px 14px;

  background: #141c28;
  border-bottom: 1px solid var(--twnn-log-border);
}

.twnnLogFilterRow {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.twnnLogFilterLabel {
  padding-top: 5px;

  color: var(--twnn-log-text-muted);

  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.twnnLogScopeFilters,
.twnnLogLevelFilters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.twnnLogScopeFilters button,
.twnnLogLevelFilters button {
  padding: 4px 10px;
  border-radius: 999px;

  color: var(--twnn-log-text-muted);
  background: #172030;
}

.twnnLogScopeFilters button.active,
.twnnLogLevelFilters button.active {
  color: #ffffff;
  background: var(--twnn-log-accent);
  border-color: var(--twnn-log-accent);

  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.25);
}

.twnnLogLevelFilters button[data-twnn-log-level="error"].active {
  background: var(--twnn-log-error);
  border-color: var(--twnn-log-error);
}

.twnnLogLevelFilters button[data-twnn-log-level="warn"].active {
  color: #111827;
  background: var(--twnn-log-warn);
  border-color: var(--twnn-log-warn);
}

.twnnLogLevelFilters button[data-twnn-log-level="info"].active {
  background: var(--twnn-log-info);
  border-color: var(--twnn-log-info);
}

.twnnLogLevelFilters button[data-twnn-log-level="debug"].active {
  color: #111827;
  background: var(--twnn-log-debug);
  border-color: var(--twnn-log-debug);
}

.twnnLogLevelFilters button[data-twnn-log-level="task"].active {
  background: var(--twnn-log-task);
  border-color: var(--twnn-log-task);
}

/* Search */

.twnnLogSearchLabel {
  grid-column: 1 / -1;

  display: grid;
  grid-template-columns: 58px minmax(180px, 1fr);
  align-items: center;
  gap: 10px;

  color: var(--twnn-log-text-muted);

  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.twnnLogSearch {
  width: 100%;
  min-width: 0;

  padding: 8px 11px;

  color: var(--twnn-log-text);
  background: #0f172a;

  border: 1px solid var(--twnn-log-border);
  border-radius: 8px;

  font: inherit;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.twnnLogSearch::placeholder {
  color: #64748b;
}

.twnnLogSearch:focus {
  outline: none;
  border-color: var(--twnn-log-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Progress */

.twnnLogProgress {
  padding: 9px 14px 10px;

  background: var(--twnn-log-bg);
  border-bottom: 1px solid var(--twnn-log-border);
}

.twnnLogProgressLabel {
  margin-bottom: 6px;

  color: var(--twnn-log-text-muted);

  font-size: 12px;
  font-weight: 600;
}

.twnnLogProgressBarOuter {
  height: 7px;
  overflow: hidden;

  background: #334155;
  border-radius: 999px;
}

.twnnLogProgressBarInner {
  height: 100%;

  background: linear-gradient(
    90deg,
    #2563eb,
    #60a5fa
  );

  border-radius: inherit;
}

/* Log body
   No max-height or overflow here because the modal handles it.
*/

.twnnLogBody {
  padding: 8px;
  background: var(--twnn-log-bg);
}

.twnnLogBody:empty::after {
  content: "No log entries";
  display: grid;
  place-items: center;

  min-height: 160px;

  color: var(--twnn-log-text-muted);
  font-size: 13px;
}

/* Rows */

.twnnLogRow {
  position: relative;

  margin-bottom: 6px;
  padding: 9px 11px 9px 14px;

  background: var(--twnn-log-surface);
  border: 1px solid var(--twnn-log-border-soft);
  border-radius: 8px;
}

.twnnLogRow::before {
  content: "";

  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 4px;

  width: 3px;

  background: var(--twnn-log-debug);
  border-radius: 999px;
}

.twnnLogRow:hover {
  background: var(--twnn-log-surface-hover);
  border-color: #3d4a5d;
}

.twnnLogRow:last-child {
  margin-bottom: 0;
}

.twnnLogRowMain {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.twnnLogTime {
  color: var(--twnn-log-text-muted);

  font-family:
    "Cascadia Code",
    Consolas,
    monospace;

  font-size: 11px;
  white-space: nowrap;
}

.twnnLogScope {
  display: inline-flex;
  align-items: center;

  max-width: 220px;
  padding: 2px 7px;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  color: #cbd5e1;
  background: #273449;
  border: 1px solid #3b4a60;
  border-radius: 999px;

  font-size: 10px;
  font-weight: 700;
}

.twnnLogFrameId {
  display: inline-flex;
  align-items: center;

  max-width: 180px;
  padding: 2px 6px;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  color: var(--twnn-log-text-muted);
  border: 1px dashed var(--twnn-log-border);
  border-radius: 5px;

  font-family:
    "Cascadia Code",
    Consolas,
    monospace;

  font-size: 10px;
}

.twnnLogLevel {
  display: inline-flex;
  align-items: center;

  padding: 2px 7px;

  color: #ffffff;
  background: var(--twnn-log-debug);
  border-radius: 5px;

  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.twnnLogMsg {
  flex: 1;
  min-width: 180px;

  color: var(--twnn-log-text);

  font-size: 13px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Level colours */

.twnnLog-info {
  background: var(--twnn-log-info-soft);
}

.twnnLog-info::before,
.twnnLog-info .twnnLogLevel {
  background: var(--twnn-log-info);
}

.twnnLog-warn {
  background: var(--twnn-log-warn-soft);
}

.twnnLog-warn::before,
.twnnLog-warn .twnnLogLevel {
  background: var(--twnn-log-warn);
}

.twnnLog-warn .twnnLogLevel {
  color: #111827;
}

.twnnLog-error {
  background: var(--twnn-log-error-soft);
  border-color: rgba(239, 68, 68, 0.35);
}

.twnnLog-error::before,
.twnnLog-error .twnnLogLevel {
  background: var(--twnn-log-error);
}

.twnnLog-debug {
  background: var(--twnn-log-debug-soft);
}

.twnnLog-debug::before,
.twnnLog-debug .twnnLogLevel {
  background: var(--twnn-log-debug);
}

.twnnLog-debug .twnnLogLevel {
  color: #111827;
}

.twnnLog-task {
  background: var(--twnn-log-task-soft);
}

.twnnLog-task::before,
.twnnLog-task .twnnLogLevel {
  background: var(--twnn-log-task);
}

/* Expandable details */

.twnnLogValue {
  margin: 7px 0 0 74px;

  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--twnn-log-border-soft);
  border-radius: 7px;
}

.twnnLogValue summary {
  display: flex;
  align-items: center;
  gap: 6px;

  padding: 6px 9px;

  color: var(--twnn-log-text-muted);

  font-size: 11px;
  font-weight: 700;

  cursor: pointer;
  user-select: none;
  list-style: none;
}

.twnnLogValue summary::-webkit-details-marker {
  display: none;
}

.twnnLogValue summary::before {
  content: "›";

  font-size: 17px;
  line-height: 1;

  transition: transform 120ms ease;
}

.twnnLogValue[open] summary::before {
  transform: rotate(90deg);
}

.twnnLogValue summary:hover {
  color: var(--twnn-log-text);
  background: rgba(255, 255, 255, 0.03);
}

.twnnLogValue pre {
  margin: 0;
  padding: 9px 11px;

  color: #dbe4ef;
  background: #0f172a;

  border-top: 1px solid var(--twnn-log-border-soft);
  border-radius: 0 0 7px 7px;

  font-family:
    "Cascadia Code",
    Consolas,
    monospace;

  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Responsive */

@media (max-width: 720px) {
  .twnnLogHead {
    grid-template-columns: 1fr auto;
  }

  .twnnLogBusy {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .twnnLogFilterRow {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .twnnLogSearchLabel {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .twnnLogValue {
    margin-left: 0;
  }

  .twnnLogMsg {
    flex-basis: 100%;
    min-width: 0;
  }
}