/* Styles added for the field pilot, on top of the proof of concept's app.css. */

/* Hidden until Blazor shows it after an unhandled error. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    padding: 0.6rem 1.25rem 0.7rem;
    background: lightyellow;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

    #blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* "A new version of GenoTrac is ready": shown by js/update.js. */
#gt-update {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: max-content;
    max-width: calc(100vw - 2rem);
    padding: 0.6rem 0.6rem 0.6rem 1rem;
    background: #fff;
    border: 1px solid #b9c7dd;
    border-left: 4px solid #5a86c5;
    border-radius: 0.4rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    font-size: 0.95rem;
}

    #gt-update[hidden], #gt-update [hidden] { display: none; }
    #gt-update .gt-update-reload { white-space: nowrap; }
    #gt-update .gt-update-dismiss { border: none; background: none; font-size: 1.3rem; line-height: 1; color: #6b7280; padding: 0 0.3rem; }

.gt-loading {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #fff;
    font-size: 1.1rem;
}

    .gt-loading img { background: #fff; }

.gt-pilot-tag {
    padding: 0.1rem 0.5rem;
    border: 1px dashed rgba(255, 255, 255, 0.85);
    font-size: 0.8rem;
    vertical-align: middle;
}

.gt-login-box .gt-pilot-tag { border-color: #999; color: #555; }

/* A test site's label (the server setting Site:Label), so nobody mistakes it for the real GenoTrac. */
.gt-site-tag {
    padding: 0.1rem 0.6rem;
    background: #e8590c;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: middle;
    border-radius: 2px;
}

.gt-site-strip {
    padding: 0.25rem 1rem;
    background: repeating-linear-gradient(-45deg, #e8590c, #e8590c 14px, #d9480f 14px, #d9480f 28px);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

/* ---- Connection and sync status in the top bar ---- */

.gt-status {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.8rem;
    border-radius: 1.2rem;
    background: rgba(255, 255, 255, 0.92);
    color: #222;
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

    .gt-status .dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: #2e9d48; flex-shrink: 0; }
    .gt-status.busy .dot { background: #f0a020; }
    .gt-status.attention .dot { background: #d9480f; }
    .gt-status.offline { background: #3a3f47; color: #fff; }
    .gt-status.offline .dot { background: #b0b6bf; }

/* ---- Right end of the top bar: the sync status (field section) and the account menu ---- */

.gt-topbar-end {
    margin-left: auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

    .gt-topbar-end .gt-status { margin-left: 0; max-width: none; min-width: 0; }

.gt-account { position: relative; flex-shrink: 0; }

.gt-account-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem 0.35rem 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 1.2rem;
    background: transparent;
    color: #fff;
    font-size: 0.9rem;
    white-space: nowrap;
}

    .gt-account-button:hover,
    .gt-account-button[aria-expanded=true] { background: rgba(255, 255, 255, 0.15); }

    .gt-account-button svg { width: 1.25rem; height: 1.25rem; fill: currentColor; flex-shrink: 0; }
    .gt-account-button .gt-account-caret { width: 1rem; height: 1rem; }

.gt-account-backdrop { position: fixed; inset: 0; z-index: 1040; }

.gt-account-panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 1050;
    min-width: 15rem;
    padding: 0.8rem 1rem;
    border: 1px solid #b9c7dd;
    border-radius: 4px;
    background: #fff;
    color: #222;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

    .gt-account-panel[hidden] { display: none; }
    .gt-account-who { margin-bottom: 0.5rem; word-break: break-word; }
    .gt-account-version { margin-bottom: 0.75rem; padding-top: 0.5rem; border-top: 1px solid #e3e8f0; }

.gt-banner {
    margin: 0.5rem 0.4rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid #b9c7dd;
    background: #eef3fb;
    font-size: 0.9rem;
}

    .gt-banner.warn { background: #fff4d6; border-color: #e6c35c; }
    .gt-banner.attention { background: #fde9e1; border-color: #e7a487; }

/* ---- Sign-in ---- */

.gt-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

    .gt-login-page .gt-login-box {
        background: #fff;
        padding: 1.5rem;
        width: 24rem;
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    }

    .gt-login-page h1 { font-size: 1.5rem; margin: 1rem 0; }

/* ---- Home ---- */

.gt-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.gt-tile {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.1rem 1.2rem;
    border: 1px solid var(--gt-line);
    background: #fff;
    color: #222;
    text-decoration: none;
    min-height: 7.5rem;
}

    .gt-tile strong { font-size: 1.15rem; color: #1b5aa8; }
    .gt-tile:hover { border-color: #1b6ec2; box-shadow: 0 2px 8px rgba(27, 110, 194, 0.15); }

/* ---- Field trial list ---- */

.gt-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: center;
}

    .gt-filters input[type=search] { flex: 1 1 18rem; }
    .gt-filters select { flex: 0 1 11rem; }

.gt-trial-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--gt-line);
}

    .gt-trial-list a {
        display: grid;
        grid-template-columns: 7.5rem minmax(0, 1fr) auto;
        grid-template-areas: "num plant flag" "num meta flag";
        gap: 0.1rem 0.9rem;
        align-items: center;
        padding: 0.65rem 0.6rem;
        border-bottom: 1px solid #e3e7ec;
        color: #222;
        text-decoration: none;
        min-height: 3.4rem;
    }

    .gt-trial-list a:hover, .gt-trial-list a:active { background: #f1f6fd; }
    .gt-trial-list .num { grid-area: num; font-weight: 600; font-variant-numeric: tabular-nums; color: #1b5aa8; }
    .gt-trial-list .plant { grid-area: plant; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .gt-trial-list .meta { grid-area: meta; font-size: 0.8rem; color: var(--gt-label); }
    .gt-trial-list .flag { grid-area: flag; font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 0.8rem; white-space: nowrap; }
    .gt-trial-list .flag.pending { background: #fff1cc; color: #7a5600; }
    .gt-trial-list .flag.attention { background: #fde0d4; color: #a3330b; }
    .gt-trial-list .flag.done { background: #e3f1e5; color: #276b37; }

.gt-scope td, .gt-scope th { padding: 0.45rem 0.8rem; vertical-align: middle; }
.gt-scope .gt-picked { background: #e3eefc; font-weight: 600; }

/* ---- Trial form ---- */

/* Bigger controls for fingers on a tablet. */
.gt-touch .form-control,
.gt-touch .form-select {
    min-height: 2.6rem;
    font-size: 1rem;
}

.gt-touch .gt-field {
    grid-template-columns: 8.5rem minmax(0, 1fr);
    margin-bottom: 0.4rem;
}

fieldset { min-width: 0; }
fieldset[disabled] .gt-calc { opacity: 1; }

.gt-range { display: flex; align-items: center; gap: 0.35rem; }
    .gt-range > input, .gt-range > select { flex: 1 1 0; min-width: 0; }
    .gt-range > span { color: var(--gt-label); font-size: 0.85rem; }

.gt-pct { max-width: 5rem; }

.gt-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

    .gt-chips .gt-chip {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        height: 2.4rem;
        padding: 0 0.8rem;
        font-size: 0.9rem;
    }

    .gt-chips .gt-chip.on { background: #1b6ec2; border-color: #1b6ec2; color: #fff; }
    .gt-chips .swatch { width: 0.95rem; height: 0.95rem; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.25); }

.gt-box > header.gt-box-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
}

.gt-box-head .title { font-weight: 600; color: #444; }
.gt-box-head .note { font-weight: 400; color: var(--gt-label); }

.planting-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 0.75rem;
    align-items: start;
}

.planting-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
    border: 0;
    margin: 0;
}

    .planting-fields .gt-field { grid-template-columns: 7.5rem minmax(0, 1fr); }

.years-table td, .years-table th { padding: 0.35rem 0.5rem; white-space: nowrap; }
.years-table tr.current td { background: #fff9c4; font-weight: 600; }
.hint { color: var(--gt-label); font-size: 0.78rem; }

.btn-continue {
    background: #e7f0e1;
    border: 1px solid #6f9a55;
    color: #2d5016;
    font-weight: 600;
}

/* The save bar stays at the bottom of the screen, within reach on a tablet. */
.gt-savebar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0.4rem;
    padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 2px solid #1b6ec2;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

    .gt-savebar .state { flex: 1; font-size: 0.9rem; }
    .gt-savebar .state ul { padding-left: 1.1rem; }
    .gt-savebar .btn-lg { min-width: 7rem; }

/* ---- Plant page ---- */

.gt-plant-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr 0.8fr;
    gap: 0.75rem;
    align-items: start;
}

.gt-tabs.pilot { display: flex; gap: 0; padding: 0.4rem 0.4rem 0; }
    .gt-tabs.pilot span { padding: 0.25rem 0.7rem; background: #fff; border: 1px solid var(--gt-line); border-bottom: none; margin-right: -1px; }
    .gt-tabs.pilot span.active { background: #eef2f8; font-weight: 600; }
    .gt-tabs.pilot span.disabled { color: #a0a6ae; background: #f6f7f9; }

/* ---- Device page ---- */

.gt-facts { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 0.35rem 0.75rem; margin: 0; }
    .gt-facts dt { font-weight: 400; color: var(--gt-label); text-align: right; }
    .gt-facts dd { margin: 0; }

.gt-conflicts td { vertical-align: middle; }

/* ---- Narrower screens ---- */

@media (max-width: 1400px) {
    .planting-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1100px) {
    .gt-plant-grid { grid-template-columns: minmax(0, 1fr); }
    .gt-topbar-end { max-width: 60%; }
}

@media (max-width: 760px) {
    .planting-fields { grid-template-columns: minmax(0, 1fr); }
    .gt-trial-list a { grid-template-columns: 6.5rem minmax(0, 1fr); grid-template-areas: "num plant" "num meta" "flag flag"; }
    .gt-topbar-end { max-width: none; }
    .gt-account-name { display: none; }
    .gt-topbar { flex-wrap: wrap; }
}
