/* ---------- Theming ---------- */
:root {
    --accent: #3669cc;
    --border: #d0d0d0;
    --bg-panel: #ffffff;
    --bg-toolbar: #ffffff;
    --radius: 6px;
    --shadow: 0 2px 4px rgba(0,0,0,.05);
    --font-code: "Fira Mono", monospace;
    --accent-soft: rgba(178, 129, 207, 0.25);
}

html,body {
    height:100%;
    margin:0;
    font-family:system-ui, Roboto, sans-serif;
    font-size: 12pt;
    color:#222;
}

html {
    box-sizing: border-box;
}
*, *::before, *::after {
    box-sizing: inherit;
}

/* 1️⃣  Make <body> a vertical flex-container */
body { display: flex; flex-direction: column; }

button,select,input,textarea {font:inherit}
textarea {resize:both}

/* ---------- Toolbar ---------- */
.toolbar {
    display:flex;align-items:center;gap:.4rem;
    padding:.4rem .8rem;background:var(--bg-toolbar);;
    position:sticky;top:0;z-index:10;
}
.toolbar .br {
    border-left: 1px black solid;
    padding-left: 10px;
}
.ti{background:none;border:0;padding:0;cursor:pointer}
.ti img{width:36px;height:36px;display:block}
.ti--right{margin-left:auto}
.tt{font-weight:500;margin-left:.8rem}

input[type="text"], .input--short, .input--long {
    font: inherit;
    border: 1px solid var(--border, #d0d0d0);
    border-radius: var(--radius, 6px);
    background: #f4f7fa;
    color: inherit;
    padding: .45rem .7rem;
    outline: none;
    line-height: 1.3;
    transition: border-color .13s;
    font-size: 1em;
    box-sizing: border-box;
}

input[type="text"]:hover,
input[type="text"]:focus,
.input--short:focus,
.input--long:focus {
    border-color: var(--accent, #3669cc);
    background: #fff;
}

.input--short { width: 10rem; max-width: 100%; box-sizing: border-box;}
.input--long  { width: 20rem; max-width: 100%; box-sizing: border-box;}

.dash-panel {
    background: var(--bg-toolbar);
    border: 1.5px solid var(--border);
    border-radius: 1.8rem;                /* more rounded corners! */
    box-shadow: 0 4px 24px rgba(60,64,67,.09);
    padding: 0.5rem;
    min-width: 0; min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* For cards to never overflow on resize: */
    overflow: auto;
}

/* Panel itself shouldn't scroll; inner bodies will */
.dash-panel {
    overflow: hidden;      /* ← was auto */
    min-height: 0;
    height: 100%;
}

.dash-panel.maximized {
    position: fixed !important;
    top: 100px; /* adjust to match your header */
    left: 0;
    width: 100vw;
    height: calc(100vh - 100px);
    z-index: 2000;
    background: #fff;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.12);
    overflow: auto;
}
body.maximized-panel-active main .dash-panel:not(.maximized) {
    visibility: hidden;
    pointer-events: none;
}

/* Any card in a dash-panel can grow when it has content */
.dash-panel > .lc-section:has(.lc-body:not(:empty)) {
    flex: 1 1 0;
    min-height: 0;         /* critical for nested overflow */
}

/* When a section grows, its body becomes the scroll container */
.dash-panel > .lc-section:has(.lc-body:not(:empty)) .lc-body {
    flex: 1 1 0;
    min-height: 0;
    overflow: auto;        /* ← actual scrolling happens here */
}

/* Optional: better headings and spacing */
.dash-panel h2, .dash-panel h3 {
    margin-top: .7em;
    margin-bottom: .7em;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Optional: for list/table items inside */
.dash-panel table, .dash-panel .list {
    border-radius: 1rem;
    overflow: hidden;
    background: var(--bg-panel);
}

.dash-panel .button{
     align-self: flex-start;     /* left-align and no stretch */
     width: auto;                /* restore intrinsic width */
     max-width: fit-content;     /* modern browsers; harmless fallback */
}

.icon-button {
    background: none;
    border: none;
    box-shadow: none;
    padding: 2px;
    margin: 6px 0 12px 4px;
    border-radius: 50%;
    cursor: pointer;
    transition: background .14s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-button:hover {
    background: #e5ebf5;
}
.icon-button:active {
    background: #dbe3ee;
}
.container{
    display:flex;
    flex-direction:column;
    gap:.6rem;
    min-height:0;                       /* allow inner panels to shrink/scroll */
}


/* ---------- Forms & grids ---------- */
fieldset{border:0;padding:0;margin:0;display:flex;flex-wrap:wrap;gap:.6rem}
.checkbox-grid label{display:flex;gap:.3rem;white-space:nowrap}

.button{
    padding:.4rem .8rem;
    margin-top: 0.3rem;
    border:1px solid var(--border);
    background:#fff;
    border-radius:var(--radius);cursor:pointer
}

.button--primary{background:var(--accent);color:#fff;border-color:var(--accent)}


a {
    color: var(--accent);
    text-decoration: none;
}
a:hover, a:focus {
    text-decoration: underline;
}

label {
    font-size: 10pt;
}



.box {
    flex: 1 1 auto;         /* flex-grow: 1; flex-shrink: 1; flex-basis: 0 */
    min-height: 200px;   /* Ensures at least some content is visible */
    overflow: auto;      /* Allows scrolling if content overflows */
    padding: 10px;
    flex-basis:  auto;
}

/* GodView overlay that sits on top of the info column */
#godView{
    position: absolute;     /* remove from normal flow */
    inset: 0;               /* stretch to the panel’s edges */
    z-index: 20;            /* above filters/info but below global modals */
    display: flex;          /* center the .chat card */
    align-items: center;
    justify-content: center;
    background: var(--bg-panel);  /* same colour as panel */
    overflow: auto;         /* scroll *inside* the overlay if chat grows */
}

/* 1️⃣  let every management table use the full column width */
.list{
    width:100%;
    table-layout:auto;      /* cells obey explicit / remaining width */
}

/* 2️⃣  first cell in each row gets the remaining space */
.list td:first-child{ width:100%; }

/* 3️⃣  inputs inside those cells grow/shrink with the table */
.list input[type="text"]{
    width:100%;
    box-sizing:border-box;   /* include padding in the 100 % */
}

table.list tr > td:last-child{
    padding-right: .75rem  !important;          /* ← adjust to taste */
}

th {
    text-align: left;
}

.header-row {
    display: flex;
    align-items: center; /* Vertically aligns images and h3 */
    gap: 10px; /* Optional: space between heading and images */
}

.image-row img {
    height: 24px; /* Adjust as needed */
    display: inline-block;
}

/* =========================================================================
   Themed dropdown – add class="dropdown" to <select>
   ===================================================================== */
.dropdown{
    /* Force the same font + radius used everywhere else */
    font: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--fg);
    padding: .45rem 2.2rem .45rem .7rem;   /* room for custom arrow  */
    outline: none;
    cursor: pointer;
    line-height: 1.3;

    /* Remove native arrow (we draw our own) */
    appearance:none;            /* Firefox & modern */
    -webkit-appearance:none;    /* Safari */
    -moz-appearance:none;       /* legacy */
    background-image:
            url("data:image/svg+xml,%3Csvg viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2399a' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat:no-repeat;
    background-position: right .8rem center;
    background-size: .75rem;
}

/* Hover / focus */
.dropdown:hover,
.dropdown:focus{
    border-color: var(--accent);
}

/* Disabled state */
.dropdown:disabled{
    background: var(--bg-toolbar);
    color: var(--fg-muted);
    cursor: not-allowed;
}

/* Optional: ensure options inherit font + line-height (mostly for Safari) */
.dropdown option{
    font: inherit;
    line-height: 1.4;
}

/* quick themed message box */
.notice{
    background: var(--bg-panel);
    border-left: 4px solid var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .8rem 1.2rem;
    margin: 1rem auto;
    max-width: 820px;
    position: relative;
    font-size: 1rem;
}
.notice .close{
    position: absolute;
    top: 0; right: .5rem;
    border: 0; background: none; color: var(--fg);
    font-size: 1.2rem; line-height: 1;
    cursor: pointer;
}
.notice .close:focus{ outline: 2px solid var(--accent); }

.overlay-backdrop{
    width:100%; height:100%;
    background:rgba(0,0,0,.45);   /* dim the page */
    display:flex;
    align-items:center;
    justify-content:center;
}

/* the actual white card */
.overlay-card{
    background:var(--bg-panel);
    border:1px solid var(--border);
    border-radius:var(--radius);
    box-shadow:var(--shadow-lg,0 6px 24px rgba(0,0,0,.2));
    max-width:720px;
    width:90%;
    max-height:90vh;
    overflow:hidden;
    display:flex;
    flex-direction:column;
}

/* -------------------------------------------------------------
   transient popup message (appears over the left column)
   ------------------------------------------------------------- */

/* base state: completely hidden */
.popup-msg{
    position:absolute; top:1.2rem; left:1.2rem;
    max-width:320px;
    background:var(--accent); color:#fff;
    border-radius:var(--radius);
    box-shadow:0 8px 28px rgba(0,0,0,.35);
    padding:1rem 1.25rem 1rem 1rem;
    font-weight:600; line-height:1.35;
    display:flex; gap:.8rem; align-items:center;

    opacity:0;
    transform:translateX(-120%);
    visibility:hidden;        /* ← nothing to flash */
}

/* slide-in */
@keyframes slideIn{ to{opacity:1;transform:translateX(0);} }
@keyframes fadeOut{to{opacity:0;transform:translateX(-120%);} }

.popup-msg.show{
    visibility:visible;       /* becomes paintable only now */
    animation:slideIn .45s cubic-bezier(.32,.72,.18,1.25) forwards;
}

.popup-msg.fade{ animation:fadeOut .6s ease forwards; }

.popup-msg .close{
    border:0;background:none;
    color:inherit;font-size:1.4rem;line-height:1;
    cursor:pointer;margin-left:auto;padding:0 .1rem;opacity:.85;
}
.popup-msg .close:hover{opacity:1;}


.dropdown {
    padding: .5em .9em;
    border-radius: 10px;
    border: 1px solid var(--border, #d0d0d0);
    font-size: 1em;
    background: #f4f7fa;
    margin-left: 0.6em;
}

/* Section card: do NOT grow by default (hugs content) */
.lc-section{
    display:flex; flex-direction:column;
    flex:0 0 auto;                      /* no growth by default */
    min-height:0; overflow:hidden;
    border:1.5px solid var(--border);
    border-radius:1rem; background:var(--bg-toolbar);
}

/* Fixed title */
.lc-title{
    flex:0 0 auto;
    padding:.55rem .75rem; font-weight:600;
    border-bottom:1px solid var(--border);
}

/* Body */
.lc-body{
    /* default: hug content (no scroll needed) */
    flex:0 0 auto;
    min-height:0;                       /* critical for scroll when flexing */
    overflow:auto;                      /* enables scroll when it gets height */
    padding:10px;
}

/* Hide body when empty, keep title visible */
.lc-body:empty{ display:none; padding:0; }

/*----------- */
/* Let the page layout breathe */
html, body { height: 100%; }
body { display:flex; flex-direction:column; min-height:100vh; }

/* Make <main> consume remaining height instead of a calc() guess */
main.dashboard-3col{
    display:grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
}

main.dashboard-2col{
    display:grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
}

/* If you keep grid-template-rows elsewhere, neutralize it for this layout */
main.dashboard-1col, main.dashboard-2col, main.dashboard-3col { grid-template-rows: unset; }

/* (Optional) If you use 1- or 2-col variants the same way */
.dashboard-1col, .dashboard-2col, .dashboard-3col{
    flex:1 1 auto;
    min-height:0;
    height:auto;
    grid-auto-rows: 1fr;   /* so cards fill vertically if you add more rows */
    /* keep your spacing */
    gap: 0.4rem;
    padding: 0.8rem;
    background: var(--bg-panel);
    overflow: hidden;
}

.dashboard-1col {
    grid-template-columns: 1fr;  /* Adjust to taste */
}

.dashboard-2col {
    grid-template-columns: 1fr 1fr;  /* Adjust to taste */
}

.dashboard-3col {
    grid-template-columns: 1fr 1fr 1fr;  /* Adjust to taste */
}

.dashboard-3col > .dash-panel, .dashboard-2col > .dash-panel, .dashboard-1col > .dash-panel {
    height: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.container {
    display:flex;
    flex-direction:column;
    gap:.6rem;
    min-height:0;                       /* allow inner panels to shrink/scroll */
}

.container .lc-section { flex: 0 0 auto; }

/* If a section has content, it participates in sharing the column height */
.container .lc-section:has(.lc-body:not(:empty)) {
    flex: 1 1 0;           /* it will grow */
    min-height: 0;
}

/* When a section grows, its body stretches and becomes the scroll container */
.container .lc-section:has(.lc-body:not(:empty)) .lc-body{
    flex: 1 1 0;           /* give the body the available height */
    min-height: 0;         /* needed for overflow to work in flex */
    overflow: auto;        /* scrolls if content exceeds height */
}


.input-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem;
}
.input-row input {
    flex: 1;
    padding: .35rem .5rem;
    border: 1px solid #ccc;
    border-radius: 6px;
}
.input-row img {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* wrapper ensures iframe fills flex space */
.iframe-wrapper {
    flex: 1 1 auto;          /* grow/shrink inside .dash-panel */
    display: flex;
    flex-direction: column;
    min-height: 0;           /* critical so iframe can shrink/scroll */
}

/* iframe takes all available space */
.iframe-wrapper iframe {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 1px var(--border); /* subtle border, matches theme */
}

/* ensure the hidden attribute actually hides it */
.iframe-wrapper[hidden] { display: none !important; }

