/* ?? AxisMonitor Web Portal ?????????????????????????????????????
   Design tokens aligned with the WPF Instance Manager theme.
   Colors from AGIControls.WPF Brushes.xaml + InstanceManager App.xaml.
   ?????????????????????????????????????????????????????????????? */

:root {
    /* Accent — periwinkle indigo, same as the AxisMonitor web UI */
    /* Accent — Axis Geosystems brand teal (exact from the BUS Cards sheet) */
    --primary: #1F7E72;
    --primary-dark: #186154;
    --primary-light: #E7F1EF;        /* tinted active/hover surface (nav, pills) */
    --primary-on-soft: #14584C;      /* text/icon sitting on the soft surface */

    /* Brand companions (mark ink + slate secondary from the same sheet) */
    --brand-ink: #0E2329;
    --brand-slate: #4A5D5F;

    /* Status */
    --success: #15803d;
    --success-soft: #e7f3ea;
    --warning: #b45309;
    --warning-soft: #fdf3e4;
    --danger: #b4342a;
    --danger-dark: #93291f;
    --danger-soft: #fbeae7;

    /* Neutrals — light, clean, near-neutral (a whisper cool) */
    --bg: #f5f6f8;                   /* page canvas */
    --bg-subtle: #f1f3f6;            /* zebra / hover rows, table headers, insets */
    --card-bg: #ffffff;
    --text-primary: #1a1d24;
    --text-secondary: #616774;
    --text-disabled: #97a0ac;
    --border: #d6dae1;               /* strong border (inputs, buttons) */
    --border-light: #e6e8ec;         /* hairline borders */

    /* Sidebar — light shell like AxisMonitor (tokens kept for back-compat) */
    --sidebar-top: #ffffff;
    --sidebar-mid: #ffffff;
    --sidebar-bottom: #ffffff;

    /* Shape + depth */
    --radius: 10px;
    --radius-sm: 7px;
    --shadow-sm: 0 1px 2px rgba(19, 24, 33, 0.06);
    --shadow-md: 0 6px 20px -6px rgba(19, 24, 33, 0.14);

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    font-family: var(--font-family);
    color: var(--text-primary);
    background: var(--bg);
    margin: 0;
    padding: 0;
}

/* ?? Buttons ???????????????????????????????????????????????????? */

.btn-primary-am {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary-am:hover { background: var(--primary-dark); }
.btn-primary-am:disabled { opacity: 0.5; cursor: default; }

.btn-secondary-am {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.btn-secondary-am:hover { background: var(--bg-subtle); }
.btn-secondary-am:disabled { opacity: 0.5; cursor: default; }

.btn-danger-am {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: var(--danger);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.btn-danger-am:hover { background: var(--danger-dark); }
.btn-danger-am:disabled { opacity: 0.5; cursor: default; }

.btn-link-am {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
    text-decoration: none;
    white-space: nowrap;
}
.btn-link-am:hover { text-decoration: underline; }

/* ?? Cards ?????????????????????????????????????????????????????? */

.card-am {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    margin: 8px;
    box-shadow: var(--shadow-sm);
}

/* ?? Form controls ?????????????????????????????????????????????? */

.form-group-am {
    margin-bottom: 16px;
}

.form-group-am label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-control-am {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.form-control-am:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(31, 126, 114, 0.18);
}
.form-control-am::placeholder {
    color: var(--text-disabled);
}

/* ?? Status badges ?????????????????????????????????????????????? */

.badge-am {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}
.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-running { background: var(--success-soft); color: var(--success); }
.badge-stopped { background: var(--bg-subtle); color: var(--text-secondary); }
.badge-error   { background: var(--danger-soft); color: var(--danger); }
.badge-info    { background: var(--primary-light); color: var(--primary-on-soft); }

/* ?? Page header ???????????????????????????????????????????????? */

.page-header-am {
    background: #fff;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.page-header-am h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* ?? Toolbar ???????????????????????????????????????????????????? */

.toolbar-am {
    background: #fff;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ?? Table ?????????????????????????????????????????????????????? */

.table-am {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table-am th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border-light);
    background: var(--bg-subtle);
}
.table-am td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.table-am tr:hover td {
    background: var(--bg-subtle);
}

/* Responsive table wrapper � horizontal scroll on mobile */
.table-responsive-am {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ?? Alert ?????????????????????????????????????????????????????? */

.alert-am {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-danger-am { background: var(--danger-soft); color: var(--danger); border: 1px solid #f0cdc7; }
.alert-success-am { background: var(--success-soft); color: var(--success); border: 1px solid #c4e3cd; }
.alert-info-am { background: var(--primary-light); color: var(--primary-on-soft); border: 1px solid #CCE2DD; }
.alert-warning-am { background: var(--warning-soft); color: var(--warning); border: 1px solid #f3ddb8; }

/* ?? Validation ????????????????????????????????????????????????? */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}
.invalid {
    outline: 1px solid var(--danger);
}
.validation-message {
    color: var(--danger);
    font-size: 12px;
}

/* ?? Blazor error UI ???????????????????????????????????????????? */

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after {
    content: "An error has occurred.";
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ?? Login page ????????????????????????????????????????????????? */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1000px 500px at 15% -10%, rgba(31, 126, 114, 0.14), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(31, 126, 114, 0.10), transparent 60%),
        var(--bg);
}
.login-card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-md);
}
.login-card h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text-primary);
}
.login-card .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ?? Login (split brand layout) ????????????????????????????????? */
/* Brand identity from the Axis Geosystems business card: faceted teal
   diamond, AXIS (bold) + GEOSYSTEMS (light, letter-spaced), monospace
   tagline. The old .login-page/.login-card classes remain for /register. */

.login-split {
    min-height: 100vh;
    display: flex;
    background: var(--bg);
}

.login-split *,
.login-split *::before,
.login-split *::after {
    box-sizing: border-box;
}

/* — Brand panel — */

.login-brand {
    position: relative;
    flex: 0 0 44%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    overflow: hidden;
    /* Brand ink #0E2329 with a teal #1F7E72 glow — exact BUS Cards palette */
    background:
        radial-gradient(900px 600px at 85% -10%, rgba(31, 126, 114, 0.28), transparent 55%),
        linear-gradient(160deg, #13303A 0%, #0E2329 55%, #0A1B20 100%);
}

.login-contours {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.login-contours path {
    fill: none;
    stroke: #FFFFFF;
    stroke-opacity: 0.05;
    stroke-width: 1.4;
}

.login-contours path:nth-child(2n) {
    stroke: #1F7E72;
    stroke-opacity: 0.18;
}

.login-watermark {
    position: absolute;
    top: -140px;
    right: -140px;
    width: 420px;
    height: 420px;
}

.login-watermark polygon {
    fill: #FFFFFF;
    fill-opacity: 0.045;
}

.login-brand-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
}

.login-mark {
    width: 84px;
    height: 84px;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35));
}

.login-wordmark {
    display: flex;
    align-items: baseline;
    gap: 10px;
    white-space: nowrap;
}

.login-wordmark-axis {
    font-size: 27px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #FFFFFF;
}

.login-wordmark-geo {
    font-size: 27px;
    font-weight: 300;
    letter-spacing: 0.14em;
    color: #CDD4D2;
}

.login-tagline {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 11.5px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: rgba(205, 212, 210, 0.55);
}

.login-brand-foot {
    position: absolute;
    bottom: 26px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 10.5px;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.28);
}

/* — Form panel — */

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.login-form-box {
    width: 380px;
    max-width: 100%;
}

.login-form-title {
    font-size: 24px;
    font-weight: 650;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.login-form-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 26px;
}

/* Everything in the column is the same border-box width — inputs, submit,
   Google button all line up exactly */
.login-form-box .form-control-am,
.login-form-box .login-submit,
.login-form-box .login-google-btn {
    width: 100%;
}

.login-submit {
    margin-top: 8px;
    padding: 11px 16px;
    font-size: 14px;
    justify-content: center;
    background: #1F7E72;
    border: none;
}

.login-submit:hover:not(:disabled) {
    background: #186154;
}

.login-google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    text-decoration: none;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}

.login-divider hr {
    flex: 1;
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 0;
}

.login-divider span {
    color: var(--text-disabled);
    font-size: 12px;
    white-space: nowrap;
}

.login-register-row {
    text-align: center;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
}

.login-register-row a {
    color: #1F7E72;
    font-weight: 600;
    margin-left: 4px;
    text-decoration: none;
}

.login-register-row a:hover {
    text-decoration: underline;
}

/* — Mobile: brand panel becomes a compact header band — */

@media (max-width: 820px) {
    .login-split {
        flex-direction: column;
    }

    .login-brand {
        flex: none;
        max-width: none;
        padding: 34px 24px 30px;
    }

    .login-mark {
        width: 56px;
        height: 56px;
    }

    .login-wordmark-axis,
    .login-wordmark-geo {
        font-size: 21px;
    }

    .login-tagline {
        font-size: 10px;
        letter-spacing: 0.24em;
    }

    .login-brand-content {
        gap: 12px;
    }

    .login-brand-foot {
        display: none;
    }

    .login-watermark {
        top: -180px;
        right: -120px;
    }

    .login-form-side {
        align-items: flex-start;
        padding: 32px 20px 40px;
    }
}

/* ?? Empty state ???????????????????????????????????????????????? */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}
.empty-state i {
    font-size: 40px;
    color: var(--text-disabled);
    margin-bottom: 12px;
}
.empty-state p {
    font-size: 14px;
    margin: 8px 0;
}

/* ?? Mobile responsive global ??????????????????????????????????? */

@media (max-width: 768px) {
    .page-header-am {
        padding: 12px 16px;
    }

    .page-header-am h1 {
        font-size: 17px;
    }

    .card-am {
        margin: 4px;
        padding: 12px;
    }
}

/* ?? Mobile stacked tables ?????????????????????????????????????? */
/* Opt-in via .table-stack-mobile on a .table-am: below the breakpoint the
   header disappears and each row renders as a card. Cells show right-aligned
   values with an optional label from data-label; cells whose content is
   self-evident (names, titles) can omit it. Empty cells collapse away.
   Mark the row's lead cell with .stack-primary and an action cell with
   .stack-actions for card-like emphasis/placement. */

@media (max-width: 700px) {
    /* Once a table is stacked there is nothing to scroll — the wrapper's
       overflow would otherwise clip card content */
    .table-responsive-am:has(> .table-stack-mobile) {
        overflow-x: visible;
    }

    /* IMPORTANT: no `width: 100%` anywhere in here. The portal has no global
       box-sizing reset, so 100% + padding/border renders WIDER than the
       container (content-box) and clips. Blocks auto-fill their parent. */

    table.table-stack-mobile thead {
        display: none;
    }

    table.table-stack-mobile,
    table.table-stack-mobile tbody,
    table.table-stack-mobile tfoot,
    table.table-stack-mobile tr,
    table.table-stack-mobile td {
        display: block;
        box-sizing: border-box;
        min-width: 0;
    }

    /* Each row is a self-contained card */
    table.table-stack-mobile tr {
        border: 1px solid var(--border-light);
        border-radius: 10px;
        margin-bottom: 10px;
        background: #fff;
        padding: 10px 14px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }

    table.table-stack-mobile tr:hover td {
        background: transparent;
    }

    /* Field line: fixed label column left, value left-aligned and wrapping */
    table.table-stack-mobile td {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        border-bottom: none;
        padding: 3px 0;
        text-align: left;
        /* Defeat inline nowrap/ellipsis/max-width styles and break long
           tokens (image tags, emails, port lists) instead of overflowing */
        white-space: normal !important;
        overflow-wrap: anywhere;
        max-width: none !important;
    }

    table.table-stack-mobile td > * {
        min-width: 0;
    }

    table.table-stack-mobile td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 92px;
        padding-top: 2px;
        font-size: 10px;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-family: 'Segoe UI', system-ui, sans-serif;
        /* cells with inline text-align (center/right) must not move the label */
        text-align: left;
    }

    table.table-stack-mobile td:empty {
        display: none;
    }

    /* Lead cell = card header */
    table.table-stack-mobile td.stack-primary {
        display: block;
        font-weight: 600;
        font-size: 14.5px;
        padding: 0 0 7px;
        margin-bottom: 7px;
        border-bottom: 1px solid var(--border-light);
    }

    /* Action buttons = divided footer row */
    table.table-stack-mobile td.stack-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
        border-top: 1px solid var(--border-light);
        margin-top: 8px;
        padding-top: 9px;
    }

    /* Cells that carry no information worth a card row (e.g. a lone status
       dot duplicated by a status badge) */
    table.table-stack-mobile td.stack-hide-mobile {
        display: none;
    }
}