/* static/css/debug_panel.css */

/* =========================================================
   DEBUG PANEL: CONTAINER
   ========================================================= */

.dbg-panel {
  position: fixed;
  right: 8px;
  bottom: 8px;
  width: 420px;
  max-width: 95vw;
  max-height: 85vh;
  min-width: 320px;
  min-height: 140px;
  overflow: auto;
  resize: both;

  background: rgba(20, 20, 20, 0.92);
  color: #e6e6e6;
  font: 12px/1.35 Consolas, monospace;
  border: 1px solid #444;
  border-radius: 6px;
  z-index: 99999;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}


/* =========================================================
   DEBUG PANEL: HEADER
   ========================================================= */

.dbg-header {
  padding: 6px 8px;
  background: #2b2b2b;
  border-bottom: 1px solid #444;
  cursor: move;

  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.dbg-header-main {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
  word-break: break-word;
}

.dbg-header-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.dbg-mini-btn {
  border: 1px solid #555;
  background: #3a3a3a;
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  cursor: pointer;
}


/* =========================================================
   DEBUG PANEL: TOP-LEVEL DETAILS SECTIONS
   ========================================================= */

.dbg-panel > details {
  border-top: 1px solid #333;
}

/* Only style top-level summaries */
.dbg-panel > details > summary {
  cursor: pointer;
  padding: 6px 8px;
  background: #1f1f1f;
  font-weight: 600;
}


/* =========================================================
   DEBUG PANEL: GRID
   ========================================================= */

.dbg-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 4px 8px;
  padding: 6px 8px 8px 8px;
}


/* =========================================================
   DEBUG PANEL: TOGGLE BUTTON
   ========================================================= */

.dbg-toggle {
  position: fixed;
  right: 50px;
  bottom: 10px;
  z-index: 100000;
  border: 0;
  border-radius: 20px;
  padding: 6px 10px;
  background: #333;
  color: #fff;
  cursor: pointer;
}


/* =========================================================
   DEBUG PANEL: FORMS SECTION
   ========================================================= */

.dbg-panel-empty {
  padding: 6px 8px 8px 8px;
  color: #bbb;
  font-style: italic;
}

/* Indentation wrapper for ALL forms */
.dbg-forms-list {
  margin-left: 1rem;
  padding-left: 0.75rem;
  border-left: 3px solid #888;
}

/* Each form */
.dbg-form {
  margin: 0.4rem 0;
}

/* Form summary */
.dbg-form > summary {
  display: block;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #f0f0f0;
  font-weight: 600;
  cursor: pointer;
}

/* Custom expand marker */
.dbg-form > summary::before {
  content: "▸ ";
}

.dbg-form[open] > summary::before {
  content: "▾ ";
}

/* Form body indentation */
.dbg-form-body {
  margin-left: 1rem;
  padding-left: 0.75rem;
  border-left: 2px dashed #777;
}

/* Metadata */
.dbg-form-meta {
  margin: 0.3rem 0;
}

/* Fields */
.dbg-form-fields {
  margin-top: 0.3rem;
}

.dbg-field-name {
  font-weight: 600;
  color: #f0f0f0;
}

.dbg-field-meta {
  font-size: 0.85em;
  color: #d0d0d0;
}

/* Flags */
.dbg-flag {
  background: #eee;
  color: #222;
  padding: 0 0.3em;
  border-radius: 3px;
  margin-left: 0.3em;
  font-size: 0.8em;
}

/* Errors */
.dbg-error {
  color: #ff7777;
  margin-left: 0.4em;
  font-weight: 600;
}

.dbg-panel-empty-inline {
  opacity: 0.7;
  font-style: italic;
  margin-left: 4px;
  color: #aaa;
}

/* ========================================================================
   Template Context Explorer
   ======================================================================== */

.dbg-context-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid rgba(127, 127, 127, 0.28);
}

.dbg-context-tree {
    padding: 0.65rem 0.75rem 1rem;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.dbg-context-node {
    min-width: 0;
    margin: 0.22rem 0;
}

.dbg-context-details {
    margin: 0.2rem 0;
}

.dbg-context-summary,
.dbg-context-leaf {
    display: grid;
    grid-template-columns:
        minmax(10rem, 0.8fr)
        minmax(8rem, 0.65fr)
        minmax(12rem, 2fr);
    align-items: baseline;
    column-gap: 0.75rem;
    row-gap: 0.2rem;

    padding: 0.32rem 0.45rem;
    border-radius: 0.25rem;

    overflow-wrap: anywhere;
}

.dbg-context-summary {
    cursor: pointer;
}

.dbg-context-summary:hover,
.dbg-context-leaf:hover {
    background: rgba(127, 127, 127, 0.13);
}

.dbg-context-children {
    margin: 0.35rem 0 0.5rem 1.45rem;
    padding-left: 0.8rem;
    border-left: 2px solid rgba(127, 127, 127, 0.25);
}

.dbg-context-name {
    font-weight: 700;
}

.dbg-context-type {
    opacity: 0.72;
    font-size: 0.72rem;
}

.dbg-context-type::before {
    content: "[";
}

.dbg-context-type::after {
    content: "]";
}

.dbg-context-value {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.dbg-context-note {
    grid-column: 3;
    opacity: 0.72;
    font-style: italic;
}

.dbg-context-truncated {
    grid-column: 3;
    width: fit-content;
    padding: 0 0.28rem;
    border: 1px solid currentColor;
    border-radius: 0.2rem;
    opacity: 0.75;
    font-size: 0.67rem;
    text-transform: uppercase;
}


/* ------------------------------------------------------------------------
   Type colours
   ------------------------------------------------------------------------ */

.dbg-context-kind-request > .dbg-context-details > .dbg-context-summary {
    border-left: 3px solid #d97706;
}

.dbg-context-kind-model > .dbg-context-details > .dbg-context-summary {
    border-left: 3px solid #16a34a;
}

.dbg-context-kind-form > .dbg-context-details > .dbg-context-summary {
    border-left: 3px solid #9333ea;
}

.dbg-context-kind-queryset > .dbg-context-details > .dbg-context-summary {
    border-left: 3px solid #0891b2;
}

.dbg-context-kind-mapping > .dbg-context-details > .dbg-context-summary,
.dbg-context-kind-sequence > .dbg-context-details > .dbg-context-summary {
    border-left: 3px solid #2563eb;
}

.dbg-context-kind-string .dbg-context-value {
    color: #0f766e;
}

.dbg-context-kind-number .dbg-context-value {
    color: #7c3aed;
}

.dbg-context-kind-bool-true .dbg-context-value {
    color: #15803d;
    font-weight: 700;
}

.dbg-context-kind-bool-true .dbg-context-value::before {
    content: "✓ ";
}

.dbg-context-kind-bool-false .dbg-context-value {
    color: #b91c1c;
    font-weight: 700;
}

.dbg-context-kind-bool-false .dbg-context-value::before {
    content: "✗ ";
}

.dbg-context-kind-none .dbg-context-value {
    opacity: 0.6;
    font-style: italic;
}

.dbg-context-root {
    margin: 0.55rem 0;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid rgba(127, 127, 127, 0.17);
}

.dbg-context-root:last-child {
    border-bottom: 0;
}

@media (max-width: 700px) {
    .dbg-context-summary,
    .dbg-context-leaf {
        grid-template-columns: minmax(8rem, 1fr) minmax(10rem, 2fr);
    }

    .dbg-context-type {
        grid-column: 1;
        grid-row: 2;
    }

    .dbg-context-value {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    .dbg-context-note,
    .dbg-context-truncated {
        grid-column: 2;
    }
}

@media (max-width: 900px) {
    .dbg-context-provenance-row {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .dbg-context-source {
        grid-column: 1 / -1;
    }
}

/* ========================================================================
   Context provenance
   ======================================================================== */

.dbg-context-source {
    grid-column: 3;
    font-size: 0.7rem;
    opacity: 0.68;
    font-style: italic;
}

.dbg-context-provenance {
    margin: 0.4rem 0 0.55rem 1rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(127, 127, 127, 0.25);
    border-radius: 0.3rem;
}

.dbg-context-provenance > summary {
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
}

.dbg-context-provenance-list {
    margin-top: 0.4rem;
}

.dbg-context-provenance-row {
    display: grid;
    grid-template-columns:
        minmax(4.5rem, auto)
        minmax(10rem, 1fr)
        minmax(7rem, auto)
        minmax(10rem, 2fr)
        minmax(6rem, auto);

    gap: 0.5rem;
    padding: 0.25rem 0.35rem;
    border-top: 1px solid rgba(127, 127, 127, 0.16);
    font-size: 0.72rem;
    overflow-wrap: anywhere;
}

.dbg-context-provenance-winner {
    border-left: 3px solid #15803d;
    background: rgba(21, 128, 61, 0.08);
}

.dbg-context-layers {
    margin: 0.8rem 0.6rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid rgba(127, 127, 127, 0.3);
    border-radius: 0.35rem;
}

.dbg-context-layers > summary {
    cursor: pointer;
    font-weight: 700;
}

.dbg-context-layer-list {
    margin-top: 0.55rem;
}

.dbg-context-layer {
    margin: 0.35rem 0;
    border-top: 1px solid rgba(127, 127, 127, 0.2);
    padding-top: 0.35rem;
}

.dbg-context-layer > summary {
    cursor: pointer;
    font-size: 0.77rem;
    font-weight: 700;
}

/*.dbg-context-kind-dataclass*/
/*    > .dbg-context-details*/
/*    > .dbg-context-summary {*/
/*    border-left: 3px solid #c026d3;*/
/*}*/

.dbg-context-kind-dataclass
    > .dbg-context-details
    > .dbg-context-summary
    > .dbg-context-type {
    border-left: 3px solid #c026d3;
    color: #a21caf;
}
