/**
 * HHD Availability Widget — Styles v2.0
 * Brand navy: #00205c
 * All states covered. Fixed min-heights prevent CLS.
 */

/* ---------------------------------------------------------------------------
   Widget wrapper
--------------------------------------------------------------------------- */
.hhd-widget {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: #0f172a;
    contain: layout;
}

/* ---------------------------------------------------------------------------
   Panels row
--------------------------------------------------------------------------- */
.hhd-widget__panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.hhd-widget__panel {
    display: block;
    width: 100%;
    padding: 13px 15px;
    border: none;
    border-right: 1px solid #e2e8f0;
    cursor: pointer;
    text-align: left;
    position: relative;
    transition: background 0.12s ease;
    min-height: 76px;
    background: #f8fafc;
}

.hhd-widget__panel:last-child {
    border-right: none;
}

.hhd-widget__panel:hover:not(.hhd-widget__panel--active) {
    background: #f1f5f9;
}

.hhd-widget__panel--active {
    background: #00205c;
    cursor: default;
}

.hhd-widget__panel-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.hhd-widget__panel-icon {
    color: #94a3b8;
    flex-shrink: 0;
}

.hhd-widget__panel--active .hhd-widget__panel-icon {
    color: #7aa0cc;
}

.hhd-widget__panel-label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
}

.hhd-widget__panel--active .hhd-widget__panel-label {
    color: #7aa0cc;
}

.hhd-widget__panel-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hhd-widget__status-text {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
}

.hhd-widget__panel--active .hhd-widget__status-text {
    color: #fff;
}

/* ---------------------------------------------------------------------------
   Status dots
--------------------------------------------------------------------------- */
.hhd-widget__dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
}

.hhd-widget__dot--loading {
    background: #e2e8f0;
    animation: hhd-pulse 1.4s ease-in-out infinite;
}

.hhd-widget__dot--available {
    background: #16a34a;
    color: #fff;
}
.hhd-widget__dot--available::after { content: '✓'; font-size: 9px; font-weight: 700; }

.hhd-widget__dot--soon {
    background: #d97706;
    color: #fff;
}
.hhd-widget__dot--soon::after { content: '◷'; font-size: 10px; }

.hhd-widget__dot--unavailable {
    background: #dc2626;
    color: #fff;
}
.hhd-widget__dot--unavailable::after { content: '✕'; font-size: 9px; font-weight: 700; }

.hhd-widget__dot--unknown {
    background: #64748b;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hhd-widget__dot--unknown svg {
    display: block;
    width: 8px;
    height: 8px;
    stroke: #ffffff !important;
    fill: none !important;
    flex-shrink: 0;
}

.hhd-widget__dot--prompt {
    background: #00205c;
    color: #fff;
}
.hhd-widget__dot--prompt::after { content: '→'; font-size: 9px; }

/* Status text colours */
.hhd-widget__panel[data-state="available"]   .hhd-widget__status-text { color: #16a34a; }
.hhd-widget__panel[data-state="soon"]        .hhd-widget__status-text { color: #d97706; }
.hhd-widget__panel[data-state="unavailable"] .hhd-widget__status-text { color: #dc2626; }
.hhd-widget__panel[data-state="unknown"]     .hhd-widget__status-text { color: #64748b; }
.hhd-widget__panel[data-state="prompt"]      .hhd-widget__status-text { color: #00205c; }
.hhd-widget__panel--active[data-state]       .hhd-widget__status-text { color: #fff; }

/* ---------------------------------------------------------------------------
   Strip — detail area
--------------------------------------------------------------------------- */
.hhd-widget__strip {
    padding: 13px 15px;
    min-height: 110px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.hhd-widget__strip--hidden {
    display: none;
}

.hhd-widget__strip-heading {
    font-size: 13px;
    font-weight: 500;
    color: #0f172a;
    margin: 0 0 2px;
}

.hhd-widget__strip-address {
    font-size: 12px;
    color: #94a3b8;
    margin: 0 0 9px;
    line-height: 1.5;
}

/* Footer row — always at the bottom, consistent height */
.hhd-widget__strip-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    min-height: 28px;
}

.hhd-widget__strip-link {
    font-size: 12px;
    color: #00205c;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}
.hhd-widget__strip-link:hover { text-decoration: underline; }
.hhd-widget__strip-link--muted {
    color: #cbd5e1;
    cursor: default;
    pointer-events: none;
}

/* ---------------------------------------------------------------------------
   Info boxes
--------------------------------------------------------------------------- */
.hhd-infobox {
    border-radius: 0 7px 7px 0;
    padding: 9px 11px;
    margin-bottom: 0;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    border-left: 3px solid transparent;
    flex: 1;
}

.hhd-infobox__icon {
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
    width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Phone icon in circle for no-live-feed */
.hhd-infobox__phone-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: -1px;
}

.hhd-infobox--unknown .hhd-infobox__phone-circle {
    background: #64748b;
    color: #fff;
}

.hhd-infobox__main {
    font-size: 12px;
    font-weight: 500;
    color: #0f172a;
    line-height: 1.5;
}

.hhd-infobox__sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 3px;
    line-height: 1.4;
}

/* Tel link inside infobox */
.hhd-infobox__tel {
    color: #00205c;
    font-weight: 500;
    text-decoration: none;
}
.hhd-infobox__tel:hover { text-decoration: underline; }

/* State colour variants */
.hhd-infobox--available { background: #f0fdf4; border-left-color: #16a34a; }
.hhd-infobox--available .hhd-infobox__icon { color: #16a34a; }
.hhd-infobox--available .hhd-infobox__main { color: #14532d; }

.hhd-infobox--soon { background: #fefce8; border-left-color: #d97706; }
.hhd-infobox--soon .hhd-infobox__icon { color: #d97706; }
.hhd-infobox--soon .hhd-infobox__main { color: #78350f; }

.hhd-infobox--unavailable { background: #fef2f2; border-left-color: #dc2626; }
.hhd-infobox--unavailable .hhd-infobox__icon { color: #dc2626; }
.hhd-infobox--unavailable .hhd-infobox__main { color: #7f1d1d; }
.hhd-infobox--unavailable .hhd-infobox__sub { color: #991b1b; }

.hhd-infobox--unknown { background: #f8fafc; border-left-color: #94a3b8; }
.hhd-infobox--unknown .hhd-infobox__main { color: #0f172a; }
.hhd-infobox--unknown .hhd-infobox__sub { color: #64748b; }

.hhd-infobox--dispatch { background: #f0fdf4; border-left-color: #16a34a; }
.hhd-infobox--dispatch .hhd-infobox__icon { color: #16a34a; }
.hhd-infobox--dispatch .hhd-infobox__main { color: #14532d; }
.hhd-infobox--dispatch .hhd-infobox__sub { color: #16a34a; }

/* ---------------------------------------------------------------------------
   Resting state (postcode entry)
--------------------------------------------------------------------------- */
.hhd-widget__resting { min-height: 70px; }

.hhd-widget__resting-text {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 8px;
}

.hhd-widget__postcode-form {
    display: flex;
    gap: 7px;
    align-items: center;
}

.hhd-widget__postcode-input {
    flex: 1;
    max-width: 160px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #0f172a;
    background: #fff;
    outline: none;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.hhd-widget__postcode-input:focus {
    border-color: #00205c;
    box-shadow: 0 0 0 2px rgba(0, 32, 92, 0.12);
}

.hhd-widget__postcode-submit {
    height: 34px;
    padding: 0 14px;
    background: #00205c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s ease;
}
.hhd-widget__postcode-submit:hover { background: #001844; }
.hhd-widget__postcode-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.hhd-widget__postcode-error {
    font-size: 12px;
    color: #dc2626;
    margin: 6px 0 0;
}

/* ---------------------------------------------------------------------------
   Loading / skeleton
--------------------------------------------------------------------------- */
@keyframes hhd-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.hhd-widget--loading .hhd-widget__strip { pointer-events: none; }

.hhd-skeleton-line {
    height: 12px;
    background: #e2e8f0;
    border-radius: 4px;
    animation: hhd-pulse 1.4s ease-in-out infinite;
    margin-bottom: 8px;
}
.hhd-skeleton-line:last-child { margin-bottom: 0; }
.hhd-skeleton-line--short  { width: 55%; }
.hhd-skeleton-line--medium { width: 75%; }
.hhd-skeleton-line--full   { width: 100%; }

/* ---------------------------------------------------------------------------
   Store modal
--------------------------------------------------------------------------- */
.hhd-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.hhd-modal[hidden] { display: none; }

.hhd-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    cursor: pointer;
}

.hhd-modal__box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}

.hhd-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.hhd-modal__title {
    font-size: 15px;
    font-weight: 500;
    color: #0f172a;
    margin: 0;
}

.hhd-modal__close {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.hhd-modal__close:hover { background: #f1f5f9; color: #0f172a; }

.hhd-modal__search {
    padding: 14px 18px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    border-bottom: 1px solid #e2e8f0;
}

.hhd-modal__input {
    flex: 1;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    color: #0f172a;
    outline: none;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.hhd-modal__input:focus { border-color: #00205c; box-shadow: 0 0 0 2px rgba(0,32,92,0.12); }

.hhd-modal__search-btn {
    height: 38px;
    padding: 0 16px;
    background: #00205c;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
}
.hhd-modal__search-btn:hover { background: #001844; }
.hhd-modal__search-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.hhd-modal__error {
    font-size: 12px;
    color: #dc2626;
    padding: 0 18px;
    margin: 0 0 4px;
}

.hhd-modal__results {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: 8px 0;
}

.hhd-modal__store-row {
    padding: 12px 18px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.hhd-modal__store-row:last-child { border-bottom: none; }
.hhd-modal__store-row:hover { background: #f8fafc; }
.hhd-modal__store-row--selected { background: #eff6ff; }

.hhd-modal__store-name    { font-size: 13px; font-weight: 500; color: #0f172a; margin: 0 0 2px; }
.hhd-modal__store-address { font-size: 12px; color: #64748b; margin: 0; line-height: 1.4; }
.hhd-modal__store-dist    { font-size: 12px; color: #94a3b8; white-space: nowrap; flex-shrink: 0; margin-top: 2px; }
.hhd-modal__no-stores     { padding: 24px 18px; text-align: center; color: #64748b; font-size: 13px; }

.hhd-modal__skeleton { padding: 12px 18px; }
.hhd-skeleton-row {
    height: 54px;
    background: #f1f5f9;
    border-radius: 7px;
    margin-bottom: 8px;
    animation: hhd-pulse 1.4s ease-in-out infinite;
}

/* ---------------------------------------------------------------------------
   Mobile
--------------------------------------------------------------------------- */
@media (max-width: 479px) {
    .hhd-widget__panel { padding: 11px 12px; min-height: 68px; }
    .hhd-widget__strip { padding: 12px; min-height: 100px; }
    .hhd-widget__postcode-form { flex-wrap: wrap; }
    .hhd-widget__postcode-input { max-width: 100%; width: 100%; }
    .hhd-widget__postcode-submit { width: 100%; }
    .hhd-modal__box { max-height: 90vh; border-radius: 12px 12px 0 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: 100%; }
}

/* ---------------------------------------------------------------------------
   Modal — store rows
--------------------------------------------------------------------------- */

.hhd-modal__store-row {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}
.hhd-modal__store-row:last-child  { border-bottom: none; }
.hhd-modal__store-row:hover       { background: #f8fafc; }
.hhd-modal__store-row--selected   { background: #f0f7ff; }

/* Store name + badges on one flex row */
.hhd-modal__store-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
    flex-wrap: nowrap;
}

.hhd-modal__store-name {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
    flex: 1 1 120px;
    min-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hhd-modal__store-address {
    font-size: 12px;
    color: #94a3b8;
    margin: 0 0 10px;
    line-height: 1.4;
}

/* Stock badge */
.hhd-modal__stock-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 9px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}
.hhd-modal__stock-badge--available   { background: #dcfce7; color: #15803d; }
.hhd-modal__stock-badge--soon        { background: #fef9c3; color: #92400e; }
.hhd-modal__stock-badge--unavailable { background: #fee2e2; color: #991b1b; }
.hhd-modal__stock-badge--unknown     { background: #f1f5f9; color: #64748b; }

.hhd-modal__store-dist {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Actions row: view info + collect button */
.hhd-modal__store-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.hhd-modal__expand-btn {
    font-size: 12px;
    color: #64748b;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.hhd-modal__expand-btn:hover { color: #0f172a; }

.hhd-modal__select-btn {
    font-size: 12px;
    font-weight: 800;
    padding: 7px 18px;
    background: #FFD100;
    color: #00205B;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.hhd-modal__select-btn:hover { background: #E6BC00; }

.hhd-modal__store-row--selected .hhd-modal__select-btn {
    background: #00205B;
    color: #FFD100;
    font-weight: 800;
    cursor: default;
    padding-left: 18px;
}

/* Expandable detail panel */
.hhd-modal__store-detail {
    margin-top: 12px;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Phone row */
.hhd-modal__detail-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #475569;
    margin-bottom: 14px;
}
.hhd-modal__detail-row svg { flex-shrink: 0; color: #00205c; }

.hhd-modal__tel {
    color: #00205c;
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
}
.hhd-modal__tel:hover { text-decoration: underline; }

/* Opening hours table — each day on its own line, spaced out */
.hhd-modal__hours-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
}

.hhd-modal__hours-table tr {
    border-bottom: 1px solid #e2e8f0;
}
.hhd-modal__hours-table tr:last-child { border-bottom: none; }

.hhd-modal__hours-table td {
    padding: 6px 4px;
    font-size: 13px;
    vertical-align: middle;
}

.hhd-modal__hours-day {
    width: 110px;
    min-width: 110px;
    color: #475569;
    font-weight: 500;
    white-space: nowrap;
}

.hhd-modal__hours-time { color: #0f172a; }

.hhd-modal__hours-today .hhd-modal__hours-day,
.hhd-modal__hours-today .hhd-modal__hours-time {
    font-weight: 700;
    color: #00205c;
}

.hhd-modal__hours-today .hhd-modal__hours-day::after {
    content: ' (today)';
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
}

/* Store page link */
.hhd-modal__store-page-link {
    font-size: 12px;
    color: #00205c;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.hhd-modal__store-page-link:hover  { text-decoration: underline; }
.hhd-modal__store-page-link::after { content: '↗'; font-size: 11px; }

/* --------------------------------------------------------------------------
   HHD modal layout fixes - desktop and mobile
   Keeps store rows readable and puts distance above the action button.
-------------------------------------------------------------------------- */

.hhd-modal__box {
    max-width: 560px;
    width: calc(100% - 32px);
}

.hhd-modal__body {
    max-height: 70vh;
    overflow-y: auto;
}

.hhd-modal__store-row {
    display: grid !important;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "main action"
        "address action"
        "detail detail";
    gap: 6px 16px;
    padding: 18px 20px;
    align-items: center;
}

.hhd-modal__store-top {
    grid-area: main;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}

.hhd-modal__store-name {
    min-width: 115px;
    max-width: 180px;
    font-weight: 700;
    color: #0f172a;
}

.hhd-modal__store-address {
    grid-area: address;
    width: 100%;
    margin-top: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #64748b;
}

.hhd-modal__store-actions {
    grid-area: action;
    display: flex !important;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 7px;
    min-width: 140px;
}

.hhd-modal__store-dist {
    display: block;
    font-size: 12px;
    line-height: 1.2;
    color: #64748b;
    text-align: right;
    margin: 0;
}

.hhd-modal__select-btn {
    min-width: 136px;
    text-align: center;
    white-space: nowrap;
}

.hhd-modal__store-row--selected .hhd-modal__select-btn,
.hhd-modal__select-btn.is-selected {
    background: #00205B;
    border-color: #00205B;
    color: #FFD100;
    cursor: default;
}

.hhd-modal__expand-btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 12px;
    line-height: 1.2;
    color: #00205c;
    text-decoration: underline;
    cursor: pointer;
    text-align: right;
}

.hhd-modal__store-detail {
    grid-area: detail;
    margin-top: 4px;
}

.hhd-modal__store-detail[hidden] {
    display: none !important;
}

.hhd-modal__hours-table {
    max-width: 300px;
}

@media (max-width: 640px) {
    .hhd-modal {
        padding: 0;
        align-items: flex-end;
    }

    .hhd-modal__box {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: 14px 14px 0 0;
    }

    .hhd-modal__body {
        max-height: calc(92vh - 130px);
    }

    .hhd-modal__store-row {
        grid-template-columns: 1fr;
        grid-template-areas:
            "main"
            "address"
            "action"
            "detail";
        padding: 16px;
    }

    .hhd-modal__store-top {
        display: flex;
        width: 100%;
    }

    .hhd-modal__store-name {
        max-width: none;
    }

    .hhd-modal__store-actions {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-width: 0;
    }

    .hhd-modal__store-dist {
        order: 1;
        width: 100%;
        text-align: right;
    }

    .hhd-modal__select-btn {
        order: 2;
        min-width: 150px;
    }

    .hhd-modal__expand-btn {
        order: 3;
        text-align: right;
    }
}
