* {
    box-sizing: border-box;
}

:root {
    --text: #222;
    --muted: #666;
    --line: #e3e3e3;
    --soft: #f5f5f5;
    --page-width: 1100px;
    --header-height: 60px;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: Arial, "Helvetica Neue", sans-serif;
    background: white;
    color: var(--text);

    /* keeps the footer at the bottom on short pages */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 16px 30px;
}

a {
    color: inherit;
}

.hidden {
    display: none !important;
}


/* HEADER */

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid #ddd;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    height: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 16px;
}

.site-name {
    font-size: 18px;
    font-weight: bold;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.header-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    background: white;
    color: var(--text);
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
}

.header-button:active {
    background: #eee;
}

/* phone number / email text only on wide screens; icons only on phones */
.contact-text {
    display: none;
    font-weight: normal;
}

@media (min-width: 900px) {
    .contact-text {
        display: inline;
    }
    .contact-link {
        border-color: transparent;
    }
    .contact-link:hover .contact-text {
        text-decoration: underline;
    }
}

@media (max-width: 370px) {
    .site-name {
        font-size: 15px;
    }
    .header-inner {
        padding: 0 10px;
    }
    .header-controls {
        gap: 4px;
    }
    .header-button {
        min-width: 34px;
        height: 34px;
        padding: 0 6px;
    }
}


/* PREVIEW BANNER (admin preview only) */

#preview-banner {
    background: #fff3c4;
    color: #5a4500;
    text-align: center;
    font-weight: bold;
    padding: 8px 16px;
    font-size: 14px;
}


/* FOOTER */

.site-footer {
    border-top: 1px solid #ddd;
    background: #fafafa;
    font-size: 15px;
}

.footer-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 20px 16px 28px;
}

.footer-inner p {
    margin: 6px 0;
}

.footer-name {
    font-weight: bold;
}

.footer-inner h2 {
    font-size: 15px;
    margin: 14px 0 6px;
    color: var(--muted);
}


/* SEARCH */

.search-container {
    position: sticky;
    top: var(--header-height);
    z-index: 900;
    padding: 16px 0;
    background: white;
}

#search {
    width: 100%;
    padding: 14px;
    font-size: 16px;   /* 16px stops iPhones from zooming in */
    font-family: inherit;
    border: 1px solid #ccc;
    border-radius: 6px;
}


/* HOME PAGE: keep it a comfortable column on desktop */

.home-page {
    max-width: 720px;
}


/* TABS */

.tabs {
    display: flex;
    border-bottom: 1px solid #ccc;
    margin-bottom: 10px;
}

.tab {
    flex: 1;
    padding: 14px 10px;
    background: white;
    border: none;
    border-bottom: 3px solid transparent;
    font-family: inherit;
    font-size: 16px;
    color: var(--text);
    cursor: pointer;
}

.tab.active {
    font-weight: bold;
    border-bottom-color: var(--text);
}


/* LIST */

.list-item {
    display: block;
    padding: 18px 10px;
    text-decoration: none;
    border-bottom: 1px solid #eee;
    font-size: 18px;
}

.list-item:active,
.list-item:hover {
    background: var(--soft);
}


/* SEARCH RESULTS (home page) */

.search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    text-decoration: none;
}

.search-result:active {
    background: var(--soft);
}

.search-result img,
.search-result .no-image {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    object-fit: contain;
    border: 1px solid #eee;
    border-radius: 4px;
}

.search-result-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.search-result-name {
    font-size: 17px;
    font-weight: bold;
}

.search-result-meta {
    color: var(--muted);
    font-size: 14px;
}

.no-results,
.load-error {
    padding: 20px 0;
}

.no-image {
    display: block;
    background: var(--soft);
}


/* BACK BUTTON */

.back-button {
    display: inline-block;
    padding: 14px 0 6px;
    text-decoration: none;
}


/* CATEGORY PAGE */

.category-page h1 {
    margin: 6px 0 0;
    font-size: 26px;
}

.sort-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 15px;
}

.sort-bar label {
    color: var(--muted);
    white-space: nowrap;
}

#sort-select {
    flex: 1;
    max-width: 260px;
    padding: 9px 8px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
}


/* PRODUCT GRID: 2 columns on phones, 3 on tablets, 4 on desktop */

#product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 640px) {
    #product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (min-width: 960px) {
    #product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

#product-grid .no-results {
    grid-column: 1 / -1;
}

.product-card {
    display: block;
    min-width: 0;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
}

.product-card:active {
    background: var(--soft);
}

@media (hover: hover) {
    .product-card:hover {
        border-color: #aaa;
    }
}

.product-card img,
.product-card .no-image {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    margin-bottom: 8px;
}

.product-card h2 {
    font-size: 15px;
    margin: 0 0 4px;
    overflow-wrap: anywhere;
}

.product-card p {
    font-size: 14px;
    margin: 0;
}

.card-brand {
    color: var(--muted);
}

.card-price {
    font-weight: bold;
    margin-top: 4px !important;
}


/* PRODUCT PAGE */

.product-gallery {
    position: relative;
    margin: 10px 0 20px;
}

/* photos side by side; swipe left/right on phones */
.gallery-track {
    display: flex;
    direction: ltr;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-radius: 6px;
}

.gallery-track::-webkit-scrollbar {
    display: none;
}

.gallery-slide {
    flex: 0 0 100%;
    scroll-snap-align: start;
}

.gallery-slide img,
.product-gallery .no-image {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.carousel-button {
    position: absolute;
    top: calc(50% - 30px);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #ccc;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    border-radius: 50%;
    cursor: pointer;
}

.carousel-previous {
    left: 8px;
}

.carousel-next {
    right: 8px;
}

.gallery-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
    direction: ltr;
    margin-top: 6px;
}

.gallery-dot {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    position: relative;
}

.gallery-dot::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: #ccc;
}

.gallery-dot.active::after {
    background: var(--text);
}

.product-title {
    margin: 0 0 5px;
    font-size: 24px;
    overflow-wrap: anywhere;
}

.product-brand {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 17px;
}

.product-item-number {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 14px;
}

.product-price {
    font-size: 22px;
    font-weight: bold;
    margin: 0 0 20px;
}

.product-section {
    border-top: 1px solid #eee;
    padding: 18px 0;
}

.product-section h2 {
    font-size: 18px;
    margin: 0 0 10px;
}

.product-description {
    line-height: 1.6;
    margin: 0;
    white-space: pre-line;   /* keeps the admin's line breaks */
}

.product-specs {
    margin: 0;
}

.product-specs div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.product-specs dt {
    font-weight: bold;
}

.product-specs dd {
    margin: 0;
    text-align: end;
}

/* desktop: photos beside the details */
@media (min-width: 800px) {
    .product-page {
        max-width: 1000px;
    }

    #product-detail {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 40px;
        align-items: start;
    }

    .product-gallery {
        position: sticky;
        top: calc(var(--header-height) + 16px);
        margin-top: 10px;
    }

    .product-info {
        padding-top: 10px;
    }

    .product-title {
        font-size: 28px;
    }
}
