/* ============================================================
   SEE Part Inventory — Mobile-First Stylesheet
   Domain: parts.see.com.sg
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --primary: #0a3d62;
    --accent: #1e90ff;
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #2c3e50;
    --muted: #7f8c8d;
    --border: #e1e8ed;
    --success: #27ae60;
    --radius: 10px;
    --tap-target: 44px;

    --cond-new-bg: #d4f5e2;
    --cond-new-fg: #18794e;
    --cond-refurb-bg: #dbeafe;
    --cond-refurb-fg: #1e40af;
    --cond-used-bg: #fef3c7;
    --cond-used-fg: #92400e;
    --cond-asis-bg: #e2e8f0;
    --cond-asis-fg: #1e293b;
    --cond-asis-border: #94a3b8;

    --wa-green: #25d366;
    --wa-green-dark: #1ebe5b;

    --sku-bg: #0a3d62;
    --sku-fg: #ffffff;

    --sold-out-bg: #dc2626;
    --sold-out-fg: #ffffff;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    font-size: 16px;
    overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { -webkit-touch-callout: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ============================================================
   HEADER + MOBILE NAV
   ============================================================ */
.header {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    min-height: 60px;
    position: relative;
    gap: 12px;
}
.logo a { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; }
.logo-mark {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    font-size: 20px;
    flex-shrink: 0;
}
.logo-text {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.logo-dot { color: var(--accent); }

.mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    width: var(--tap-target);
    height: var(--tap-target);
    border-radius: 8px;
    flex-shrink: 0;
    transition: background .2s;
}
.mobile-menu-toggle:active { background: rgba(255,255,255,0.25); }

.nav { display: flex; gap: 22px; align-items: center; }
.nav a {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    padding: 10px 4px;
    display: inline-block;
}
.nav a:hover { color: var(--accent); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
    background: linear-gradient(135deg, var(--primary), #1e5799);
    color: #fff;
    padding: 44px 16px;
    text-align: center;
}
.hero h1 {
    font-size: clamp(24px, 5.5vw, 38px);
    margin-bottom: 10px;
    line-height: 1.25;
}
.hero p {
    font-size: clamp(15px, 3.8vw, 18px);
    margin-bottom: 22px;
    opacity: 0.95;
    padding: 0 8px;
}
.search-bar {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    gap: 8px;
}
.search-bar input {
    flex: 1;
    padding: 14px 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    min-height: var(--tap-target);
}
.search-bar button {
    padding: 14px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    min-height: var(--tap-target);
    flex-shrink: 0;
}
.search-bar button:active { background: #0b7bd0; }

/* ============================================================
   FILTERS
   ============================================================ */
.filters {
    display: flex;
    gap: 12px;
    padding: 20px 16px 4px;
    flex-wrap: wrap;
    align-items: center;
}
.filters label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    flex: 1 1 auto;
    min-width: 140px;
}
.filters select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-size: 16px;
    min-height: var(--tap-target);
    width: 100%;
}

/* ============================================================
   CATALOG GRID
   ============================================================ */
.catalog { padding: 24px 16px 48px; }

.parts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.part-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s, opacity .2s;
    display: flex;
    flex-direction: column;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
}
.part-card:hover,
.part-card:active {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

/* ---------- SOLD OUT state ---------- */
.part-card.sold-out {
    cursor: not-allowed;
    opacity: 0.7;
    filter: grayscale(0.4);
}
.part-card.sold-out:hover,
.part-card.sold-out:active {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.part-card.sold-out .part-img {
    filter: grayscale(0.6) brightness(0.95);
}
.part-card.sold-out .part-name {
    color: #64748b;
}

.sold-out-ribbon {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--sold-out-bg);
    color: var(--sold-out-fg);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 5px 12px;
    border-bottom-left-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    z-index: 3;
    pointer-events: none;
}

/* CARD IMAGE — TRUE SHRINK-TO-FIT */
.part-img-wrap {
    position: relative;
    width: 100%;
    height: 200px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    padding: 12px;
}
.part-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    background: transparent;
}

.photo-count {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    pointer-events: none;
}

/* Info block — padding-top removed so SKU banner is flush to card top */
.part-info {
    padding: 0 0 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---------- SKU banner (top of card, full width) ---------- */
.part-sku {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: var(--sku-bg);
    color: var(--sku-fg);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    padding: 6px 14px;
    margin: 0 0 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.part-sku::before {
    content: "●";
    color: #7dd3fc;
    font-size: 9px;
    line-height: 1;
}

/* Padding for the rest of the info content */
.part-no,
.part-name,
.part-desc,
.part-meta,
.part-info > .stock,
.part-info > div[style] {
    padding-left: 16px;
    padding-right: 16px;
}

.part-no {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.part-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
}
.part-desc {
    font-size: 14px;
    color: var(--muted);
    margin: 6px 0 10px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.part-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.part-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* Price on Request style */
.price-por {
    color: #b45309;
    font-style: italic;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.2px;
}

/* ============================================================
   CONDITION BADGES
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.badge-new         { background: var(--cond-new-bg); color: var(--cond-new-fg); }
.badge-refurbished { background: var(--cond-refurb-bg); color: var(--cond-refurb-fg); }
.badge-used        { background: var(--cond-used-bg); color: var(--cond-used-fg); }
.badge-as-is {
    background: var(--cond-asis-bg);
    color: var(--cond-asis-fg);
    border: 1px dashed var(--cond-asis-border);
    font-style: italic;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.6px;
    padding: 3px 9px;
}

.stock { font-size: 13px; color: var(--muted); }
.stock.low { color: #d97706; font-weight: 600; }
.stock.out { color: #dc2626; font-weight: 700; }

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 17px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 200;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
}
.modal.active { display: block; }

.modal-content {
    background: #fff;
    max-width: 900px;
    margin: 0 auto;
    border-radius: var(--radius);
    position: relative;
    animation: slideUp .3s ease;
    overflow: hidden;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: none; }
}

.close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    background: rgba(0,0,0,0.5);
    width: var(--tap-target);
    height: var(--tap-target);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: none;
}
.close:active { background: rgba(0,0,0,0.8); }

.modal-body { padding: 0; }

.gallery-main {
    position: relative;
    background: #f8fafc;
    height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-header-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    background: transparent;
}
.gallery-counter {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
}

.gallery-thumbs {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.gallery-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    transition: border-color .15s, transform .15s;
}
.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gallery-thumb.active { border-color: var(--accent); }
.gallery-thumb:active { transform: scale(0.95); }

.modal-details { padding: 22px 20px 26px; }
.modal-details h2 {
    font-size: clamp(20px, 5vw, 26px);
    margin-bottom: 4px;
    line-height: 1.3;
    padding-right: 8px;
}
.modal-partno {
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 18px;
    font-size: 14px;
    word-break: break-word;
}

.modal-sku {
    background: #e0f2fe;
    color: #075985;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 6px;
    letter-spacing: 0.4px;
}

.spec-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 16px 0;
}
.spec-item {
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.spec-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.5px;
    font-weight: 700;
}
.spec-value {
    font-size: 15px;
    font-weight: 600;
    margin-top: 2px;
    word-break: break-word;
}

.terms-box {
    background: #fff8e6;
    border-left: 4px solid #f0b429;
    padding: 14px 16px;
    border-radius: 6px;
    margin-top: 18px;
    font-size: 14px;
}
.terms-box h4 { margin-bottom: 8px; color: #92400e; font-size: 15px; }
.terms-box ul { padding-left: 18px; color: #555; }
.terms-box li { margin-bottom: 4px; }

.action-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 18px;
    border-radius: 8px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap-target);
    flex: 1 1 auto;
    text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: #062a45; }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:active { background: #0b7bd0; }
.btn-outline { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:active { background: var(--primary); color: #fff; }

.btn-whatsapp { background: var(--wa-green); color: #fff; }
.btn-whatsapp:active { background: var(--wa-green-dark); }

/* ============================================================
   SECTIONS
   ============================================================ */
.contact {
    padding: 48px 16px;
    text-align: center;
    background: #fff;
}
.contact h2 {
    font-size: clamp(22px, 5vw, 30px);
    margin-bottom: 14px;
    color: var(--primary);
}
.contact p {
    max-width: 700px;
    margin: 0 auto 8px;
    color: var(--muted);
    font-size: 16px;
}
.contact a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.contact a:hover { text-decoration: underline; }

.whatsapp-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    padding: 14px 26px;
    border-radius: 30px;
    background: var(--wa-green);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
    min-height: var(--tap-target);
    transition: background .2s, transform .15s;
}
.whatsapp-cta:hover { background: var(--wa-green-dark); text-decoration: none; }
.whatsapp-cta:active { transform: scale(0.97); }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    background: var(--primary);
    color: #fff;
    text-align: center;
    padding: 22px 16px;
    font-size: 14px;
}
.footer a { color: var(--accent); text-decoration: none; }

/* ============================================================
   BACK TO TOP
   ============================================================ */
.back-to-top {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity .25s ease, transform .25s ease, visibility .25s, background .2s;
    z-index: 150;
}
.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover,
.back-to-top:active {
    background: var(--accent);
}
.back-to-top:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary);
        flex-direction: column;
        padding: 12px 16px 16px;
        gap: 4px;
        box-shadow: 0 8px 16px rgba(0,0,0,0.2);
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    .nav.open { display: flex; }
    .nav a {
        padding: 14px 12px;
        border-radius: 8px;
        font-size: 16px;
        width: 100%;
    }
    .nav a:active { background: rgba(255,255,255,0.12); }

    .logo-text { font-size: 15px; }
    .logo-mark { width: 32px; height: 32px; font-size: 18px; }

    .parts-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .part-img-wrap { height: 150px; padding: 8px; }
    .part-info  { padding: 0 0 12px; }
    .part-name  { font-size: 15px; }
    .part-desc  { font-size: 13px; }
    .part-price { font-size: 16px; }
    .price-por  { font-size: 13px; }
    .badge      { font-size: 11px; padding: 2px 8px; }
    .badge-as-is { font-size: 10px; padding: 2px 7px; }
    .photo-count { font-size: 11px; padding: 2px 7px; bottom: 6px; right: 6px; }

    .part-sku {
        font-size: 10px;
        padding: 5px 12px;
        letter-spacing: 0.5px;
    }
    .part-no,
    .part-name,
    .part-desc,
    .part-meta,
    .part-info > .stock,
    .part-info > div[style] {
        padding-left: 12px;
        padding-right: 12px;
    }

    .sold-out-ribbon {
        font-size: 9px;
        padding: 4px 10px;
        letter-spacing: 1px;
    }

    .search-bar { flex-direction: column; }
    .search-bar input,
    .search-bar button { width: 100%; border-radius: 8px; }

    .modal { padding: 0; }
    .modal-content {
        border-radius: 0;
        min-height: 100vh;
        animation: none;
    }
    .gallery-main { height: 300px; padding: 10px; }
    .gallery-thumb { width: 56px; height: 56px; }
    .spec-grid { grid-template-columns: 1fr; }
    .action-row { flex-direction: column; }
    .action-row .btn { width: 100%; flex: 1 1 100%; }

    .back-to-top {
        width: 44px;
        height: 44px;
        right: 14px;
        bottom: 14px;
        font-size: 20px;
    }
}

@media (max-width: 400px) {
    .parts-grid { grid-template-columns: 1fr; }
    .part-img-wrap { height: 220px; padding: 10px; }
    .logo-text  { font-size: 13px; }
    .logo-mark  { width: 28px; height: 28px; font-size: 16px; }
}

@media (min-width: 992px) {
    .parts-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
    .part-img-wrap { height: 220px; padding: 14px; }
    .gallery-main { height: 420px; }
    .modal { padding: 40px 20px; }
    .modal-content { border-radius: var(--radius); min-height: auto; }
    .action-row .btn { flex: 0 0 auto; }
}

@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    .hero { padding: 24px 16px; }
    .gallery-main { height: 220px; }
}

body.modal-open { overflow: hidden; position: fixed; width: 100%; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}