/*
  Remain PWA — shared UI styling
  Goal: match the OutSystems field app look and be mobile-friendly.
  These classes centralise the button/header/card styling so individual
  components don't need bespoke inline styles.

  Palette tokens:
    --remain-navy  #1d2c63   primary actions / outline
    --remain-red   #d82323   destructive actions
*/

:root {
    --remain-navy: #1d2c63;
    --remain-navy-dark: #16234f;
    --remain-red: #d82323;
    --remain-red-dark: #b71c1c;
}

/*
  Full-width fluid content (OutSystems stretches edge to edge on desktop too).
  Just provides comfortable side padding; no narrow max-width cap.
*/
.remain-app {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1rem 2rem;
    box-sizing: border-box;
    /* Guard against accidental sideways scroll on tablets (iPad portrait/landscape
    and split-screen multitasking). Vertical scrolling is still allowed. */
    overflow-x: hidden;
}

/* Flat top bar (OutSystems uses a plain full-width header, not a floating card). */
.remain-header.rz-card {
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid #e6e6e6;
    margin: 0 0 1rem;
    padding: 0.6rem 1rem;
}

/*
  Trip dashboard header (OutSystems-style). On phones it stacks vertically and
  centres; from tablet width up (iPad A16 portrait ≈820px and landscape) it
  becomes a single compact horizontal row: logo | sync | project | material
  pill | stats | theme | flag. Built with flexbox so the layout is independent
  of Radzen's grid breakpoints.
*/
.remain-trip-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
}

.remain-trip-header__logo img {
    height: 56px;
    width: auto;
    display: block;
}

.remain-trip-header__project {
    text-align: center;
    line-height: 1.3;
    min-width: 0;
}

.remain-trip-header__project-name {
    font-weight: 700;
}

.remain-trip-header__project-equipment {
    font-size: 0.875rem;
}

/* Navy pill for the selected material (OutSystems "Soil - Cobbles" button). */
.rz-button.remain-trip-header__material {
    border-radius: 20px !important;
    background-color: var(--remain-navy) !important;
    border-color: var(--remain-navy) !important;
    color: #fff !important;
    font-weight: 700;
    white-space: normal;
    flex: 0 0 auto;
}

/* Compact 2-column label/value stats list. */
.remain-trip-header__stats {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 1rem;
    row-gap: 0.1rem;
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: nowrap;
}

.remain-trip-header__stats dt {
    margin: 0;
    font-weight: 400;
}

.remain-trip-header__stats dd {
    margin: 0;
    font-weight: 700;
}

.remain-trip-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .remain-trip-header {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .remain-trip-header__project {
        text-align: start;
        flex: 0 1 auto;
        max-width: 12rem;
    }

    .remain-trip-header__stats {
        justify-content: end;
    }
}

/* Cards: flatter, full-width, less margin than the Radzen default. */
.remain-card.rz-card {
    width: 100%;
    margin: 0 auto 1rem;
    border-radius: 10px;
}

/*
  Trip dashboard action tiles (Next Phase / End Trip / Refuel / Delay).
  Height scales with the viewport height so the big touch tiles fill the tall
  iPad portrait canvas without overflowing the shorter landscape view.
*/
.rz-button.remain-action-tile {
    min-height: clamp(200px, 28vh, 340px);
}

/* Generous, viewport-relative vertical rhythm between dashboard sections. */
.remain-dashboard-row {
    margin-top: clamp(1.5rem, 5vh, 3.5rem);
}

/*
  NOTE: the Radzen theme stylesheet is injected into the markup (a <link> inside
  MainLayout), so it loads AFTER this file. At equal specificity Radzen's
  .rz-primary / .rz-danger colours would win, so the colour overrides below use
  !important to beat the theme regardless of load order.
*/

/* Primary action — full-width dark-navy button (OutSystems "Next"). */
.rz-button.remain-btn-primary {
    width: 100%;
    background-color: var(--remain-navy) !important;
    border-color: var(--remain-navy) !important;
    color: #fff !important;
    border-radius: 6px !important;
    padding: 0.85rem 1rem;
    font-weight: 600;
}

.rz-button.remain-btn-primary:hover:not(:disabled) {
    background-color: var(--remain-navy-dark) !important;
    border-color: var(--remain-navy-dark) !important;
}

/*
  Destructive action — compact red rectangle ("Delete all trip data").
  Add remain-btn-full to make it span the row (used by dialog Save buttons).
*/
.rz-button.remain-btn-danger {
    background-color: var(--remain-red) !important;
    border-color: var(--remain-red) !important;
    color: #fff !important;
    border-radius: 6px !important;
    font-weight: 600;
    padding: 0.4rem 1rem;
}

.rz-button.remain-btn-danger:hover:not(:disabled) {
    background-color: var(--remain-red-dark) !important;
    border-color: var(--remain-red-dark) !important;
}

/*
  Outline / secondary choice — transparent with navy border + text
  (OutSystems "End shift" / "New material" / dialog "Cancel").
*/
.rz-button.remain-btn-outline {
    background: transparent !important;
    border: 1px solid var(--remain-navy) !important;
    color: var(--remain-navy) !important;
    border-radius: 6px !important;
    font-weight: 600;
}

.rz-button.remain-btn-outline:hover:not(:disabled) {
    background: rgba(29, 44, 99, 0.08) !important;
}

/* Span the full width of the parent row (combine with primary/danger/outline). */
.rz-button.remain-btn-full {
    width: 100%;
}

/* Plain icon button (theme toggle / refresh) — no filled background. */
.rz-button.remain-btn-icon {
    background: transparent !important;
    box-shadow: none !important;
    color: var(--remain-navy) !important;
    padding: 0.25rem;
    /* Keep a minimum 44px tap target for touch devices (iPad). */
    min-width: 44px;
    min-height: 44px;
}

.rz-button.remain-btn-icon:hover:not(:disabled) {
    background: rgba(29, 44, 99, 0.08) !important;
}

/* Full-width form controls on mobile. */
.remain-app .rz-dropdown,
.remain-app .rz-textbox {
    width: 100%;
}

/*
  In-app loading overlay — full-screen dim with the spinner dead-centre.
  Defined here (a stylesheet that's reliably loaded) with !important so the
  centring can't be lost to load-order or a stale bundle.
*/
.loader-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(255, 255, 255, 0.7) !important;
}

/*
  Centre dropdown text — both the selected value and the list options.
  The options panel renders at the document root (outside .remain-app), so
  these selectors are global. !important beats the later-loaded Radzen theme.
*/
.rz-dropdown .rz-dropdown-label,
.rz-dropdown-panel .rz-dropdown-item,
.rz-dropdown-panel .rz-dropdown-item .rz-dropdown-item-text {
    text-align: center !important;
    justify-content: center !important;
}

/* PIN keypad keys — square navy, large touch targets. */
.rz-button.remain-key {
    width: 64px;
    height: 64px;
    margin: 6px;
    background-color: var(--remain-navy) !important;
    border-color: var(--remain-navy) !important;
    color: #fff !important;
    border-radius: 8px !important;
    font-size: 1.25rem;
    font-weight: 600;
}

.rz-button.remain-key:hover:not(:disabled) {
    background-color: var(--remain-navy-dark) !important;
    border-color: var(--remain-navy-dark) !important;
}

/*
  Select-material carousel — a row of bordered, navy-text cards (matches the
  OutSystems "Select material" picker). Cards keep a fixed size and are
  left-aligned so the carousel arrows page through them.
*/
.material-page {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    justify-content: center;
    align-items: stretch;
    padding: 8px 56px;
    width: 100%;
    box-sizing: border-box;
}

.material-card {
    flex: 1 1 0;
    min-width: 0;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 1rem;
    border: 1px solid var(--remain-navy);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.material-card.selected {
    background: var(--remain-navy);
}

.material-card.selected .material-card-text {
    color: #fff;
}

.material-card-text {
    text-align: center;
    color: var(--remain-navy);
    font-weight: 600;
    font-size: 1.25rem;
    overflow-wrap: anywhere;
}

.material-card-code {
    font-size: 1.6rem;
    font-weight: 600;
}

.material-card-name {
    margin-top: 0.35rem;
    font-size: 1.15rem;
    font-weight: 600;
}

/* Phones / narrow screens: tighter spacing, smaller text, shorter cards. */
@media (max-width: 600px) {
    .material-page {
        gap: 8px;
        padding: 6px 44px;
    }

    .material-card {
        min-height: 140px;
        padding: 0.5rem;
    }

    .material-card-text {
        font-size: 1rem;
    }

    .material-card-code {
        font-size: 1.25rem;
    }

    .material-card-name {
        font-size: 0.95rem;
    }
}

/* Centre the "Select material" dialog title. */
.material-dialog .rz-dialog-title {
    width: 100%;
    text-align: center;
}

/*
  Bigger, touch-friendly dialog close (X) button on every Radzen dialog.
  The titlebar button is global (rendered outside .remain-app), so this applies
  app-wide. !important beats the later-loaded Radzen theme sizing.
*/
.rz-dialog-titlebar .rz-dialog-titlebar-close {
    width: 3rem !important;
    height: 3rem !important;
    justify-content: center;
    border-radius: 8px !important;
}

.rz-dialog-titlebar .rz-dialog-titlebar-close .rzi,
.rz-dialog-titlebar .rz-dialog-titlebar-close .notranslate {
    font-size: 2rem !important;
}

.rz-dialog-titlebar .rz-dialog-titlebar-close:hover {
    background: rgba(29, 44, 99, 0.08) !important;
}

/*
  Trip phase tiles (Driving Empty / Loading / Driving Full / Unloading).
  All tiles are white cards; the active phase is marked with a navy border and
  navy text. The empty-truck icon ships as a white PNG, so it's tinted grey to
  stay visible on the white tile and match the other (grey) phase icons.
*/
.phase-tile {
    background: #fff;
    border: 1px solid #d9dce5;
    border-radius: 8px;
    padding: 20px;
    color: #8a90a2;
    /* Centre the icon + label and give the tiles a comfortable, viewport-relative
    height so the status row balances with the taller action tiles above. */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: clamp(140px, 16vh, 200px);
    box-sizing: border-box;
}

.phase-tile.active {
    background: var(--remain-navy);
    border: 1px solid var(--remain-navy);
    color: #fff;
}

.phase-truck-empty {
    filter: brightness(0) invert(60%);
}

.phase-tile.active .phase-truck-empty {
    filter: none;
}


/*
  Refueling / recharge amount steppers — enlarge the Radzen numeric up/down
  buttons into big, touch-friendly tap targets for the field app, and grow the
  digit input to match. Scoped to .amount-stepper (unit-agnostic: used for both
  kWh recharge and litre refuelling inputs) so other RadzenNumeric controls are
  unaffected. Radzen's theme loads after this file, hence the overrides.
*/
.amount-stepper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
}

.amount-stepper .rz-numeric {
    --rz-numeric-button-width: 3.25rem;
    --rz-numeric-button-height: 2.25rem;
    --rz-numeric-button-offset: 0;
    width: 5.5rem;
    height: 5rem;
    border: 1px solid var(--remain-navy);
    border-radius: 10px;
    box-sizing: border-box;
}

.amount-stepper .rz-numeric input[type="number"],
.amount-stepper .rz-numeric input[type="text"] {
    font-size: 2rem;
    font-weight: 600;
    color: var(--remain-navy);
    text-align: center;
    padding-inline-end: 3.5rem;
}

.amount-stepper .rz-numeric-button {
    width: var(--rz-numeric-button-width) !important;
    height: var(--rz-numeric-button-height) !important;
    background-color: var(--remain-navy) !important;
    color: #fff !important;
    border-radius: 6px !important;
}

.amount-stepper .rz-numeric-button .rzi {
    font-size: 1.75rem !important;
    line-height: var(--rz-numeric-button-height) !important;
}

.amount-stepper .rz-numeric-button:hover:not(:disabled) {
    background-color: var(--remain-navy-dark) !important;
}

/*
  Tablet breakpoint (iPad A16 portrait ≈820px, landscape ≈1180px, and the wider
  split-screen panes). Gives the interactive Radzen controls a comfortable
  minimum touch height so dropdowns, inputs and buttons are easy to tap. The
  per-component responsive column sizes (SizeSM/SizeMD) handle the grid reflow;
  this block only tunes touch ergonomics and is intentionally conservative so it
  doesn't override the fixed-size keypad keys or the tall action tiles.
*/
@media (min-width: 601px) and (max-width: 1366px) {
    .remain-app .rz-dropdown,
    .remain-app .rz-textbox,
    .remain-app .rz-numeric,
    .remain-app .rz-button:not(.remain-key):not(.remain-action-tile) {
        min-height: 44px;
    }
}



/*
  Language selector: a single flag button showing the current language's flag.
  Clicking it cycles to the next language and applies it in place (no reload).
*/
.remain-language-toggle {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
}

.remain-language-toggle:hover {
    opacity: 0.85;
}

.remain-language-flag {
    width: 40px;
    height: auto;
    vertical-align: middle;
    border-radius: 2px;
    object-fit: contain;
}
