/* Stack nav buttons vertically on small screens */
@media (max-width: 768px) {
    /* the opened menu drops below the logo row; with the bar's flex-nowrap it sat beside it, pushed off the screen
       by the plan badge, so a signed-in phone saw an empty menu (owner, 19 Nov 2026) */
    nav.navbar > .container, nav.navbar > .container-fluid {
        flex-wrap: wrap !important;
    }

    #btngrpNav {
        flex-direction: column !important;
        width: 100% !important;
    }

    #btngrpNav .btn {
        margin-bottom: 0.25rem;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .responsive-title {
        font-size: 1.4rem !important;
    }
}

@media (min-width: 769px) {
    .responsive-title {
        font-size: 2rem !important;
    }
}

.small-date-picker .DateInput_input {
    font-size: 15px;
}

.small-date-picker .DateInput {
    font-size: 15px;
}

#preview-image {
    transition: opacity 0.2s ease;
}

/* ── Portfolio page ───────────────────────────────────────────── */

/* Tabs: prevent label wrapping on small screens */
.portfolio-tabs .nav-link {
    font-size: 13px;
    padding: 6px 12px;
    white-space: nowrap;
}

@media (max-width: 400px) {
    .portfolio-tabs .nav-link {
        font-size: 11px;
        padding: 5px 8px;
    }
}

/* Stat cards: ensure label fits on two lines without overflow */
#Port-Response1 .card-body p.text-muted {
    white-space: normal;
    line-height: 1.3;
}

/* Date picker: prevent iOS auto-zoom (input font-size >= 16px) */
.small-date-picker input {
    font-size: 16px !important;
}

/* DataTable: make filter inputs readable on mobile */
.dash-filter input {
    font-size: 14px !important;
}

/* Responsive graph height in Map tab */
@media (max-width: 575.98px) {
    #Port-Response1 .js-plotly-plot {
        height: 320px !important;
    }
}

/* ── Chat modal & page ────────────────────────────────────────── */

/* Typing / thinking indicator — three pulsing dots */
.chat-typing-dots {
    display: flex;
    align-items: center;
    padding: 4px 2px;
    gap: 4px;
}

.chat-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #03446E;
    opacity: 0.4;
    animation: typing-pulse 1.2s infinite ease-in-out;
}

@keyframes typing-pulse {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.3; }
    40%            { transform: scale(1);   opacity: 1;   }
}

/* flex column wrapper for modal body content */
.chat-modal-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* message area — fixed height on desktop so modal doesn't overflow */
.chat-messages {
    height: 400px;
    max-height: 52vh;
    min-height: 120px;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

/* message bubbles — responsive max-width */
.chat-bubble {
    max-width: 78%;
    word-wrap: break-word;
    word-break: break-word;
}

/* minimum touch target size (WCAG 2.5.5) */
#chat-send-btn,
#chat-input,
.chat-modal-body .form-control {
    min-height: 44px;
}

/* prevent iOS Safari from zooming on focus */
#chat-input,
.chat-modal-body input[type="text"] {
    font-size: 16px !important;
}

/* mobile: fullscreen modal — single consolidated block */
@media (max-width: 575.98px) {
    /* fullscreen dialog fills viewport including safe areas */
    .modal-fullscreen-sm-down.modal-dialog {
        margin: 0;
        max-width: 100%;
        width: 100%;
    }

    .modal-fullscreen-sm-down .modal-content {
        border-radius: 0;
        /* push content above home indicator on iPhone */
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* modal header: allow title to wrap so close button stays visible */
    .modal-fullscreen-sm-down .modal-header {
        flex-wrap: wrap;
        row-gap: 4px;
        padding: 8px 12px;
    }

    /* modal body: flex column, clipped, no horizontal scroll */
    .modal-fullscreen-sm-down .modal-body {
        display: flex;
        flex-direction: column;
        padding: 10px;
        overflow: hidden;
        max-width: 100%;
    }

    /* chat-modal-body fills all remaining vertical space */
    .modal-fullscreen-sm-down .chat-modal-body {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        max-width: 100%;
    }

    /* message area fills the flex space */
    .modal-fullscreen-sm-down .chat-messages {
        flex: 1 1 auto;
        height: auto !important;
        max-height: none !important;
        min-height: 0;
    }

    /* input group: don't overflow viewport */
    .modal-fullscreen-sm-down .chat-modal-body .input-group {
        max-width: 100%;
    }

    .chat-bubble {
        max-width: 92%;
    }

    .chat-hint-text {
        display: none;
    }
}


/* chat full-page layout */
.chat-page-messages {
    height: calc(100vh - 290px);
    /* iOS Safari: use svh (small viewport height) to exclude browser chrome */
    height: calc(100svh - 290px);
    min-height: 320px;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 12px;
}

@media (max-width: 575.98px) {
    .chat-page-messages {
        height: calc(100vh - 200px);
        height: calc(100svh - 200px);
        min-height: 240px;
    }

    .chat-bubble {
        max-width: 92%;
    }
}

/* ── Valuations modal (#val-view-modal) ───────────────────────── */

/* Tab bar: scroll horizontally on narrow screens so labels don't wrap or clip */
#val-view-modal .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;          /* Firefox */
}
#val-view-modal .nav-tabs::-webkit-scrollbar {
    display: none;                  /* Chrome / Safari */
}
#val-view-modal .nav-tabs .nav-link {
    white-space: nowrap;
    font-size: 13px;
    padding: 6px 12px;
}

/* Modal body: reliable scroll on iOS */
#val-view-modal .modal-body {
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Tab pane content: allow wide tables/charts to scroll horizontally */
#val-view-modal .tab-content,
#val-view-modal .tab-pane {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Prevent DataTable filter inputs triggering iOS zoom */
#val-view-modal .dash-filter input,
#val-view-modal input[type="text"],
#val-view-modal input[type="search"] {
    font-size: 16px !important;
}

/* Fullscreen on mobile: push content above home indicator */
@media (max-width: 575.98px) {
    #val-view-modal.modal-fullscreen-sm-down .modal-content,
    #val-view-modal .modal-fullscreen-sm-down .modal-content {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    #val-view-modal .nav-tabs .nav-link {
        font-size: 11px;
        padding: 5px 9px;
    }

    /* Charts inside tabs: limit height so they don't push content off screen */
    #val-view-modal .js-plotly-plot {
        max-height: 55vh;
    }
}

/* ── Font: Nunito Sans everywhere (the LUX theme's font; also on the Flask pages) ─────────────────────
   Loaded in full weights (the theme only loads 400 and 600, so bold was synthesised). Charts use it too.
   The theme's capitals and square black buttons are replaced below ("Style refresh"). */
:root {
    --hpai-font: "Nunito Sans", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    --bs-font-sans-serif: var(--hpai-font);
    --bs-body-font-family: var(--hpai-font);
}
body { font-family: var(--hpai-font); }
/* figures in tables line up */
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner td,
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner th,
table td, table th { font-variant-numeric: tabular-nums; }

/* Guest landing panel (MDAP.GuestHero): small on phones so the valuation inputs show on the first screen */
.guest-hero .btn { padding: .5rem 1.1rem; }
@media (max-width: 767.98px) {
    .guest-hero.card > .card-body { padding: .75rem 1rem; }
    .guest-hero .lead { font-size: 1rem; margin-bottom: .6rem !important; }
}

/* Postcode suggestions as you type, under the valuation's postcode box */
.pc-suggest { margin: 4px 0 6px; border-radius: 6px; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.pc-suggest:empty { box-shadow: none; margin: 0; }
.pc-suggest-item { display: block; width: 100%; min-height: 44px; padding: 10px 12px; text-align: left; background: #fff;
    color: #0f2230; border: 0; border-bottom: 1px solid #e3e8ec; font-size: .95rem; font-weight: 600;
    text-transform: none; letter-spacing: normal; cursor: pointer; }
.pc-suggest-item:hover, .pc-suggest-item:focus { background: #eef4f8; outline: none; }
.pc-suggest-more { background: #fff; color: #586a78; font-size: .8rem; padding: 6px 12px; }
.pc-suggest-msg { background: #fff7e0; color: #5c4400; padding: 8px 12px; font-size: .85rem; text-align: left; }

/* The valuation's three Swatches: short labels that never break mid-word on a phone */
.lv-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; }
.lv-tile { border-radius: 3px; padding: 6px 5px; min-height: 56px; display: flex; flex-direction: column;
    justify-content: space-between; min-width: 0; cursor: help; }
.lv-t, .lv-v { letter-spacing: normal; text-transform: none; line-height: 1.15; overflow-wrap: normal; word-break: normal;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-t { font-size: .68rem; font-weight: 800; }
.lv-v { font-size: .74rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .lv-tile { padding: 5px 3px; min-height: 48px; } .lv-t { font-size: .6rem; } .lv-v { font-size: .66rem; } }
.lv-note { min-height: 0; padding: 4px 2px 0; color: var(--bs-secondary-color, #586a78); }
.lv-note:empty { padding: 0; }

/* ── Style refresh (owner, 21 Oct 2026: the app looked dated beside the newer pages) ─────────────────────
   The newer pages' look (Swatchle, /us, the method pages): sentence case instead of the LUX theme's spaced capitals,
   navy buttons with rounded corners instead of square black ones, softer cards. Colours as the Flask pages. */
:root { --hpai-navy: #03446e; --hpai-navy-dark: #02324f; --hpai-ink: #0f2230; --hpai-muted: #586a78; --hpai-line: #d6dee5; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6, .card-title, .modal-title, .nav-tabs .nav-link, legend {
    text-transform: none; letter-spacing: normal; }
h1, h2, h3, .h1, .h2, .h3 { font-weight: 900; }
h4, h5, h6, .h4, .h5, .h6, .card-title, .modal-title { font-weight: 800; }
.btn { text-transform: none; letter-spacing: normal; font-weight: 700; border-radius: 8px; }
.btn-sm { border-radius: 6px; }
.btn-primary { background-color: var(--hpai-navy); border-color: var(--hpai-navy); color: #fff; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active {
    background-color: var(--hpai-navy-dark); border-color: var(--hpai-navy-dark); color: #fff; }
.btn-outline-secondary, .btn-outline-primary { color: var(--hpai-navy); border-color: var(--hpai-navy); }
.btn-outline-secondary:hover, .btn-outline-primary:hover { background-color: var(--hpai-navy); border-color: var(--hpai-navy); color: #fff; }
.card { border-radius: 12px; border-color: var(--hpai-line); }
.card > .card-header:first-child { border-radius: 12px 12px 0 0; }
.form-control, .form-select { border-radius: 8px; }
.modal-content { border-radius: 14px; }
body, p, .lead, .small, small, label, .form-label, .form-control, .form-select, .dropdown-item, .card-text {
    letter-spacing: normal; }
.navbar .nav-link, .navbar .dropdown-toggle, .navbar-brand { text-transform: none; letter-spacing: normal; font-weight: 700; }
.Select-placeholder, .Select--single > .Select-control .Select-value { padding-right: 34px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The menu a little larger on tablets and desktops (owner, 21 Oct 2026); base.html has the same rule for the Flask pages */
@media (min-width: 768px) { #btngrpNav .btn { font-size: .9rem; } }
@media (min-width: 768px) and (max-width: 991.98px) { #btngrpNav .btn { font-size: .82rem; padding-left: .45rem; padding-right: .45rem; } }   /* one line on an upright iPad */
