/* ==========================================================================
   Speedparts — Main Stylesheet
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }

.impersonate-bar {
    background: #c62828;
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.85rem;
    position: sticky;
    top: 0;
    z-index: 9999;
}
.impersonate-bar a {
    color: #fff;
    text-decoration: underline;
    margin-left: 16px;
    font-weight: 600;
}

/* Color semantics — shop-facing tokens:
   --brand / --brand-hover Logo cyan (#5aa6b0) darkened so text and fills clear WCAG.
                           Same hue as the wordmark and the diagram plates.
   --red / --red-hover     Alias of --brand. Older rules still say --red.
   --danger                Errors, out of stock, destructive. Stays red.
   --green / --green-hover Purchase / go CTAs only
   --dark / --black        Neutral form actions (btn-primary)
   btn-danger              Destructive actions (unchanged) */
:root {
    --black:      #1a1a1a;
    --dark:       #2c2c2c;
    --mid:        #555;
    --border:     #ddd;
    --bg:         #f5f5f5;
    --white:      #fff;
    --brand:      #0f6470;
    --brand-hover:#0a4c56;
    --red:        var(--brand);
    --red-hover:  var(--brand-hover);
    --danger:     #c62828;
    --green:      #2e7d32;
    --green-hover:#1b5e20;
    --max-width:  1200px;
}

html { font-size: 16px; }
body { font-family: Arial, Helvetica, sans-serif; color: var(--black); background: var(--bg); line-height: 1.5; }
a { color: var(--black); text-decoration: none; }
a:hover { color: var(--red); }
img { max-width: 100%; height: auto; display: block; }

/* ==========================================================================
   Layout
   ========================================================================== */

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }

/* ==========================================================================
   Main content
   ========================================================================== */

.site-main { padding: 24px 0 48px; }

.btn-buy {
    display: block;
    width: 100%;
    padding: 7px;
    background: var(--green);
    color: var(--white);
    border: none;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: background 0.15s;
}
.btn-buy:hover { background: var(--green-hover); color: var(--white); }
.btn-buy:disabled { background: #aaa; cursor: not-allowed; }

/* Pagination */
.pagination {
    display: flex;
    gap: 10px;
    align-items: center;
}
.pagination-info { color: var(--mid); font-size: 0.875rem; }
.result-count { color: var(--mid); font-size: 0.875rem; margin-bottom: 16px; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-block;
    padding: 9px 20px;
    border-radius: 3px;
    font-size: 0.875rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}
.btn-primary { background: var(--dark); color: var(--white); }
.btn-primary:hover { background: var(--black); color: var(--white); }
.btn-cta { background: var(--green); color: var(--white); }
.btn-cta:hover { background: var(--green-hover); color: var(--white); }
.btn-secondary { background: var(--dark); color: var(--white); }
.btn-secondary:hover { background: var(--black); color: var(--white); }
.btn-outline { background: transparent; border: 2px solid var(--red); color: var(--red); }
.btn-outline:hover { background: var(--red); color: var(--white); }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* ==========================================================================
   Order confirmation
   ========================================================================== */

.order-confirm-header {
    text-align: center;
    padding: 32px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}
.order-confirm-check {
    width: 64px;
    height: 64px;
    background: var(--green);
    color: var(--white);
    border-radius: 50%;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.order-confirm-header h1 { font-size: 1.6rem; margin-bottom: 8px; }
.order-confirm-header p  { color: var(--mid); }
.order-summary-box {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 24px;
    max-width: 700px;
    margin: 0 auto;
}
.order-address { background: var(--bg); padding: 12px; border-radius: 3px; font-size: 0.875rem; }
.order-items-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 0.9rem; }
.order-items-table th,
.order-items-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.order-items-table th { font-size: 0.8rem; color: var(--mid); text-transform: uppercase; }
.order-items-table tfoot td { border-bottom: none; border-top: 2px solid var(--border); font-size: 1rem; }

/* ==========================================================================
   Stock badge
   ========================================================================== */

.stock-in    { color: var(--green); font-size: 0.8rem; }
.stock-out   { color: var(--danger); font-size: 0.8rem; }
.stock-order { color: var(--mid);   font-size: 0.8rem; }

/* ==========================================================================
   Flash messages
   ========================================================================== */

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}
.alert-success { background: #e8f5e9; border: 1px solid #a5d6a7; color: var(--green); }
.alert-error   { background: #ffebee; border: 1px solid #ef9a9a; color: var(--danger); }
.alert-info    { background: #e3f2fd; border: 1px solid #90caf9; color: #1565c0; }

/* ==========================================================================
   Utility
   ========================================================================== */

.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ==========================================================================
   Product detail page
   ========================================================================== */

.product-admin-edit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-left: 6px;
    vertical-align: middle;
    font-size: 0.82rem;
    line-height: 1;
    color: var(--mid);
    text-decoration: none;
    border-radius: 3px;
    opacity: 0.45;
    transition: opacity .15s, color .15s, background .15s;
}
.product-admin-edit:hover,
.product-admin-edit:focus {
    opacity: 1;
    color: var(--red);
    background: rgba(15, 100, 112, 0.08);
}
.product-admin-edit[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    min-width: 140px;
    max-width: 240px;
    padding: .4rem .55rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #1a1a1a;
    color: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
    font-size: .75rem;
    font-weight: 400;
    line-height: 1.35;
    white-space: normal;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .12s ease, visibility .12s ease;
    z-index: 40;
}
.product-admin-edit[data-tip]:hover::after,
.product-admin-edit[data-tip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
}
.product-admin-box {
    margin: 0 0 12px;
    padding: 8px 10px;
    border-left: 2px solid var(--red);
    background: rgba(15, 100, 112, 0.05);
}
.product-admin-box-tag {
    position: relative;
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--red);
    cursor: default;
}
.product-admin-box-tag[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    padding: 4px 8px;
    background: var(--black);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    border-radius: 3px;
    opacity: 0;
    pointer-events: none;
    z-index: 40;
}
.product-admin-box-tag[data-tip]:hover::after,
.product-admin-box-tag[data-tip]:focus-visible::after { opacity: 1; }
.product-admin-box-line { margin-top: 4px; font-size: 0.85rem; }
.product-hedin-admin-inline {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--red);
}
.cart-price-was      { font-size: 0.85rem; color: var(--mid); text-decoration: line-through; }
.club-verify-status  { font-size: 0.9rem; margin: 0 0 1rem; padding: 0.5rem 0.75rem; border-radius: 4px; }
.club-verify-verified { background: #e8f5e9; color: #2e7d32; }
.club-verify-pending  { background: #fff8e1; color: #f57f17; }
.club-verify-failed   { background: #ffebee; color: #c62828; }
.club-verify-note     { display: block; font-size: 0.85rem; margin-top: 0.25rem; opacity: 0.9; }

/* Compatibility table (parsed from Abicart description field) */
.compat-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.compat-table th,
.compat-table td { padding: 5px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.compat-table th { width: 30%; background: var(--bg-alt, #f5f5f5); font-weight: 600; white-space: nowrap; }
.compat-model th { border-top: 2px solid var(--border); }
.compat-detail th { font-weight: normal; color: var(--mid); padding-left: 18px; }
.compat-chassis th { font-style: italic; color: var(--mid); }
.compat-qty th { color: var(--mid); }
.compat-freetext { font-size: 0.8rem; color: var(--mid); padding: 4px 10px; }

/* ==========================================================================
   Static info pages
   ========================================================================== */

.page-content { max-width: 820px; }
.page-title { font-size: 1.75rem; margin-bottom: 1.25rem; line-height: 1.2; }
.page-meta { margin-top: 2rem; font-size: .8rem; color: var(--mid); border-top: 1px solid var(--border); padding-top: .75rem; }

/* Body content from scraped HTML */
.page-body { line-height: 1.7; color: var(--text); }
.page-body h2 { font-size: 1.25rem; margin-top: 1.75rem; }
.page-body h3 { font-size: 1.05rem; margin-top: 1.25rem; }
.page-body p  { margin-bottom: .85rem; }
.page-body ul,
.page-body ol { padding-left: 1.5rem; margin-bottom: .85rem; }
.page-body li { margin-bottom: .3rem; }
.page-body a  { color: var(--red); }
.page-body a:hover { text-decoration: underline; }
.page-body table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.page-body td,
.page-body th  { border: 1px solid var(--border); padding: 8px 12px; font-size: .9rem; }
.page-body th  { background: var(--border); font-weight: 600; }

/* Stub pages */
.stub-notice { background: var(--card-bg, #fff); border: 1px solid var(--border); border-radius: 8px; padding: 2rem; max-width: 540px; margin-top: 1rem; }
.stub-notice p { margin-bottom: .75rem; }
.stub-notice .btn { margin-top: .5rem; }

/* ==========================================================================
   Touch targets + iOS zoom prevention
   ========================================================================== */

input, select, textarea { font-size: max(16px, 1rem); }

.btn { min-height: 44px; }

/* ==========================================================================
   Responsive — 640px (mobile)
   ========================================================================== */

@media (max-width: 640px) {
    /* Cart */
    .cart-actions { flex-direction: column; gap: 8px; }
    .cart-actions .btn { width: 100%; text-align: center; }
    .cart-img-cell { display: none; }

    /* Pagination */
    .pagination { flex-wrap: wrap; justify-content: center; gap: 6px; }

    h1 { font-size: 1.4rem; }

    /* Order confirm */
    .order-summary-box { padding: 16px; }

    /* Account responsive */
    .profile-layout { grid-template-columns: 1fr; }
    .wishlists-layout { grid-template-columns: 1fr; }
    .account-tabs { overflow-x: auto; }
    .wishlist-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .wishlist-actions { flex-direction: column; width: 100%; }
}

/* ==========================================================================
   Customer auth pages
   ========================================================================== */

.auth-page {
    display: flex;
    justify-content: center;
    padding: 32px 0;
}
.auth-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 36px 32px;
    width: 100%;
    max-width: 440px;
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 24px; }
.auth-subtitle { color: var(--mid); font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; }
.auth-links {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.875rem;
    color: var(--mid);
}
.auth-links a { color: var(--dark); }
.auth-links a:hover { color: var(--red); }
.auth-sep { padding: 0 8px; color: var(--border); }

/* ==========================================================================
   Forms (shared)
   ========================================================================== */

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--dark);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
    color: var(--black);
    background: var(--white);
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 2px rgba(204,0,0,0.08);
}
.form-group input:disabled {
    background: var(--bg);
    color: var(--mid);
    cursor: not-allowed;
}
.form-hint { display: block; font-size: 0.78rem; color: var(--mid); margin-top: 4px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-check { margin-bottom: 16px; }
.form-check label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.875rem;
    cursor: pointer;
}
.form-check input[type="checkbox"] { margin-top: 3px; accent-color: var(--red); }

.btn-full { width: 100%; text-align: center; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; min-height: 36px; }
.btn-danger { background: #c62828; color: var(--white); }
.btn-danger:hover { background: #a31c1c; color: var(--white); }
.input-sm { padding: 6px 10px; font-size: 0.85rem; border: 1px solid var(--border); border-radius: 4px; }

/* ==========================================================================
   Account page
   ========================================================================== */

.account-page { padding-bottom: 32px; }
.account-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.account-header h1 { margin: 0; }

.account-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 28px;
}
.account-tab {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--mid);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.account-tab:hover { color: var(--black); }
.account-tab.active { color: var(--red); border-bottom-color: var(--red); }

.empty-state { color: var(--mid); font-size: 0.95rem; padding: 24px 0; }

/* Orders table */
.orders-table-wrap { overflow-x: auto; }
.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.orders-table th {
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--mid);
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
}
.orders-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.orders-table .text-right { text-align: right; }
.order-number { font-weight: 600; white-space: nowrap; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.status-pending   { background: #fff3e0; color: #e65100; }
.status-paid      { background: #e8f5e9; color: var(--green); }
.status-shipped   { background: #e3f2fd; color: #1565c0; }
.status-cancelled { background: #fbe9e7; color: #c62828; }
.status-refunded  { background: #f3e5f5; color: #6a1b9a; }

/* Profile layout */
.profile-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 32px;
    align-items: start;
}
.profile-layout h2 { margin-bottom: 20px; font-size: 1.2rem; }
.profile-layout h3 { margin: 24px 0 12px; font-size: 1rem; }

.delivery-fields {
    margin-top: 16px;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.delivery-fields h3 { margin-top: 0 !important; }

.side-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 16px;
}
.side-card h3 { margin: 0 0 12px; font-size: 1rem; }
.side-card p { font-size: 0.875rem; color: var(--mid); margin-bottom: 8px; line-height: 1.5; }
.side-card-danger { border-color: #ef9a9a; }
.side-card-danger h3 { color: #c62828; }

/* Wishlists */
.wishlists-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 28px;
    align-items: start;
}
.wishlists-sidebar h2 { font-size: 1.1rem; margin-bottom: 12px; }
.wishlist-list {
    list-style: none;
    margin-bottom: 16px;
}
.wishlist-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background 0.15s;
}
.wishlist-list li a:hover { background: var(--bg); }
.wishlist-list li.active a { background: var(--red); color: var(--white); font-weight: 600; }
.wishlist-list li.active a:hover { background: var(--red-hover); color: var(--white); }
.wishlist-count {
    background: var(--bg);
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mid);
}
.wishlist-list li.active .wishlist-count { background: rgba(255,255,255,0.2); color: var(--white); }

.wishlist-create-form {
    display: flex;
    gap: 8px;
}
.wishlist-create-form input { flex: 1; }
.wishlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.wishlist-header h3 { margin: 0; }
.wishlist-actions { display: flex; gap: 8px; align-items: center; }

/* Order detail */
.back-link {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 0.875rem;
    color: var(--mid);
}
.back-link:hover { color: var(--red); }
.order-meta {
    display: flex;
    gap: 32px;
    margin: 16px 0 24px;
    flex-wrap: wrap;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 0.78rem; text-transform: uppercase; color: var(--mid); letter-spacing: 0.04em; }
.meta-value { font-size: 0.95rem; font-weight: 600; }
.order-address { margin-bottom: 24px; }
.order-address h3 { font-size: 0.95rem; margin-bottom: 4px; }
.order-address p { font-size: 0.9rem; line-height: 1.6; color: var(--dark); }
.order-totals {
    margin-top: 16px;
    max-width: 320px;
    margin-left: auto;
}
.total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}
.total-final { font-weight: 700; font-size: 1.05rem; border-bottom: 2px solid var(--dark); }

/* ==========================================================================
   Cookie consent banner (GDPR / GA4)
   ========================================================================== */

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
    padding: 14px 20px;
    background: var(--black);
    color: #e8e8e8;
    font-size: 0.875rem;
    line-height: 1.45;
    border-top: 1px solid #333;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.cookie-banner-text {
    flex: 1 1 240px;
    margin: 0;
    max-width: 52rem;
}

.cookie-banner-link {
    color: #fff;
    text-decoration: underline;
    margin-left: 0.35em;
    white-space: nowrap;
}

.cookie-banner-link:hover {
    color: #f5c6c6;
}

.cookie-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.cookie-banner-actions .btn {
    min-width: 9rem;
    font-weight: 600;
}

.cookie-banner-btn-reject {
    background: transparent;
    color: #fff;
    border: 2px solid #fff;
}

.cookie-banner-btn-reject:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.footer-link-btn {
    display: block;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}

.footer-link-btn:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .cookie-banner {
        padding: 12px 16px;
    }
    .cookie-banner-actions {
        width: 100%;
    }
    .cookie-banner-actions .btn {
        flex: 1 1 auto;
        min-width: 0;
    }
}
