/* Milligram overrides */
:root {
    /* The following are official CakePHP colors */
    --color-cakephp-red: #d33c43;
    --color-cakephp-gray: #404041;
    --color-cakephp-blue: #2f85ae;
    --color-cakephp-lightblue: #34bdd7;

    /* These are additional colors */
    --color-lightgray: #606c76;
    --color-white: #fff;

    --color-main-bg: #f5f7fa;
    --color-links: var(--color-cakephp-blue);
    --color-links-active: #2a6496;
    --color-headings: #363637;

    --color-message-success-bg: #e3fcec;
    --color-message-success-text: #1f9d55;
    --color-message-success-border: #51d88a;

    --color-message-warning-bg: #fffabc;
    --color-message-warning-text: #8d7b00;
    --color-message-warning-border: #d3b800;

    --color-message-error-bg: #fcebea;
    --color-message-error-text: #cc1f1a;
    --color-message-error-border: #ef5753;

    --color-message-info-bg: #eff8ff;
    --color-message-info-text: #2779bd;
    --color-message-info-border: #6cb2eb;

    --site-header-height: 88px;
}

/* Base button defaults, later overridden to SustainChain green */
.button,
button,
input[type='button'],
input[type='reset'],
input[type='submit'] {
    background-color: var(--color-cakephp-red);
    border-color: var(--color-cakephp-red);
}

body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: 400;
    background: var(--color-main-bg);
    padding-top: var(--site-header-height);
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

html {
    scroll-padding-top: calc(var(--site-header-height) + 16px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
video,
canvas,
svg {
    max-width: 100%;
}

.top-nav-links,
.side-nav,
h1, h2, h3, h4, h5, h6 {
    font-family: "Raleway", sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 400;
    color: var(--color-headings);
}

a {
    color: var(--color-links);
    transition: color 0.2s linear;
}

a:hover,
a:focus,
a:active {
    color: var(--color-links-active);
    transition: color 0.2s ease-out;
}

.side-nav a,
th a,
.actions a {
    color: var(--color-lightgray);
}

.side-nav a:hover,
.side-nav a:focus,
.actions a:hover,
.actions a:focus {
    color: var(--color-links-active);
}

/* Utility */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 720px;
}

/* Main */
.main {
    padding: 2.4rem 0 4rem;
}

.content {
    padding: 2rem;
    background: var(--color-white);
    border-radius: 0.4rem;
    /* Thanks Stripe */
    box-shadow:
        0 7px 14px 0 rgba(60, 66, 87, 0.1),
        0 3px 6px 0 rgba(0, 0, 0, 0.07);
    max-width: 100%;
    min-width: 0;
}

.content form {
    margin: 0;
}

.actions a {
    font-weight: bold;
    padding: 0 0.4rem;
}

.actions a:first-child {
    padding-left: 0;
}

th {
    white-space: nowrap;
}

td,
th {
    overflow-wrap: anywhere;
}

/* View action */
.view.content .text {
    margin-top: 1.2rem;
}

.related {
    margin-top: 2rem;
}

/* Flash messages */
.message {
    padding: 0.5rem 1rem;
    background: var(--color-message-info-bg);
    color: var(--color-message-info-text);
    border-color: var(--color-message-info-border);
    border-width: 1px;
    border-style: solid;
    border-radius: 4px;
    margin-bottom: 1rem;
    cursor: pointer;
}

.message.hidden {
    display: none;
}

.message.success {
    background: var(--color-message-success-bg);
    color: var(--color-message-success-text);
    border-color: var(--color-message-success-border);
}

.message.warning {
    background: var(--color-message-warning-bg);
    color: var(--color-message-warning-text);
    border-color: var(--color-message-warning-border);
}

.message.error {
    background: var(--color-message-error-bg);
    color: var(--color-message-error-text);
    border-color: var(--color-message-error-border);
}

/* Forms */
.input {
    margin-bottom: 1.5rem;
}

.input input,
.input select,
.input textarea {
    margin-bottom: 0;
}

.input label:has(input[type='checkbox']),
.input label:has(input[type='radio']) {
    display: flex;
    align-items: center;
}

.input label:has(~ label),
.input label:has(input[type='radio']) {
    margin-bottom: 0;
}

.input label > input[type='checkbox'],
.input label > input[type='radio'] {
    margin-right: 1rem;
}

input[type='color'] {
    max-width: 4rem;
    padding: 0.3rem 0.5rem 0.3rem;
}

.error-message {
    color: var(--color-message-error-text);
}

/* Paginator */
.paginator {
    text-align: right;
}

.paginator p {
    margin-bottom: 0;
}

.pagination {
    display: flex;
    justify-content: center;
    list-style: none;
    margin: 0 0 1rem 0;
    padding: 0;
}

.pagination li {
    display: inline-block;
    margin: 0.25em;
    text-align: center;
}

.pagination a {
    color: var(--color-cakephp-blue);
    display: inline-block;
    font-size: 1.25rem;
    line-height: 3rem;
    min-width: 3rem;
    padding: 0;
    position: relative;
    text-decoration: none;
    transition: background 0.3s, color 0.3s;
}

.pagination li.active a,
.pagination a:hover {
    text-decoration: underline;
}

.pagination .disabled a {
    cursor: not-allowed;
    color: var(--color-lightgray);
    text-decoration: none;
}

.first a,
.prev a,
.next a,
.last a {
    padding: 0 0.75rem;
}

.disabled a:hover {
    background: initial;
    color: initial;
}

/* Cart */
.cart-page table {
    table-layout: fixed;
}

.cart-page td,
.cart-page th {
    vertical-align: middle;
}

.cart-page .actions {
    text-align: center;
}

.cart-page .actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 22px;
    border: 1px solid #dbe3e9;
    border-radius: 999px;
    color: #52616f;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: normal;
}

.cart-page th:first-child,
.cart-page td:first-child {
    width: 170px;
}

.cart-image-cell {
    vertical-align: middle;
}

.cart-image-frame {
    width: 140px;
    height: 110px;
    border-radius: 12px;
    overflow: hidden;
    background: #f3f5f7;
    border: 1px solid #e1e6eb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-listing-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.cart-page .paginator {
    display: none;
}

.cart-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.6rem;
}

.cart-total {
    margin: 0;
    color: #52616f;
    font-size: 1.7rem;
    font-weight: 700;
}

.cart-summary-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cart-update-button,
.cart-checkout-button {
    min-width: 190px;
    margin-bottom: 0;
    text-align: center;
}

.cart-update-button-idle {
    border-color: #dbe3e9;
    background: #eef1f4;
    color: #52616f;
    cursor: not-allowed;
    opacity: 0.72;
}

.cart-update-button-idle:hover,
.cart-update-button-idle:focus {
    border-color: #dbe3e9;
    background: #eef1f4;
    color: #52616f;
}

.cart-update-button-dirty {
    border-color: #1f7a45;
    background: #1f7a45;
    color: #ffffff;
}

.cart-checkout-button-disabled {
    border-color: #dbe3e9;
    background: #eef1f4;
    color: #52616f;
    cursor: not-allowed;
    opacity: 0.72;
}

.cart-checkout-button-disabled:hover,
.cart-checkout-button-disabled:focus {
    border-color: #dbe3e9;
    background: #eef1f4;
    color: #52616f;
}

/* Checkout */
.checkout-page {
    align-items: flex-start;
    gap: 2rem;
}

.checkout-page .column {
    min-width: 0;
}

.checkout-summary-card,
.checkout-payment-card {
    height: 100%;
}

.checkout-table {
    margin-bottom: 0;
}

.checkout-total {
    margin-top: 1.8rem;
    font-size: 1.9rem;
    font-weight: 700;
    color: #4f5d6b;
}

.checkout-return {
    margin-top: 1.6rem;
}

.checkout-payment-card fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

.asc:after {
    content: " \2193";
}

.desc:after {
    content: " \2191";
}

/* Error in non debug mode */
.error-container {
    align-items: center;
    display: flex;
    flex-direction: column;
    height: 100vh;
    justify-content: center;
}

/* Side nav */
.side-nav-item {
    display: block;
    padding: 0.5rem 0;
}

/* ===== SustainChain container support ===== */
/* Matches home page container width */
.container {
    width: 88%;
    max-width: 1240px;
    margin: 0 auto;
    min-width: 0;
}

/* ===== SustainChain unified header ===== */
/* This matches the updated default.php structure:
   <header class="site-header">
       <div class="container nav-container">
           <div class="site-logo">...</div>
           <nav class="site-nav">...</nav>
       </div>
   </header>
*/

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #f5f7f5;
    padding: 28px 0 18px;
    border-bottom: 1px solid #e4e7eb;
    box-shadow: 0 8px 24px rgba(31, 41, 55, 0.06);
}

.site-header .container {
    width: min(96vw, 1580px);
    margin: 0 auto;
    padding: 0 28px;
    box-sizing: border-box;
    max-width: none;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.site-logo a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 2.4rem;
    font-weight: 700;
    color: #1f7a45;
    letter-spacing: -0.5px;
    text-decoration: none;
}

.site-logo-mark {
    width: 34px;
    height: 34px;
    object-fit: contain;
    display: block;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-toggle {
    display: none;
}

/* Normal nav links */
.site-nav a,
.top-nav-link {
    position: relative;
    margin: 0;
    color: #4f6f5e;
    font-size: 1.7rem;
    font-weight: 500;
    text-decoration: none;
    transition: 0.2s ease;
}

.site-nav a:hover,
.site-nav a:focus,
.site-nav a.active,
.top-nav-link:hover,
.top-nav-link:focus,
.top-nav-link.active {
    color: #1f7a45;
    text-decoration: none;
}

/* Underline effect exactly like home style */
.site-nav a::after,
.top-nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 100%;
    height: 2px;
    background: #1f7a45;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.25s ease;
}

.site-nav a:hover::after,
.site-nav a:focus::after,
.site-nav a.active::after,
.top-nav-link:hover::after,
.top-nav-link:focus::after,
.top-nav-link.active::after {
    transform: scaleX(1);
}

/* Login / logout button - match home thickness */
.nav-login,
.nav-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 26px;
    border: 2px solid #1f7a45;
    border-radius: 999px;
    color: #1f7a45 !important;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    background: transparent;
    box-sizing: border-box;
    box-shadow: none;
    outline: none;
    transition: 0.2s ease;
    vertical-align: middle;
}

.nav-login:hover,
.nav-pill:hover,
.nav-login:focus,
.nav-pill:focus {
    background: #1f7a45;
    color: #fff !important;
    text-decoration: none;
}

/* Register button - match home */
.nav-register {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 26px;
    border: 2px solid #d10b0b;
    border-radius: 999px;
    color: #d10b0b !important;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    background: transparent;
    box-sizing: border-box;
    box-shadow: none;
    outline: none;
    transition: 0.2s ease;
    vertical-align: middle;
}

.nav-register:hover,
.nav-register:focus {
    background: #d10b0b;
    color: #fff !important;
    text-decoration: none;
}

/* Buttons should not show underline animation */
.nav-login::after,
.nav-register::after,
.nav-pill::after {
    display: none;
}

/* ===== SustainChain common buttons ===== */
.button,
button,
input[type='button'],
input[type='reset'],
input[type='submit'],
a.button {
    background-color: #1f7a45;
    border-color: #1f7a45;
    color: #fff;
    border-radius: 999px;
}

.button:hover,
button:hover,
input[type='button']:hover,
input[type='reset']:hover,
input[type='submit']:hover,
a.button:hover {
    background-color: #145a31;
    border-color: #145a31;
    color: #fff;
}

/* Green focus */
.input input:focus,
.input select:focus,
.input textarea:focus,
input:focus,
textarea:focus {
    border-color: #1f7a45;
    box-shadow: 0 0 0 3px rgba(31, 122, 69, 0.14);
}

/* Responsive */
@media screen and (max-width: 900px) {
    .checkout-page {
        flex-direction: column;
        width: 100%;
        margin-left: 0;
    }

    .checkout-page .column {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
}

@media screen and (max-width: 768px) {
    :root {
        --site-header-height: 82px;
    }

    .main {
        padding: 1.6rem 0 3rem;
    }

    .container {
        width: 100%;
        padding-left: 1.2rem;
        padding-right: 1.2rem;
    }

    .content {
        padding: 1.6rem;
        border-radius: 1.2rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    h1 {
        font-size: 3.2rem;
    }

    h2 {
        font-size: 2.7rem;
    }

    h3 {
        font-size: 2.2rem;
    }

    input,
    select,
    textarea,
    button,
    .button,
    a.button {
        max-width: 100%;
    }

    .button,
    button,
    input[type='button'],
    input[type='reset'],
    input[type='submit'],
    a.button {
        white-space: normal;
        min-height: 4.4rem;
        height: auto;
        line-height: 1.25;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .site-header {
        padding: 16px 0;
    }

    .nav-container {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        width: 48px;
        height: 44px;
        min-width: 48px;
        padding: 0;
        margin: 0;
        border: 1px solid #d7e5dc;
        border-radius: 10px;
        background: #ffffff;
        color: #1f7a45;
        box-shadow: none;
        cursor: pointer;
        flex-direction: column;
    }

    .nav-toggle:hover,
    .nav-toggle:focus {
        background: #eef8f1;
        border-color: #b8d7c4;
        color: #1f7a45;
    }

    .nav-toggle-line {
        display: block;
        width: 22px;
        height: 2px;
        border-radius: 999px;
        background: currentColor;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .nav-toggle-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .nav-toggle.is-open .nav-toggle-line:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .nav-toggle.is-open .nav-toggle-line:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.is-open .nav-toggle-line:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .site-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 0 2px;
    }

    .site-nav.is-open {
        display: flex;
    }

    .site-nav a,
    .top-nav-link {
        font-size: 1.6rem;
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 14px;
        border-radius: 10px;
        background: #eef1f4;
    }

    .site-nav a::after,
    .top-nav-link::after {
        display: none;
    }

    .site-logo a {
        font-size: 2rem;
        gap: 8px;
    }

    .site-logo-mark {
        width: 30px;
        height: 30px;
    }

    .nav-login,
    .nav-register,
    .nav-pill {
        padding: 10px 20px;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .paginator {
        text-align: center;
    }

    .table-responsive table {
        min-width: 640px;
    }

    .cart-page table,
    .checkout-table {
        min-width: 0;
    }

    .cart-page table,
    .cart-page thead,
    .cart-page tbody,
    .cart-page th,
    .cart-page td,
    .cart-page tr,
    .checkout-table,
    .checkout-table thead,
    .checkout-table tbody,
    .checkout-table th,
    .checkout-table td,
    .checkout-table tr {
        display: block;
    }

    .cart-page thead,
    .checkout-table thead {
        display: none;
    }

    .cart-page tr,
    .checkout-table tr {
        border: 1px solid #e1e6eb;
        border-radius: 1.4rem;
        padding: 1.2rem;
        margin-bottom: 1.2rem;
        background: #ffffff;
    }

    .cart-page td,
    .checkout-table td {
        border-bottom: 0;
        padding: 0.6rem 0;
    }

    .cart-page td::before,
    .checkout-table td::before {
        display: block;
        margin-bottom: 0.3rem;
        color: #667484;
        font-size: 1.25rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .cart-page td:nth-child(1)::before {
        content: "Image";
    }

    .cart-page td:nth-child(2)::before {
        content: "Listing";
    }

    .cart-page td:nth-child(3)::before {
        content: "Quantity";
    }

    .cart-page td:nth-child(4)::before {
        content: "Subtotal";
    }

    .checkout-table td:nth-child(1)::before {
        content: "Listing";
    }

    .checkout-table td:nth-child(2)::before {
        content: "Quantity";
    }

    .checkout-table td:nth-child(3)::before {
        content: "Subtotal";
    }

    .cart-page td:first-child,
    .cart-page th:first-child {
        width: auto;
    }

    .cart-image-frame {
        width: 100%;
        height: 150px;
    }

    .cart-page .qty-input {
        max-width: 140px;
    }

    .cart-page .actions,
    .cart-page .actions a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        text-align: center;
    }

    .cart-page .actions a {
        min-height: 58px;
        padding: 0 16px;
    }

    .cart-summary-bar,
    .cart-summary-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cart-summary-actions {
        width: 100%;
    }

    .cart-update-button,
    .cart-checkout-button {
        width: 100%;
        min-width: 0;
    }

    .cart-total {
        width: 100%;
    }

    .checkout-total {
        font-size: 1.7rem;
    }

    .checkout-return .button,
    .checkout-payment-card button {
        width: 100%;
    }
}

@media screen and (max-width: 640px) {
    /* Fix milligram not having a responsive column system */
    .row .column[class*='column-'] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .side-nav {
        margin-bottom: 1rem;
    }

    .heading {
        margin-bottom: 1rem;
    }

    .side-nav-item {
        display: inline;
        margin: 0 1.5rem 0 0;
    }

    .asc:after {
        content: " \2192";
    }

    .desc:after {
        content: " \2190";
    }
}
