html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #7EAA5D;
    border-bottom-color: #004700;
    border-bottom-width: 2px;
    border-bottom-style: solid;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    z-index: 1000;
}

.header-box-btn {
    display: flex;
    align-items: center;
    background: #fff;
    color: #004700;
    border: 1px solid #004700;
    border-radius: 8px;
    padding: 0.4rem 0.9rem;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    transition: background 0.2s, border-color 0.2s;
    margin-right: 20px;
}

.header-box-btn-texts {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 0.5rem;
    line-height: 1.1;
}

.header-box-text {
    font-size: 1rem;
    font-weight: 600;
}

.header-box-checkout {
    font-size: 0.85rem;
    color: #007BFF;
    opacity: 0.85;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-right: 10px;
}

.account-section {
    display: flex;
    align-items: center;
}

.header-account-btn {
    display: flex;
    align-items: center;
    background: #fff;
    color: #004700;
    border: 1px solid #004700;
    border-radius: 8px;
    padding: 0.4rem 0.7rem;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    transition: background 0.2s, border-color 0.2s;
}

.header-account-btn:hover {
    background: #f8f9fa;
}

.header-account-text {
    margin-left: 0.5rem;
    font-weight: 500;
}

body {
  margin-bottom: 60px;
  padding-top: 60px; /* Prevent content from being hidden behind fixed header */
}

.logo-img {
    display: block;
    margin-left: auto;
    margin-right: auto;
    height: 70px;
    border-right-color: #004700;
    border-right-width: 2px;
    border-right-style: solid;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

a.navbar-brand {
    white-space: normal;
    text-align: center;
    word-break: break-all;
}

a {
    color: #0077cc;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.border-top {
    border-top: 1px solid #e5e5e5;
}

.border-bottom {
    border-bottom: 1px solid #e5e5e5;
}

.box-shadow {
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}

button.accept-policy {
    font-size: 1rem;
    line-height: inherit;
}

.footer {
    width: 100%;
    line-height: 60px;
    margin-top: 3rem;
    padding-top: 0.5rem;
}

:root {
    --gap: 1rem
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f9f9f9;
    padding-top: 60px; /* Adjust to your header's height */
}

.container {
    margin: 2rem auto;
    padding: 0 1rem;
}

.text-center {
    text-align: center;
}

.step-title {
    font-size: 1.5rem;
    margin: 1.5rem 0 1rem;
}

.welcome-message {
    font-size: 1.1rem;
    color: #2e5d2e;
    background: #f3f8f0;
    border-left: 4px solid #4a8c4a;
    padding: 0.9rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Weekly special banner. Styled like the welcome message so it reads as an
   announcement, but holds a real product card the customer can add from. */
.special-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
    background: #f3f8f0;
    border-left: 4px solid #4a8c4a;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    text-align: left;
}

.special-card .special-product-card {
    flex: 0 0 auto;
    max-width: 320px;
}

.special-price {
    font-weight: 700;
    color: #004700;
}

/* Paid extras sit in the ordinary product grid, so the price is the only thing marking
   them as charged on top of the box. */
.extra-price {
    font-weight: 700;
    color: #004700;
    margin: 0.15rem 0 0.35rem;
}

.product-card.extra-card {
    border-color: #4a8c4a;
}

.special-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.special-quantity button {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid #004700;
    border-radius: 6px;
    background-color: #B8E28A;
    color: #000;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.special-quantity button[disabled] {
    opacity: 0.45;
    cursor: default;
}

.special-qty {
    min-width: 1.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    color: #2e5d2e;
}

.special-message {
    flex: 1 1 auto;
    font-size: 1.1rem;
    color: #2e5d2e;
}

.sidebar-special-price {
    font-weight: 600;
}

/* Phones: the one-row layout has nowhere to go, so stack it. */
@media (max-width: 700px) {
    .special-card {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .special-card .special-product-card {
        max-width: none;
    }

    .special-quantity {
        justify-content: center;
    }

    .special-message {
        text-align: center;
    }
}

.box-options {
    display: flex;
    gap: var(--gap);
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.box-card {
    flex: 1 1 220px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 14px;
    padding: 1.5rem 1rem 1.25rem 1rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.1rem;
}

.box-card:hover, .box-card.selected {
    border-color: #004700;
    box-shadow: 0 4px 18px rgba(0,123,255,0.10);
    transform: translateY(-2px) scale(1.03);
}

.box-card h3 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: #1b4d2e;
    letter-spacing: 0.01em;
}

.box-card p {
    margin: 0.2rem 0;
    font-size: 1.05rem;
}

.box-card p:first-of-type {
        font-weight: 600;
        color: #004700;
        font-size: 1.15rem;
        margin-bottom: 0.2rem;
    }

.box-card p:last-of-type {
    color: #888;
    font-size: 0.98rem;
    margin-bottom: 0;
}

.box-card.disabled {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
}

.box-icon {
    font-size: 3.5rem;
    color: #004700;
    line-height: 1;
    flex-shrink: 0;
}

/* Layout: stack on phones, sidebar on right for larger screens */
.layout {
    display: grid;
    grid-template-columns: 1fr;
}

.layout > .sidebar {
    order: 0;
}

.layout > .product-grid {
    order: 1;
}

@media (min-width: 960px) {
    .layout {
        grid-template-columns: 1fr 320px;
        align-items: start;
    }
    .layout > .sidebar {
        order: 1;
        grid-column: 2;
    }
    .layout > .product-grid {
        order: 0;
        grid-column: 1;
    }
    .layout > .step-title {
        grid-column: 1 / -1;
        margin-top: 0;
    }
}

/* Product grid: 1 col on phones up to 3 on desktop */
.product-grid {
    display: grid;
    grid-template-columns: 1fr; /* phones */
    gap: var(--gap);
}

@media (min-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(1, 1fr);
    }
}

@media (min-width: 640px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 900px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.product-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 1rem;
    text-align: left;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
}

.product-card .thumb {
    width: 100px;
    height: 100px;
    min-width: 56px;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    display: grid;
    place-items: center;
    font-size: 2rem;
}

.product-card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.2rem;
}

.product-card h4 {
    margin: 0;
    font-size: 1rem;
}

.product-card-amount {
    font-size: 0.8rem;
    color: #6a7a5e;
    margin-top: 0.1rem;
}

.sidebar-item-amount {
    font-size: 0.8em;
    color: #6a7a5e;
}

.product-card button {
    margin-top: 0.5rem;
    background: #007BFF;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    align-self: flex-start;
}

.product-card button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.product-card button.htmx-request:disabled,
.sidebar-item-btn.htmx-request:disabled {
    opacity: 1;
    cursor: pointer;
}

.sidebar {
    position: sticky;
    top: 85px;
    background: #fff;
    border: 2px solid #004700;
    color: #000;
    border-radius: 12px;
    padding: 1rem;
    height: fit-content;
    margin-left: 15px;
}

/* The special and paid extras sit in their own lists but are cart lines like any other,
   so they share the box list's row styling. */
#boxList li,
#specialList li,
#extrasList li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
}

.sidebar-item-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar-item-btn {
    width: 26px;
    height: 26px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #B8E28A;
    color: #000;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9rem;
}

.sidebar-item-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.progress-bar {
    height: 12px;
    background: #eee;
    border-radius: 6px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress {
    height: 100%;
    background: #B8E28A;
    width: 0%;
    transition: width 0.3s;
}

.checkout-btn {
    width: 100%;
    margin-top: 1rem;
    background-color: #B8E28A;
    font-weight: bold;
    color: #000;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    box-sizing: border-box;
}

.checkout-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

ul#boxList,
ul#specialList,
ul#extrasList {
    list-style: none;
    padding: 0;
    margin: 0;
}

    ul#boxList li,
    ul#specialList li,
    ul#extrasList li {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: .5rem;
        padding: .25rem 0;
    }

        ul#boxList li button {
            background: #B8E28A;
            color: #000;
            border: none;
            border-radius: 6px;
            padding: .25rem .5rem;
            cursor: pointer;
        }

/* Desktop: hide mobile toggle, show body */
.cart-toggle-arrow { display: none; }
.cart-header { cursor: default; margin-top: 0; }

.cart-price {
    font-size: 1.6rem;
    font-weight: 700;
    color: #004700;
    margin: 0.25rem 0 0.75rem;
}

@media (max-width: 959px) {
    .sidebar {
        position: sticky;
        top: 70px;
        z-index: 100;
        margin-left: 0;
        border-radius: 0 0 12px 12px;
        padding-top: 0.6rem;
    }

    .cart-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        margin: 0;
        padding-top: 0.3rem;
    }

    .cart-toggle-arrow {
        display: inline-block;
        font-size: 0.8rem;
        transition: transform 0.2s;
    }

    .cart-toggle-arrow::after {
        content: '\25BC';
    }

    #cart-sidebar.expanded .cart-toggle-arrow {
        transform: rotate(180deg);
    }

    .cart-body {
        display: none;
    }

    #cart-sidebar.expanded .cart-body {
        display: block;
        margin-top: 0.5rem;
    }
}

.product-card-quantity {
    padding-left: 7px;
    padding-right: 7px
}

/* Terms & Conditions popup dialog (native <dialog>) */
.terms-dialog {
    width: min(800px, 92vw);
    max-width: 92vw;
    max-height: 85vh;
    padding: 0;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    color: #333;
    overflow: hidden;
}

.terms-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.terms-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
}

.terms-dialog-header h2 {
    color: #004700;
    margin: 0;
    font-size: 1.25rem;
}

.terms-dialog-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: #777;
    cursor: pointer;
    padding: 0 0.25rem;
}

.terms-dialog-close:hover {
    color: #333;
}

.terms-dialog-body {
    padding: 0.5rem 1.5rem 1rem;
    overflow-y: auto;
    /* header (~58px) + actions (~74px) trimmed from the dialog's max-height */
    max-height: calc(85vh - 140px);
}

.terms-dialog-actions {
    padding: 0.5rem 1.5rem 1.25rem;
    border-top: 1px solid #eee;
}

.terms-dialog-actions .checkout-btn {
    margin-top: 0.75rem;
}

/* Phones: keep the logo and account button from overflowing the fixed header */
@media (max-width: 600px) {
    .logo {
        min-width: 0;
        flex-shrink: 1;
    }

    /* Scale the whole logo down proportionally. A fixed height plus max-width would
       letterbox the artwork inside a too-tall bordered box on narrow screens. */
    .logo-img {
        height: auto;
        max-height: 56px;
        width: auto;
        max-width: 55vw;
    }

    /* The footer's one-line credit is ~470px wide; without wrapping it forces
       horizontal overflow on every phone, which drags the fixed header off-screen. */
    .footer {
        line-height: 1.6;
        padding-bottom: 0.75rem;
    }

    .header-right {
        flex-shrink: 0;
        margin-right: 8px;
        gap: 8px;
    }

    .header-account-btn {
        padding: 0.35rem 0.55rem;
        font-size: 0.82rem;
    }

    .header-account-text {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}