
/* =========================================================
   Master pages – shared layout for every master (Categories,
   Locations, Units, Ledgers …). Used by MasterLayout.razor.
   Link AFTER theme.css. Colours come from theme.css (--sg-*).
   ========================================================= */

.master-grid {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

/* ---------- Page header buttons ---------- */
.master-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

/* ---------- Form card ---------- */
.master-form {
    position: sticky;
    top: 24px;
}

.master-form-el { display: flex; flex-direction: column; }

.master-status { margin-bottom: 0; }

.master-hint {
    margin: 10px 0 0;
    font-size: .88rem;
    line-height: 1.45;
}

/* ---------- List card ---------- */
.master-count { font-weight: 400; font-size: .95rem; }

.master-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--sg-line);
}

table.master-table td.master-name { font-weight: 500; }

table.master-table tbody tr.is-editing { background: rgba(var(--sg-brand-rgb), .10); }

.master-confirm {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Tablet & phone: form becomes a full-screen sheet ---------- */
@media (max-width: 992px) {
    .master-grid { grid-template-columns: minmax(0, 1fr); }

    .master-form { display: none; }

    .master-form.open {
        position: fixed;
        inset: 0;
        z-index: 1050;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        border: 0;
        border-radius: 0;
    }

    .master-form.open .master-form-el { flex: 1; }
    .master-form.open .master-form-el .sg-card-body { flex: 1; }
}

/* ---------- Phone: table rows become cards ----------
   Extra cells can add data-label="Code" to show a small label. */
@media (max-width: 640px) {
    .master-toolbar { padding: 14px 16px; }

    table.master-table thead { display: none; }
    table.master-table,
    table.master-table tbody { display: block; }

    table.master-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px 14px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--sg-line);
    }

    table.master-table tbody tr:last-child { border-bottom: 0; }

    table.master-table td { display: block; padding: 0; border: 0; }
    table.master-table td.sg-col-num { display: none; }
    table.master-table td.master-name { flex: 1 1 100%; font-weight: 600; }
    table.master-table td[data-label]::before { content: attr(data-label) ": "; color: var(--sg-muted); }
    table.master-table td.sg-col-actions { width: auto; margin-left: auto; }
}

/* =========================================================
   Split layout – form card on the left, SC_Table list on the right
   (used by the Category_Master_New style pages; same for every master)
   ========================================================= */
.master-split {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.master-list-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

@media (max-width: 992px) {
    .master-split { grid-template-columns: minmax(0, 1fr); }
}

/* Small red label above the page title */
.master-eyebrow {
    margin-bottom: 6px;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--sg-brand-light);
}

/* ---------- Premium form card ---------- */
.master-card {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .03), transparent 160px),
        var(--sg-surface);
    border: 1px solid var(--sg-line);
    border-radius: 20px;
    box-shadow: 0 28px 60px -34px rgba(0, 0, 0, .9);
}

/* thin brand-coloured edge along the top (amber while editing) */
.master-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--sg-brand), var(--sg-brand-light) 55%, transparent);
}
.master-card.is-edit::before { background: linear-gradient(90deg, var(--sg-warning), transparent); }

.master-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 22px 18px;
}

.master-card-headtext { flex: 1; min-width: 0; }

.master-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    font-size: 1.25rem;
    color: var(--sg-brand-light);
    background: rgba(var(--sg-brand-rgb), .14);
    border: 1px solid rgba(var(--sg-brand-rgb), .38);
    border-radius: 14px;
}
.is-edit .master-icon {
    color: var(--sg-warning);
    background: rgba(245, 165, 36, .13);
    border-color: rgba(245, 165, 36, .42);
}

.master-card-title { margin: 0; font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; color: var(--sg-text); }
.master-card-sub { margin: 3px 0 0; font-size: .88rem; color: var(--sg-muted); }

.master-card-body { padding: 6px 22px 24px; }

.master-card-foot {
    display: flex;
    gap: 12px;
    padding: 16px 22px;
    background: var(--sg-surface-2);
    border-top: 1px solid var(--sg-line);
}
.master-card-foot .sg-btn-primary { flex: 1; }

/* Input with a leading icon */
.sg-input-icon { position: relative; }
.sg-input-icon > .bi {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sg-placeholder);
    pointer-events: none;
    transition: color .15s ease;
}
.sg-input-icon > .sg-input { padding-left: 44px; }
.sg-input-icon:focus-within > .bi { color: var(--sg-brand-light); }

/* Keyboard hint chip */
.master-kbd {
    padding: 2px 8px;
    font: inherit;
    font-size: .76rem;
    color: var(--sg-muted);
    background: var(--sg-surface-2);
    border: 1px solid var(--sg-line);
    border-radius: 6px;
}

/* Amber badge + full-width segmented control */
.sg-badge--warning { color: var(--sg-warning); background: rgba(245, 165, 36, .12); border-color: rgba(245, 165, 36, .4); }
.sg-segment--block { display: flex; }
.sg-segment--block button { flex: 1; }
