/*
  Our adjustments on top of the client's design (css/cp-design.css is generated; don't edit it).
  1. Fit the Navigator into our MainLayout (sidebar from 640px, mobile bottom bar below).
  2. Desktop/tablet Navigator: the client's design was only made for a phone frame and sizes one card
     to the full width, so on wide content areas the cards keep their phone size and sit side by side.
  3. Real data the client's sample didn't have (status notes, gear without artwork, history links).
  The top bar reuses the Calendar's switch (app.css .cp-cal-header) so it doesn't move between the two pages.
*/

/* ---- 1. Page height inside our layout ---- */
.cp-design.navigator-page {
    height: calc(100dvh - 5rem); /* our mobile bottom bar (MainLayout gives main 5rem bottom padding) */
    overflow: hidden;
}

.cp-design.navigator-page .navigator-panel {
    height: 100%;
}

@media (min-width: 640px) {
    .cp-design.navigator-page {
        height: 100dvh;
    }
}

/* Our toast sits above the mobile bottom bar. */
.cp-design #toast {
    bottom: 96px;
}

/* Tailwind's reset sets margin: 0 on every element, which pins the <dialog> to the top left. Centre it again. */
.cp-design #modal {
    margin: auto;
    overflow-x: hidden; /* only scrolls up and down */
    overscroll-behavior: contain;
}

/* Phones: pin the dialog near the top instead of centring it. A centred dialog moved up and down whenever the
   keyboard opened or a section of the form grew; now only its content scrolls. */
@media (max-width: 640px) {
    .cp-design #modal {
        margin: 12px auto auto;
        max-height: calc(100dvh - 24px);
    }

    /* Edit order / Resolve conflict: the button row and the date/time pair were wider than a phone, so the
       dialog could be dragged sideways. Let them shrink and wrap so it only scrolls up and down. */
    .cp-design #modal .form-pair > label {
        min-width: 0;
    }

    .cp-design #modal .form-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .cp-design #modal .form-actions button {
        flex: 1 1 auto;
        min-width: 0;
    }
}

/* ---- Top bar: same size and place as the Calendar's (Calendar.razor .cp-calendar-page py-3 + .cp-cal-bar px-3,
   app.css .cp-cal-header). Those are bootstrap's py-3/px-3 (1rem, !important), not Tailwind's 12px, so 16px here;
   with 12px the switch sat 4px higher than on the Calendar and the CRM pages. ---- */
.cp-design .navigator-header {
    display: block;
    height: auto;
    padding: 16px 16px 0;
    background: #fff;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

/* Undo the client design's button look so the switch matches the Calendar's pill exactly. */
.cp-design .navigator-header .cp-cal-nav-toggle {
    position: relative;
}

.cp-design .navigator-header .cp-cal-nav-toggle-btn {
    border: 0;
    border-radius: 9999px;
    background: transparent;
    min-height: 0;
    /* Same as app.css ".cp-cal-nav-toggle .cp-cal-nav-toggle-btn": the pill and segment sizes come from
       there; these only repeat what the client design's button rules would otherwise change. */
    padding: 0 8px;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
}

.cp-design .navigator-header .cp-cal-nav-toggle-btn:hover {
    background: transparent;
}

.cp-design .navigator-header .cp-cal-nav-toggle-btn.active {
    background: #fff;
    font-weight: 600;
}

.cp-design .navigator-header .cp-cal-nav-toggle-btn img {
    display: block;
    width: 16px;
    height: 16px;
}

/* Invisible date input over the Navigator segment; tapping the segment opens its picker. */
.cp-design .navigator-header .navigator-date-segment {
    position: relative;
    display: inline-flex;
}

.cp-design .navigator-header .navigator-date-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    opacity: 0;
    cursor: pointer;
    font-size: 16px; /* no iOS zoom on tap */
    -webkit-appearance: none;
    appearance: none;
}

.cp-design .navigator-header .navigator-date-input::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Side columns keep the row at the Calendar's 40px, so the pill sits at the same height. */
.cp-design .navigator-header-left,
.cp-design .navigator-header-right {
    display: flex;
    align-items: center;
    height: 40px;
    min-width: 0;
}

.cp-design .navigator-header-right {
    justify-content: flex-end;
}

.cp-design .navigator-header-left > .icon {
    width: 32px;
    height: 38px;
    object-fit: contain;
}

/* Phones: the pill is 50px tall with 44px segments (app.css sets the size on .cp-cal-nav-toggle), like the
   Calendar's. These repeat app.css's phone padding and font so the client design's rules don't win. */
@media (max-width: 640px) {
    .cp-design .navigator-header .cp-cal-nav-toggle-btn {
        min-height: 0;
        min-width: 0;
        padding: 0 4px;
        gap: 3px;
        font-size: 0.74rem;
    }

    .cp-design .navigator-header .cp-cal-nav-toggle-btn img {
        width: 13px;
        height: 13px;
    }
}

/* Small phones: same smaller segments as app.css, so the pill matches the Calendar and CRM. */
@media (max-width: 380px) {
    .cp-design .navigator-header .cp-cal-nav-toggle-btn {
        padding: 0 3px;
        font-size: 0.7rem;
    }
}

/* Desktop: no logo (the sidebar has it), bigger faces in the right corner. */
@media (min-width: 641px) {
    .cp-design .navigator-header-left > .icon {
        display: none;
    }

    .cp-design .navigator-header .team-faces {
        width: 54px;
        height: 54px;
    }

    .cp-design .navigator-header .team-faces .avatar {
        width: 31px;
        height: 31px;
    }

    .cp-design .navigator-header .team-faces .avatar:nth-child(1) {
        left: 11px;
    }

    .cp-design .navigator-header .team-faces .avatar:nth-child(2),
    .cp-design .navigator-header .team-faces .avatar:nth-child(3) {
        top: 23px;
    }
}

.cp-design .navigator-header .navigator-date-segment:focus-within .cp-cal-nav-toggle-btn {
    outline: 3px solid #8cadff;
    outline-offset: 1px;
}

/* ---- Day strip: square days; the weekday on the selected day is light grey like in the Calendar ---- */
.cp-design .navigator-panel .days button {
    aspect-ratio: 1;
    min-height: 0;
    padding: 4px;
    gap: 3px;
}

.cp-design .navigator-panel .days button small,
.cp-design .navigator-panel .days button strong {
    line-height: 1;
}

.cp-design .navigator-panel .days .selected small {
    color: #d1d5db;
}

/* ---- 2. Wide content areas: phone-sized cards side by side ---- */
@container (min-width: 700px) {
    .cp-design .navigator-panel {
        --nav-card-width: 340px;
        --nav-track-pad: 24px;
        max-width: 1180px;
        margin: 0 auto;
    }

    /* Top padding leaves room for the red count badges (they stick out 10px above the day). */
    .cp-design .navigator-panel .days {
        justify-content: center;
        padding: 13px var(--nav-track-pad) 10px;
    }

    .cp-design .navigator-panel .days .nav-day {
        flex: 0 1 64px;
    }

    .cp-design .navigator-panel .nav-filters {
        justify-content: center;
        padding: 3px var(--nav-track-pad) 12px;
    }

    .cp-design .navigator-panel .nav-track {
        padding: 5px var(--nav-track-pad) 10px;
        gap: 28px;
        scroll-padding-left: var(--nav-track-pad);
    }

    .cp-design .navigator-panel .navigator-card {
        flex: 0 0 var(--nav-card-width);
        max-width: var(--nav-card-width);
        max-height: 640px;
        scroll-snap-align: start;
    }

    /* When all of the day's cards fit, centre them. */
    .cp-design .navigator-panel .nav-track > :first-child {
        margin-left: auto;
    }

    .cp-design .navigator-panel .nav-track > :last-child {
        margin-right: auto;
    }

    .cp-design .navigator-card .nav-card-actions .primary {
        min-height: 40px;
        font-size: 15px;
    }

    .cp-design .navigator-panel .pager {
        padding: 4px var(--nav-track-pad);
    }
}

@container (min-width: 1100px) {
    .cp-design .navigator-panel {
        --nav-card-width: 360px;
    }
}

/* ---- 3. Real data the client's sample didn't have ---- */

/* Past-due days (missed visits) in the day strip: red border and red date (#1198).
   An inset shadow instead of a border, so the day keeps its size. */
.cp-design .navigator-panel .days .is-past-due {
    box-shadow: inset 0 0 0 2px #f20b24;
}

.cp-design .navigator-panel .days .is-past-due:not(.selected) {
    background: #fff0f3;
    color: #f20b24;
}

.cp-design .navigator-panel .days .is-past-due:not(.selected) small {
    color: #f20b24;
}

/* "Order note: ..." / "Customer note: ...": keep the note's own line breaks. */
.cp-design .nav-note {
    white-space: pre-line;
}

/* Edit order: the round "i" note icon in front of "Order note" / "Customer note". */
.cp-design .note-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cp-design .note-label .icon {
    width: 16px;
    height: 16px;
}

/* "Pending payment · finished 14:32", "Payment link sent", ... under the customer name. */
.cp-design .nav-status-note {
    font-size: 11px;
    color: #4b5563;
    background: #f3f4f6;
    padding: 6px;
    border-radius: 6px;
    margin: 0 0 5px;
}

/* Planned time row (VisitTimeSummary, #1095): same height and spacing as the other info rows. */
.cp-design .nav-card-open .nav-visit-time-row {
    display: flex;
    align-items: center;
    min-height: 35px;
    padding: 4px 0;
}

.cp-design .nav-card-open .nav-visit-time-row button:hover,
.cp-design .nav-visit-time > button:hover {
    background: none;
}

/* Edit order: planned visit time and each job's last tracked time under "Estimated time". */
.cp-design .nav-visit-time {
    display: grid;
    gap: 6px;
    margin: 0 0 8px;
}

.cp-design .nav-visit-time .nav-visit-time-label {
    display: block;
    margin-top: 4px;
}

/* Gear without artwork: show its name in the same frame as the client's equipment images. */
.cp-design .nav-equipment .nav-equipment-name {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 51px;
    height: 49px;
    padding: 2px 6px;
    border: 1px solid #e7e7e7;
    border-radius: 11px;
    font-size: 10px;
    font-weight: 600;
}

/* The card body only scrolls up and down; long overlap texts or addresses wrap instead of pushing it sideways. */
.cp-design .navigator-card .nav-card-open {
    overflow-x: hidden;
    overflow-wrap: anywhere;
}

/* The lock box opens Edit order. */
.cp-design .nav-card-open .nav-lock-open {
    cursor: pointer;
}

/* Address row: a Google Maps link that looks like the other info rows. */
.cp-design .nav-card-open .nav-address {
    color: inherit;
    text-decoration: none;
}

/* Phone row: the icon and number call the customer; no grey circle behind the icon. */
.cp-design .contact-value.contact-call {
    color: #171717;
    text-decoration: none;
}

/* Error / warning line inside the panel (load errors, route recalculation warnings). */
.cp-design .nav-page-message {
    margin: 0 14px 8px;
}

/* Dialog content we keep from the old page (delivery details, delete). */
.cp-design .modal-body .stack {
    display: grid;
    gap: 10px;
}

.cp-design .modal-body .warning-text {
    color: #d72849;
}

/* "Action needed" heading and failure text of a failed arrival email / SMS open the delivery popup. */
.cp-design .navigator-card .nav-delivery-open {
    cursor: pointer;
}

.cp-design .nav-card-open p.nav-delivery-open {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Delivery popup: each channel's status with its history inline, the customer's history folds out. */
.cp-design .delivery-channel + .delivery-channel {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.cp-design .delivery-channel > .icon {
    width: 30px;
    height: 30px;
}

.cp-design .delivery-channel h3 {
    margin: 8px 0 4px;
}

.cp-design .delivery-channel.delivery-failed h3 {
    color: #d72849;
}

.cp-design .delivery-history-title {
    margin: 14px 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: #747981;
}

.cp-design .delivery-history {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.cp-design .delivery-log {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--soft);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.cp-design .delivery-log strong {
    font-size: 12px;
    font-weight: 600;
}

.cp-design .delivery-log.is-sent strong {
    color: #168657;
}

.cp-design .delivery-log.is-failed {
    background: #fff0f3;
}

.cp-design .delivery-log.is-failed strong,
.cp-design .delivery-log-error {
    color: #d72849;
}

.cp-design .delivery-log.is-confirmed {
    background: var(--mint);
    color: #005d44;
}

.cp-design .delivery-log-time {
    font-size: 11px;
    color: var(--muted);
}

.cp-design .delivery-log.is-confirmed .delivery-log-time {
    color: #005d44;
}

.cp-design .delivery-customer-history {
    margin-top: 10px;
}

.cp-design .delivery-customer-history summary {
    cursor: pointer;
    min-height: 40px;
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
}

/* "Har du manuelt informeret kunden om, at du kommer?": ✗ closes, ✓ confirms. Light green as planned cards. */
.cp-design .delivery-confirm {
    margin: 18px 0 12px;
    padding: 12px 14px;
    border: 1.5px solid #bfe5d2;
    border-radius: 14px;
    background: var(--mint);
    color: #005d44;
}

.cp-design .delivery-confirm p {
    margin: 0 0 10px;
    font-weight: 600;
}

.cp-design .delivery-confirm-actions {
    display: flex;
    gap: 10px;
}

.cp-design .delivery-confirm-actions button {
    flex: 1;
    min-height: 44px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.cp-design .delivery-confirm-no {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
}

.cp-design .delivery-confirm-no .icon {
    width: 18px;
    height: 18px;
}

.cp-design .delivery-confirm-yes {
    background: #64cca3;
    border: 1px solid #4fb88f;
    color: #fff;
    font-weight: 700;
}

.cp-design .delivery-confirm-yes:disabled {
    opacity: .6;
}

/* Day without jobs: one centred empty-state card instead of cards, arrows and dots. */
.cp-design .navigator-panel .nav-track:has(> .nav-empty) {
    padding-left: 16px;
    padding-right: 16px;
}

.cp-design .navigator-panel .nav-track .nav-empty {
    flex: 1 1 100%;
    align-self: center;
    max-width: 420px;
    margin: auto;
    padding: 36px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--paper);
    border: 1px dashed #d4d7de;
    border-radius: 16px;
    scroll-snap-align: center;
}

.cp-design .nav-empty .nav-empty-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--soft);
    margin-bottom: 14px;
}

.cp-design .nav-empty .nav-empty-icon .icon {
    width: 30px;
    height: 30px;
}

.cp-design .nav-empty h2 {
    margin: 0 0 6px;
    font-size: 19px;
    font-weight: 650;
}

.cp-design .nav-empty p {
    margin: 0 0 18px;
    color: var(--muted);
    max-width: 300px;
    line-height: 1.45;
}

.cp-design .nav-empty .nav-empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

@media (max-width: 480px) {
    .cp-design .navigator-panel .nav-track .nav-empty {
        padding: 28px 16px;
    }

    .cp-design .nav-empty .nav-empty-actions {
        flex-direction: column;
        align-self: stretch;
    }
}

/* ---- Navigate link and the Open (Arrival) button beside it (#1186) ---- */

.cp-design .navigator-card .nav-main-actions {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.cp-design .navigator-card .nav-main-actions .primary {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
}

/* Navigate is a link (so a phone opens the Maps app); it looks like the button it replaced. */
.cp-design .navigator-card .nav-main-actions a.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 1px solid #000;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background .16s, box-shadow .16s;
}

.cp-design .navigator-card .nav-main-actions a.primary:hover {
    color: #fff;
}

.cp-design .navigator-card .nav-main-actions .nav-arrival-open {
    flex: 0 0 auto;
    margin: 0;
    padding: 6px 16px;
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid #d9d9d9;
    background: #f4f4f6;
    color: #111;
    font-size: 15px;
    gap: 7px;
}

.cp-design .navigator-card .nav-main-actions .nav-arrival-open:hover {
    background: #e9e9ec;
}

.cp-design .navigator-card .nav-main-actions .nav-arrival-open .icon {
    width: 20px;
    height: 20px;
}

@media (max-width: 380px) {
    /* Narrow phones: a little less padding so "Navigate" and "Open" both stay on one line. */
    .cp-design .navigator-card .nav-main-actions .nav-arrival-open {
        padding: 6px 12px;
    }
}

/* #1189: on a phone with many visits the status dots pushed the previous / next arrows off the
   screen. The arrows keep their size and place at both ends; the dots scroll sideways between them
   (navigator.js keeps the current dot in view). */
.cp-design .navigator-panel .pager {
    min-width: 0;
    max-width: 100%;
}

.cp-design .navigator-panel .pager > .icon-button {
    flex-shrink: 0;
}

.cp-design .navigator-panel .status-dots {
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.cp-design .navigator-panel .status-dots::-webkit-scrollbar {
    display: none;
}

.cp-design .navigator-panel .status-dots button {
    flex-shrink: 0;
}

/* #1107: "Unplannable" - the route planner tried and could not place the visit. Dark red with white text
   and the unplugged-plug icon, the same colour and icon as in the Calendar (CalendarStatusColors.Unplannable). */
.cp-design .navigator-card.unplannable .nav-card-head {
    background: #8B1E2D;
    color: #fff;
}

/* The dark key icon (locked visit) is lightened on the dark red header; the plug keeps its own colours. */
.cp-design .navigator-card.unplannable .nav-card-head > .icon:not(.status-icon) {
    filter: invert(1);
}

.cp-design .navigator-panel .navigator-card.unplannable {
    border: 2px solid #5E0F1C;
}

.cp-design .navigator-card.unplannable .nav-card-actions .primary {
    border-radius: 12px;
    font-style: normal;
    font-weight: 600;
}

.cp-design .navigator-panel .nav-filters .unplannable {
    background: #8B1E2D;
    color: #fff;
}

.cp-design .status-dots .unplannable > span {
    background: #8B1E2D;
}

.cp-design .lesson-symbol.unplannable {
    background: #8B1E2D;
}

/* #1107: the route planner has a suggestion for the visit: the green lightning next to the status icon
   opens it in the Calendar. */
.cp-design .navigator-card .nav-suggestion {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    min-height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.cp-design .navigator-card .nav-suggestion img {
    width: 22px;
    height: 22px;
}

/* A planned visit with an optimization: a light sheen passes over the card now and then. */
.cp-design .navigator-card.nav-optimization::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(110deg, transparent 35%, rgba(32, 189, 117, .16) 45%, rgba(255, 255, 255, .55) 50%, rgba(32, 189, 117, .16) 55%, transparent 65%);
    background-size: 300% 100%;
    background-repeat: no-repeat;
    animation: cp-optimization-sheen 4.5s ease-in-out infinite;
}

@keyframes cp-optimization-sheen {
    0% { background-position: 100% 0; }
    45%, 100% { background-position: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .cp-design .navigator-card.nav-optimization::after {
        animation: none;
        background: none;
    }
}

/* #1211: "Edit order" and "Add complaint" share one row under the main action; on a finished
   visit only "Add complaint" is left and it is centred like "Edit order" was. */
.cp-design .navigator-card .nav-card-actions .nav-quiet-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0 18px;
}

.cp-design .navigator-card .nav-card-actions .nav-quiet-actions:empty {
    display: none;
}

/* #1211: "Complaints" with a red count badge over it while the customer has open complaints. */
.cp-design .navigator-card .nav-card-actions .nav-complaints {
    position: relative;
}

.cp-design .navigator-card .nav-card-actions .nav-complaints.has-open {
    color: #b42318;
    font-weight: 600;
}

.cp-design .navigator-card .nav-card-actions .nav-complaints-badge {
    position: absolute;
    top: -6px;
    right: -12px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #d92d20;
    color: #fff;
    font-size: 11px;
    font-style: normal;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
}

/* ---- #1233: car icon instead of "Driving", and what to do about an unplannable visit ---- */

/* The label is vertical text turned 180deg; turn the car back so it stays upright. */
.cp-design .driving-time .driving-time-car {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-bottom: 3px;
    object-fit: contain;
    transform: rotate(180deg);
    opacity: .7;
}

.cp-design .navigator-card .nav-unplannable-hint {
    margin: 0;
    padding: 8px 12px;
    border-radius: 10px;
    background: #f6f6f8;
    color: #3a4650;
    font-size: 13px;
    line-height: 1.35;
}
