/*
 * Styling for debug_env, layered on Bootstrap 5.3.
 *
 * Everything here rides on Bootstrap's CSS custom properties (--bs-*) rather
 * than hardcoded colours, so the light/dark switch in theme.js needs no
 * parallel set of rules.
 */

body {
    font-size: 0.9rem;
}

/* ------------------------------------------------------------------ chrome */

.brand-logo {
    height: 42px;
    width: auto;
    display: block;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--bs-primary), var(--bs-indigo, #6610f2));
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: -0.02em;
}

.brand-mark-lg {
    width: 40px;
    height: 40px;
    font-size: 1rem;
    border-radius: 9px;
}

.panel {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
}

.panel-header {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
    border-radius: 0.5rem 0.5rem 0 0;
}

.section-legend {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

/* ------------------------------------------------------------------- login */

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(13, 110, 253, 0.18), transparent),
        var(--bs-body-bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-logo {
    height: 64px;
    width: auto;
    max-width: 100%;
    display: block;
    margin: 0 auto;
}

/* -------------------------------------------------------------- inspector */

.inspector pre {
    max-height: 46vh;
    overflow: auto;
    margin: 0;
    padding: 0.6rem 0.7rem;
    font-size: 11px;
    line-height: 1.45;
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* On wide desktops the Exchange column sticks under the navbar and fills the
   remaining viewport, so Logs / Response / Request scroll inside the panel
   instead of leaving empty page below the form. */
@media (min-width: 1200px) {
    #debugPanel.inspector {
        position: sticky;
        top: 4.25rem; /* under the sticky navbar */
        max-height: calc(100vh - 5rem);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #debugPanel.inspector > .p-2 {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    #debugPanel.inspector .tab-content {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* Only the visible pane participates in the flex height. */
    #debugPanel.inspector .tab-pane.show.active {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    #debugPanel.inspector pre {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }

    #debugPanel.inspector #stateJson {
        flex: 1 1 auto;
        min-height: 12rem;
    }
}

/* Expanded inspector: covers the viewport so a large payload is readable
   without leaving the page. */
.inspector.wide {
    position: fixed;
    inset: 0.75rem;
    z-index: 1080;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
}

.inspector.wide > .p-2 {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.inspector.wide .tab-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.inspector.wide .tab-pane.show.active {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.inspector.wide pre {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

.inspector.wide #stateJson {
    flex: 1 1 auto;
    min-height: 12rem;
}

/* ------------------------------------------------------------------- logs */

.log-line {
    padding: 1px 5px;
    border-bottom: 1px solid var(--bs-border-color);
    font-variant-ligatures: none;
}

.log-line:hover {
    background: var(--bs-secondary-bg);
}

.log-index {
    display: inline-block;
    min-width: 2.6em;
    color: var(--bs-secondary-color);
    user-select: none;
}

.log-err     { color: var(--bs-danger-text-emphasis); font-weight: 600; }
.log-strong  { color: var(--bs-info-text-emphasis); font-weight: 600; }
.log-solver  { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.log-sql     { color: var(--bs-warning-text-emphasis); }

/* Clickable SQL from buildQueryLink(); underline so it reads as a link inside
   the monospace log stream without looking like a button. */
a.log-query-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
a.log-query-link:hover {
    color: var(--bs-link-color);
}

/* ------------------------------------------------------------------- diff */

.diff-added   { color: var(--bs-success-text-emphasis); }
.diff-removed { color: var(--bs-danger-text-emphasis); }
.diff-changed { color: var(--bs-warning-text-emphasis); }

/* -------------------------------------------------------------- card chips */

/* A playing card rendered as a chip. Replaces a 52-option <select> as the
   visible control; the select itself stays in the DOM, hidden, so the existing
   form-collection logic and the "disabled means the server deals" rule keep
   working untouched. */
.card-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-width: 2.9rem;
    height: 2.3rem;
    padding: 0 0.35rem;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1;
    background: #f8f9fa;
    color: #212529;
    border: 1px solid rgba(0, 0, 0, 0.35);
    border-radius: 0.3rem;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.card-chip:hover:not(.card-chip-disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.card-chip-empty {
    background: transparent;
    color: var(--bs-secondary-color);
    border-style: dashed;
    border-color: var(--bs-border-color);
    font-weight: 400;
}

.card-chip-disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.card-chip-red   { color: #d6293e; }
.card-chip-black { color: #212529; }

/* The 4x13 picker. */
.card-picker {
    padding: 0.5rem;
    min-width: 21rem;
}

.card-picker-row {
    display: grid;
    grid-template-columns: 1.4rem repeat(13, 1fr);
    gap: 2px;
    margin-bottom: 2px;
    align-items: center;
}

.card-picker-suit {
    font-weight: 700;
    text-align: center;
    font-size: 0.85rem;
}

.card-picker-cell {
    padding: 0.2rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.2rem;
    cursor: pointer;
}

.card-picker-cell:hover {
    background: var(--bs-primary);
    color: #fff;
}

.card-picker-cell.is-used {
    opacity: 0.3;
    cursor: not-allowed;
}

.card-picker-cell.is-selected {
    outline: 2px solid var(--bs-primary);
}

/* -------------------------------------------------------------- game table */

.seat-row.not-playing {
    opacity: 0.4;
}

/* Whose turn it is (nextPlayer), independent of the holecardPlayer radio.
   The "to act" label itself lives with the other Exchange badges; here we only
   draw the yellow frame on the seat row. */
.seat-row.to-act {
    outline: 2px solid var(--bs-warning);
    outline-offset: -2px;
    background: var(--bs-warning-bg-subtle);
}

.seat-row.to-act > td {
    vertical-align: middle;
}

.action-frequence {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    text-align: center;
    color: var(--bs-secondary-color);
}

/* The solved-grid dump can run to hundreds of rows. */
.grid-scroll {
    max-height: 30rem;
    overflow: auto;
}

.grid-scroll table {
    font-size: 0.72rem;
}

tr.grid-highlight > td {
    background: var(--bs-danger-bg-subtle) !important;
    color: var(--bs-danger-text-emphasis);
}

/* -------------------------------------------------- preflop range heat grid */

.pfrange-grid {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    gap: 1px;
}

.pfrange-cell {
    display: flex;
    height: 30px;
    overflow: hidden;
    font-size: 8px;
    background: var(--bs-tertiary-bg);
    border-radius: 2px;
}

.pfrange-cell > div {
    overflow: hidden;
}

.pfrange-cell:hover {
    opacity: 0.75;
}

.pfrange-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.7rem;
}

.pio-raise { background-color: #ff9f9f; }
.pio-call  { background-color: #acff9f; }
.pio-allin { background-color: #9fc9ff; }
.pio-chfd  { background-color: #ffffff; }

/* ---------------------------------------------------------------- SQL tool */

.sql-editor {
    font-family: var(--bs-font-monospace);
    font-size: 0.8rem;
    min-height: 8rem;
}

.result-scroll {
    max-height: 60vh;
    overflow: auto;
}

.result-scroll table {
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ---------------------------------------------------------- catspectors egg */

.catspectors-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(2px);
}

.catspectors-overlay.is-visible {
    display: flex;
    animation: catspectors-fade-in 0.2s ease;
}

.catspectors-modal {
    position: relative;
    max-width: min(90vw, 640px);
    max-height: 90vh;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: catspectors-pop 0.25s ease-out;
}

.catspectors-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 90vh;
    object-fit: contain;
}

.catspectors-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.catspectors-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

@keyframes catspectors-pop {
    from {
        transform: scale(0.85);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes catspectors-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
