﻿/* =========================================================
   TMS — Global Site Styles (Case B: Header OUTSIDE grid)
   Layout + Sidebar (collapse & drawer) + Forms + Utilities
   - Sidebar matches site.js (body.sidebar-collapsed, #tmsSidebar.open, .tms-backdrop.show)
   - Floating label sits ON the border center (outlined look)
   - Error message BELOW the border (outside .x-field)
   - Desktop forms: 4 fields per row
========================================================= */

/* ---------------- THEME TOKENS ---------------- */
:root {
    /* Brand */
    --tms-primary: #5b3bf6; /* purple outlined look */
    --tms-on-primary: #ffffff;
    --tms-secondary: #0ea5e9;
    --tms-on-secondary: #071018;
    /* Surfaces & text */
    --tms-surface: #ffffff;
    --tms-bg: #f8fafc;
    --tms-text: #0f172a;
    --tms-muted: #64748b;
    /* Borders & effects */
    --tms-border: #e5e7eb;
    --tms-shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
    /* States */
    --tms-danger: #dc2626;
    --tms-danger-ink: #7f1d1d;
    --tms-danger-bg: #fef2f2;
    --tms-danger-border: #fecaca;
    --tms-success: #059669;
    --tms-success-bg: #ecfdf5;
    --tms-success-border: #a7f3d0;
    /* Field */
    --tms-field-bg: #ffffff;
    --tms-field-border: #c7b6ff; /* outline color (light purple) */
    --tms-label: var(--tms-primary);
    /* Layout */
    --sidebar-w: 260px;
    --header-h: 56px;
    --z-header: 1000;
    --z-sidebar: 900;
    --z-overlay: 800;
    /* Status colors */
    --ok-bg: #e6f7ed; /* Active bg */
    --ok-text: #065f46; /* Active text */
    --ok-border: #a7f3d0;
    --warn-bg: #fff1f2; /* Inactive bg */
    --warn-text: #9f1239; /* Inactive text */
    --warn-border: #fecdd3;
}

/* ---------------- BASE ---------------- */
* {
    box-sizing: border-box
}

html, body {
    height: 100%
}

body {
    margin: 0;
    font: 14px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial;
    color: var(--tms-text);
    background: var(--tms-bg);
    overflow: hidden; /* lock page; scroll lives in .tms-content */
}

a {
    color: var(--tms-primary);
    text-decoration: none
}

    a:hover {
        text-decoration: underline
    }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--tms-secondary) 35%, transparent);
    outline-offset: 2px
}

/* Header (OUTSIDE grid; sticky) */
.tms-header {
    height: var(--header-h);
    background: var(--tms-surface);
    border-bottom: 1px solid var(--tms-border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    flex-shrink: 0;
}

.tms-sidebar-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--tms-border);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer
}

    .tms-sidebar-toggle svg {
        width: 18px;
        height: 18px
    }

/* =========================================================
   LAYOUT GRID (Sidebar + Content only) — Case B
========================================================= */
.tms-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr; /* only one row */
    height: calc(100vh - var(--header-h));
    min-height: calc(100vh - var(--header-h));
    background: var(--tms-bg);
}

/* Sidebar */
#tmsSidebar {
    grid-column: 1/2;
    grid-row: 1/-1;
    width: var(--sidebar-w);
    background: var(--tms-surface);
    border-right: 1px solid var(--tms-border);
    z-index: var(--z-sidebar);
    transition: width .25s ease, transform .25s ease;
    min-height: 0;
}

    #tmsSidebar .tms-nav {
        padding: 8px
    }

        #tmsSidebar .tms-nav a {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 10px;
            color: var(--tms-text)
        }

            #tmsSidebar .tms-nav a:hover {
                background: color-mix(in srgb, var(--tms-primary) 12%, var(--tms-surface) 88%);
                text-decoration: none
            }

            #tmsSidebar .tms-nav a.is-active {
                background: color-mix(in srgb, var(--tms-primary) 18%, var(--tms-surface) 82%);
                color: var(--tms-text)
            }

/* Content (only this scrolls) */
.tms-content {
    grid-column: 2/-1;
    grid-row: 1/-1;
    padding: 12px;
    overflow: auto;
    min-height: 0;
}

    .tms-content > *:first-child {
        margin-top: 0 !important
    }
/* kill accidental top gap */

/* Desktop collapse (JS toggles body.sidebar-collapsed) */
@media (min-width:992px) {
    body.sidebar-collapsed #tmsSidebar {
        width: 0 !important;
        min-width: 0 !important;
        overflow: hidden;
        border-right: 0
    }

    body.sidebar-collapsed .tms-shell {
        grid-template-columns: 0 1fr;
    }

    body.sidebar-collapsed .tms-content {
        grid-column: 1/-1;
    }
}

/* Mobile drawer (JS sets #tmsSidebar.open and .tms-backdrop.show) */
@media (max-width:991.98px) {
    .tms-shell {
        grid-template-columns: 1fr
    }

    #tmsSidebar {
        position: fixed;
        left: 0;
        top: var(--header-h);
        height: calc(100vh - var(--header-h));
        transform: translateX(-100%);
        box-shadow: var(--tms-shadow)
    }

        #tmsSidebar.open {
            transform: translateX(0)
        }

    .tms-backdrop {
        position: fixed;
        inset: var(--header-h) 0 0 0;
        background: rgba(0,0,0,.35);
        display: none;
        z-index: var(--z-overlay)
    }

        .tms-backdrop.show {
            display: block
        }

    .tms-content {
        grid-column: 1/-1
    }
}
/* ========= Theme fallbacks (if not already present) ========= */
:root {
    --tms-bg: #ffffff;
    --tms-surface: #ffffff;
    --tms-border: #e5e7eb;
    --tms-muted: #6b7280;
    --tms-text: #111827;
    --tms-primary: #2563eb;
    --tms-primary-600: #2563eb;
    --tms-primary-700: #1d4ed8;
    --tms-primary-50: #eff6ff;
    --tms-ok-bg: var(--ok-bg, #e6f7ed);
    --tms-ok-text: var(--ok-text, #065f46);
    --tms-ok-bd: var(--ok-border, #a7f3d0);
    --tms-warn-bg: var(--warn-bg, #fff1f2);
    --tms-warn-text: var(--warn-text, #9f1239);
    --tms-warn-bd: var(--warn-border, #fecdd3);
    --radius-lg: 12px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.06), 0 1px 1px rgba(0,0,0,.04);
    --shadow-md: 0 6px 12px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.06);
}

/* ========= Section/Card ========= */
.tms-section {
    background: var(--tms-surface);
    border: 1px solid var(--tms-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 12px;
    margin: 10px 0;
}

@media (min-width: 768px) {
    .tms-section {
        padding: 16px;
    }
}

@media (min-width: 1200px) {
    .tms-section {
        padding: 20px;
    }
}

/* Optional header area inside section */
.tms-section .tms-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.tms-section .tms-section__title {
    font-weight: 600;
    color: var(--tms-text);
}

.tms-section.is-muted {
    background: #fafafa;
    border-style: dashed;
}

.tms-section.is-warning {
    background: var(--tms-warn-bg);
    border-color: var(--tms-warn-bd);
}

/* ========= Segmented control =========
   Markup:
   <div class="tms-seg">
     <label><input type="radio" name="cat" value="Top" checked> Top</label>
     <label><input type="radio" name="cat" value="Bottom"> Bottom</label>
   </div>
*/
.tms-seg {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--tms-border);
    border-radius: 999px;
    background: #f9fafb;
    padding: 2px;
    gap: 2px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}

    .tms-seg > label {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 6px 12px;
        min-width: 72px;
        border-radius: 999px;
        font-size: 13px;
        line-height: 1;
        color: var(--tms-muted);
        cursor: pointer;
        user-select: none;
        transition: all .15s ease;
    }

        .tms-seg > label:hover {
            background: #f3f4f6;
        }

        .tms-seg > label:has(input:focus-visible) {
            outline: 2px solid var(--tms-primary-600);
            outline-offset: 2px;
        }

    .tms-seg input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

        /* Selected state */
        .tms-seg input:checked + * /* for alternative markup */ {
        }

    .tms-seg > label:has(input:checked) {
        background: var(--tms-primary-50);
        color: var(--tms-primary-700);
        box-shadow: 0 0 0 1px var(--tms-primary-50) inset, 0 1px 0 rgba(255,255,255,.6);
    }

    /* Compact & block variants if needed */
    .tms-seg.is-compact > label {
        padding: 4px 10px;
        min-width: auto;
    }

    .tms-seg.is-block {
        display: flex;
        width: 100%;
    }

        .tms-seg.is-block > label {
            flex: 1 1 auto;
        }

    /* Status-colour helper inside seg (optional) */
    .tms-seg .ok {
        color: var(--tms-ok-text);
    }

    .tms-seg .warn {
        color: var(--tms-warn-text);
    }

/* ========= Small helpers ========= */
.tms-card {
    background: var(--tms-surface);
    border: 1px solid var(--tms-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.tms-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}


/* ================== tms-switch (toggle) ================== */
/* Markup:
<label class="tms-switch">
  <input type="checkbox">
  <span aria-hidden="true"></span>
</label>
*/

/* wrapper */
.tms-switch {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

    /* the hidden checkbox */
    .tms-switch > input {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        margin: 0;
        cursor: pointer;
    }

    /* track */
    .tms-switch > span {
        --sw-h: 22px;
        --sw-w: 40px;
        --sw-pad: 2px;
        --sw-knob: calc(var(--sw-h) - (var(--sw-pad) * 2));
        display: inline-block;
        width: var(--sw-w);
        height: var(--sw-h);
        background: #e5e7eb; /* fallback */
        background: var(--tms-border);
        border: 1px solid var(--tms-border);
        border-radius: 999px;
        box-shadow: inset 0 1px 1px rgba(0,0,0,.06);
        transition: background .18s ease, border-color .18s ease;
        position: relative;
    }

        /* knob */
        .tms-switch > span::before {
            content: "";
            position: absolute;
            top: var(--sw-pad);
            left: var(--sw-pad);
            width: var(--sw-knob);
            height: var(--sw-knob);
            background: #fff;
            border-radius: 999px;
            box-shadow: 0 1px 2px rgba(0,0,0,.15);
            transition: transform .18s ease;
            will-change: transform;
        }

    /* checked state */
    .tms-switch > input:checked + span {
        background: color-mix(in srgb, var(--tms-primary) 18%, #fff);
        border-color: var(--tms-primary);
    }

        .tms-switch > input:checked + span::before {
            transform: translateX(calc(var(--sw-w) - var(--sw-knob) - var(--sw-pad) * 2));
        }

    /* focus ring (keyboard) */
    .tms-switch > input:focus-visible + span {
        outline: none;
        box-shadow: 0 0 0 3px rgba(91, 59, 246, .25); /* matches --focus-ring */
    }

    /* hover (optional subtle) */
    .tms-switch:hover > span {
        border-color: #cfd4dc;
    }

    /* disabled */
    .tms-switch > input:disabled {
        cursor: not-allowed;
    }

        .tms-switch > input:disabled + span {
            background: #f3f4f6;
            border-color: #e5e7eb;
            opacity: .7;
        }

    /* error state helper */
    .tms-switch.is-error > span {
        border-color: var(--tms-danger-border);
        box-shadow: 0 0 0 2px rgba(220,38,38,.06) inset;
    }

    /* size: small */
    .tms-switch.is-sm > span {
        --sw-h: 18px;
        --sw-w: 32px;
    }

    /* size: large */
    .tms-switch.is-lg > span {
        --sw-h: 26px;
        --sw-w: 48px;
    }

/* with label helper (spacing) */
.tms-switch-with-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tms-switch > span, .tms-switch > span::before {
        transition: none;
    }
}


/* =========================================================
   BUTTONS & BADGES
========================================================= */
.btn {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none
}

.btn-primary {
    background: var(--tms-primary);
    color: var(--tms-on-primary)
}

    .btn-primary:hover {
        filter: brightness(.95)
    }

.btn-outline {
    background: #fff;
    border-color: var(--tms-border);
    color: var(--tms-text)
}

    .btn-outline:hover {
        border-color: color-mix(in srgb, var(--tms-primary) 35%, var(--tms-border))
    }


.tms-iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--tms-border);
    border-radius: 8px;
    margin-right: 6px;
    background: #fff;
    color: var(--tms-text);
    text-decoration: none;
    vertical-align: middle;
}

    .tms-iconbtn:last-child {
        margin-right: 0;
    }

    .tms-iconbtn:hover {
        border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    }

.tms-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    display: block;
}

/* Danger (Delete) */
.tms-iconbtn.is-danger {
    color: #dc2626;
    border-color: #fecaca;
    background: #fff5f5;
}

    .tms-iconbtn.is-danger:hover {
        background: #fee2e2;
    }

.tms-iconbtn.is-edit {
    color: #16a34a; /* Green */
    border-color: #bbf7d0; /* Light Green */
    background: #dcfce7; /* Very Light Green */
}

    .tms-iconbtn.is-edit:hover {
        color: #15803d; /* Darker Green on hover */
        border-color: #86efac; /* Slightly darker Green */
        background: #bbf7d0; /* Lighter Green background */
    }

.tms-iconbtn.is-info {
    color: #3b82f6; /* Blue */
    border-color: #bfdbfe; /* Light Blue */
    background: #eff6ff; /* Very Light Blue */
}

    .tms-iconbtn.is-info:hover {
        color: #2563eb; /* Darker Blue on hover */
        border-color: #93c5fd; /* Slightly darker Blue */
        background: #dbeafe; /* Lighter Blue */
    }

.tms-iconbtn.is-person {
    color: #7e22ce; /* Purple */
    border-color: #e9d5ff; /* Light Purple */
    background: #faf5ff; /* Very Light Purple */
}

    .tms-iconbtn.is-person:hover {
        color: #6b21a8; /* Darker Purple on hover */
        border-color: #d8b4fe; /* Slightly darker Purple */
        background: #f3e8ff; /* Light Purple background */
    }
.tms-iconbtn.is-measurement {
    color: #ea580c; /* Orange */
    border-color: #fed7aa; /* Light Orange */
    background: #fff7ed; /* Very Light Orange */
}

    .tms-iconbtn.is-measurement:hover {
        color: #c2410c; /* Darker Orange on hover */
        border-color: #fdba74; /* Slightly darker Orange */
        background: #ffedd5; /* Light Orange background */
    }

/* title row on forms: title left, badges right */
.x-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
}

.x-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--tms-text)
}

.badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}

    .badge .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%
    }

    /* Active / Inactive use shared vars */
    .badge.active {
        background: var(--ok-bg);
        color: var(--ok-text);
        border-color: var(--ok-border);
    }

        .badge.active .dot {
            background: var(--ok-text);
        }

    .badge.inactive {
        background: var(--warn-bg);
        color: var(--warn-text);
        border-color: var(--warn-border);
    }

        .badge.inactive .dot {
            background: var(--warn-text);
        }

    /* Code badge (neutral) */
    .badge.code {
        background: #f6f3ff;
        color: #5b21b6;
        border-color: #ddd6fe;
    }

/* =========================================================
   FORM SYSTEM — Outlined Floating Chip on Border; 4 cols (desktop)
   ERROR MESSAGE OUTSIDE THE BORDER
========================================================= */

/* wrapper for one logical field (box + error message) */
.x-field-wrap {
    display: flex;
    flex-direction: column;
}

/* outlined box */
.x-field {
    position: relative;
    background: var(--tms-field-bg);
    border: 1.5px solid var(--tms-field-border); /* single outline */
    border-radius: 10px;
    /*padding: 20px 12px 8px;*/ /* top for label chip */
    padding: 8px 1px 1px;
    transition: border-color .2s, box-shadow .2s;
}

    .x-field:focus-within {
        border-color: var(--tms-primary);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--tms-primary) 20%, transparent);
    }

/* label chip ON the border center */
.x-label {
    position: absolute;
    top: 0;
    left: 12px;
    transform: translateY(-50%);
    padding: 0 2px;
    height: 20px;
    line-height: 20px;
    background: var(--tms-surface); /* cuts the border behind */
    /*border: 1px solid var(--tms-field-border);*/
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tms-label);
}

.x-req {
    color: var(--tms-danger);
    margin-left: 4px
}

/* controls have NO inner border; avoid double outline */
.x-control {
    width: 100%;
    min-height: 32px;
    padding: 6px 4px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--tms-text);
    font: inherit;
}

textarea.x-control {
    min-height: 96px;
    resize: vertical
}

/* error state on box */
.x-field.is-invalid {
    border-color: var(--tms-danger-border);
    background: var(--tms-danger-bg);
}

    .x-field.is-invalid .x-label {
        border-color: var(--tms-danger-border);
        color: var(--tms-danger-ink);
    }

/* error message BELOW the border (outside box) */
.x-msg {
    margin-top: 4px;
    font-size: 12px;
    color: var(--tms-danger-ink);
}

.field-validation-error {
    display: block;
}
/* MVC emits this class */

/* Validation summary */
.x-summary {
    color: var(--tms-danger-ink);
    background: var(--tms-danger-bg);
    border: 1px solid var(--tms-danger-border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
}

/* Grid: xs1, sm2, md3, lg4 */
.x-grid {
    display: grid;
    gap: var(--x-gap, 12px);
   
    grid-template-columns: 1fr;
}

@media (min-width:576px) {
    .x-grid {
        grid-template-columns: repeat(2,1fr);
    }
}

@media (min-width:768px) {
    .x-grid {
        grid-template-columns: repeat(3,1fr);
    }
}

@media (min-width:1200px) {
    .x-grid {
        grid-template-columns: repeat(4,1fr);
    }
}

/* Measurement-style grid (mobile=4, tablet=6, desktop=8) */
.x-grid-measurement { /* alias, in case older markup has typo */
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* mobile */
    gap: var(--x-gap, 12px);
}

@media (min-width: 768px) {
    .x-grid-measurement {
        grid-template-columns: repeat(6, 1fr); /* tablet */
    }
}

@media (min-width: 1200px) {
    .x-grid-measurement {
        grid-template-columns: repeat(8, 1fr); /* desktop */
    }
}

/* Optional: tighter field cards for dense measurement forms */
.x-grid-measurement .x-field {
    margin: 0; /* rely on grid gap only */
}


.x-span {
    grid-column: 1/-1;
}

/* Actions */
.x-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* Subtle placeholders */
.x-control::placeholder {
    color: color-mix(in srgb, var(--tms-text) 45%, white);
}

/* =========================================================
   TABLES baseline (lists). list.css can enhance further.
========================================================= */
.tms-table {
    width: 100%;
    border-collapse: collapse
}

    .tms-table th, .tms-table td {
        padding: 10px 12px;
        border-bottom: 1px solid var(--tms-border);
        vertical-align: middle
    }

    .tms-table thead th {
        font-weight: 700;
        font-size: 14px;
        color: var(--tms-muted);
        background: color-mix(in srgb, var(--tms-surface) 88%, var(--tms-primary) 12%)
    }

.tms-loading {
    padding: 20px;
    text-align: center;
    color: var(--tms-muted)
}

@media (max-width:767.98px) {
    .tms-table thead {
        display: none
    }

    .tms-table, .tms-table tbody, .tms-table tr, .tms-table td {
        display: block;
        width: 100%
    }

        .tms-table tr {
            background: #fff;
            border: 1px solid var(--tms-border);
            border-radius: 12px;
            margin-bottom: 12px;
            padding: 10px 12px
        }

        .tms-table td {
            border: 0;
            padding: 6px 0
        }

            .tms-table td::before {
                content: attr(data-label);
                display: block;
                font-size: 12px;
                color: var(--tms-muted);
                margin-bottom: 2px
            }
}


/* =========================================================
   UTILITIES
========================================================= */
.m-val {
    font-variant-numeric: tabular-nums
}

.hide-sm {
    display: none
}

/*@media (min-width:768px) {
    .hide-sm {
        display: initial
    }
}*/

.x-dropdown {
    background: #fff;
    border: 1px solid var(--tms-field-border);
    border-radius: 8px;
    margin-top: 4px;
    min-width: 260px;
    max-height: 220px;
    overflow: auto;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
}

.x-dd-item {
    padding: 8px 10px;
    cursor: pointer;
}

    .x-dd-item:hover {
        background: var(--tms-hover);
    }

.flash {
    animation: flashHighlight 1.2s ease-out 1;
}

@keyframes flashHighlight {
    0% {
        background: #fffbe6;
    }

    100% {
        background: transparent;
    }
}

.x-dd-item {
    padding: 8px 10px;
    cursor: pointer;
}

    .x-dd-item:hover, .x-dd-item.is-active {
        background: var(--tms-hover);
    }




/* Inputs-with-clear (you already use this pattern) */
.tms-input--clear {
    position: relative
}

    .tms-input--clear > button {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        display: none
    }

    .tms-input--clear.has-value > button {
        display: block
    }

/* Toast (lightweight) */
/* Base toast */
.tms-toast {
    position: fixed;
    z-index: 10001;
    background: #111827;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0,0,0,.18);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .18s ease, transform .18s ease;
    font-size: 14px;
    line-height: 1.3;
}

    /* Positions (viewport) */
    .tms-toast.pos-br {
        right: 20px;
        bottom: 20px;
    }
    /* bottom-right (old) */
    .tms-toast.pos-tr {
        right: 20px;
        top: 20px;
    }
    /* top-right */
    .tms-toast.pos-bc {
        left: 50%;
        bottom: 20px;
        transform: translate(-50%,6px);
    }

    .tms-toast.pos-tc {
        left: 50%;
        top: 20px;
        transform: translate(-50%,6px);
    }

    /* When shown */
    .tms-toast.show {
        opacity: 1;
        transform: translateY(0);
    }

/* —— Modal-scoped variant (toast inside modal panel) —— */
/*.fs-modal__panel {
    position: relative;
}*/
/* ensure a containing block */
.tms-toast.pos-modal {
    position: absolute; /* relative to modal panel */
    left: 50%;
    bottom: 16px; /* bottom-center inside modal */
    transform: translate(-50%,6px);
}

    .tms-toast.pos-modal.show {
        transform: translate(-50%,0);
    }

.grid-8 {
    grid-column: 8; /* Places input in the 6th column */
}

.grid-7 {
    grid-column: 7; /* Places input in the 6th column */
}

/* =========================================================
   Image Lightbox — Full CSS Rewrite
   Targets: #imgLightbox, .x-modal__overlay, .x-modal__content--image,
            #imgLightboxImg, .x-close
   ========================================================= */

/* Root container (mounted once in <body>) */
/* ===================== LIGHTBOX (namespaced) ===================== */

/* Root */
#imgLightbox {
    position: fixed;
    inset: 0;
    z-index: 9999; /* above any .x-modal (5000) */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility 0s linear .18s;
}

    #imgLightbox[aria-hidden="false"] {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition: opacity .18s ease;
    }

    /* Backdrop */
    #imgLightbox .lb-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,.76);
        -webkit-tap-highlight-color: transparent;
    }

    /* Content wrapper: full viewport canvas, centers image */
    #imgLightbox .lb-content {
        position: absolute;
        inset: 0;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #000;
        box-shadow: none;
        border-radius: 0;
        user-select: none;
        overscroll-behavior: contain;
    }

/* Image fully contained (no crop) */
#imgLightboxImg {
    display: block;
    width: auto;
    height: auto;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
    background: #000;
    opacity: 0;
    transition: opacity .16s ease;
}

#imgLightbox[aria-hidden="false"] #imgLightboxImg[src] {
    opacity: 1;
}

/* Close */
#imgLightbox .lb-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: rgba(0,0,0,.55);
    color: #fff;
    font: 700 22px/36px ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    cursor: pointer;
    transition: background .12s ease, transform .06s ease;
}

    #imgLightbox .lb-close:hover {
        background: rgba(0,0,0,.72);
    }

    #imgLightbox .lb-close:active {
        transform: scale(.96);
    }

    #imgLightbox .lb-close:focus {
        outline: 2px solid #fff;
        outline-offset: 2px;
    }

/* Small screens */
@media (max-width: 420px) {
    #imgLightbox .lb-close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 20px;
        line-height: 32px;
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    #imgLightbox, #imgLightboxImg, #imgLightbox .lb-close {
        transition: none !important;
    }
}



/* Micro modal sizing */
/* Base modal */
.x-modal {
    position: fixed;
    inset: 0;
    z-index: 5000; /* keep under lightbox (9999) */
}

    /* Hidden state (default) */
    .x-modal[aria-hidden="true"] {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .18s ease, visibility 0s linear .18s;
    }

    /* Visible state (JS toggles this) */
    .x-modal[aria-hidden="false"] {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition: opacity .18s ease;
    }

    /* Overlay + content */
    .x-modal .x-modal__overlay {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,.5);
    }

    .x-modal .x-modal__content {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
        background: #fff;
        border-radius: 10px;
        box-shadow: 0 14px 40px rgba(0,0,0,.18);
    }

/* Micro size */
.x-modal--micro .x-modal__content--sm {
    width: 380px;
    max-width: 92vw;
}

/* Header/body/footer layout */
.x-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--tms-hairline,#eee);
}

.x-modal__body {
    padding: 12px 14px;
}

.x-modal__footer {
    padding: 10px 14px;
    border-top: 1px solid var(--tms-hairline,#eee);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}







/* =========================================================
   FORM FIELD ENHANCEMENTS (Add to existing Site.css)
========================================================= */

/* Enhanced form field focus states */
.x-control:focus {
    border-color: var(--tms-field-border, #c7b6ff);
    box-shadow: 0 0 0 3px rgba(91, 59, 246, 0.1);
    outline: none;
    transform: translateY(-1px);
    transition: all 0.15s ease;
}

/* Input group focus-within */
.x-field:focus-within .x-label {
    color: var(--tms-primary, #5b3bf6);
    font-weight: 600;
}

/* Error state enhancement */
.x-field.has-error .x-control {
    border-color: #dc2626;
    background: #fef2f2;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

.x-msg.field-validation-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: fadeIn 0.3s ease;
}

  

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth transitions for all inputs */
.x-control,
.tms-input,
.tms-select {
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

    /* Better placeholder styling */
    .x-control::placeholder,
    .tms-input::placeholder {
        color: var(--tms-muted, #6b7280);
        opacity: 0.6;
        font-style: italic;
    }

    .x-control:focus::placeholder,
    .tms-input:focus::placeholder {
        opacity: 0.4;
    }

/* Success state (optional) */
.x-field.has-success .x-control {
    border-color: #10b981;
    background: #f0fdf4;
}

.x-field.has-success .x-label {
    color: #059669;
}

/* Disabled state improvement */
.x-control:disabled,
.tms-input:disabled,
.tms-select:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Required field indicator */
.x-req {
    color: #dc2626;
    font-weight: 700;
    margin-left: 2px;
}

/* Helper text */
.x-helper {
    font-size: 12px;
    color: var(--tms-muted, #6b7280);
    margin-top: 4px;
    font-style: italic;
}

/* Input groups */
.input-group {
    display: flex;
    gap: 0;
}

    .input-group .x-control:first-child {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .input-group .x-control:last-child {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        border-left: 0;
    }

    .input-group .input-group-text {
        display: flex;
        align-items: center;
        padding: 8px 12px;
        background: #f9fafb;
        border: 1px solid var(--tms-border, #e5e7eb);
        font-size: 14px;
        font-weight: 500;
        color: var(--tms-muted, #6b7280);
    }

        .input-group .input-group-text:first-child {
            border-right: 0;
            border-radius: 8px 0 0 8px;
        }

        .input-group .input-group-text:last-child {
            border-left: 0;
            border-radius: 0 8px 8px 0;
        }







