/*
Theme Name: Mashallah Electronics
Theme URI: https://mashallahelectronics.com
Author: Mashallah Electronics
Description: Custom product catalog + WhatsApp inquiry theme for Mashallah Electronics. No WooCommerce, no checkout — product browsing with category/brand/price/availability filtering and a WhatsApp inquiry button per product.
Version: 0.3.0
Requires PHP: 7.4
Text Domain: mashallah-electronics
*/

/* ==========================================================================
   MOBILE-FIRST: every rule below is written for small screens by default.
   Desktop/tablet enhancements live inside `@media (min-width: 768px)` and
   `@media (min-width: 1024px)` blocks further down — nothing above those
   breakpoints should be assumed. If you add a new section to a template,
   write its mobile layout here first, then widen it in the breakpoints.
   ========================================================================== */

:root {
    --me-red: #d92027;
    --me-red-dark: #b3181e;
    --me-dark: #1a1a1a;
    --me-gray: #6b6b6b;
    --me-light-bg: #f7f7f7;
    --me-border: #e5e5e5;
    --me-radius: 10px;
    --me-max-width: 1200px;
    --me-tap: 44px; /* minimum comfortable tap target */
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--me-dark);
    background: #fff;
    line-height: 1.5;
    font-size: 16px; /* never smaller sitewide — keeps mobile Safari from auto-zooming on form inputs */
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.5rem, 6vw, 2.25rem); }
h2 { font-size: clamp(1.25rem, 5vw, 1.75rem); }
h3 { font-size: 1.05rem; }

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

/* ==========================================================================
   Buttons — full-width and thumb-friendly by default; desktop can opt into
   inline width via .btn-inline where a template wants it.
   ========================================================================== */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--me-tap);
    padding: 12px 20px;
    border-radius: var(--me-radius);
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    text-align: center;
}
.btn-inline { display: inline-flex; width: auto; }

.btn-primary {
    background: var(--me-red);
    color: #fff;
}
.btn-primary:hover { background: var(--me-red-dark); }

.btn-whatsapp {
    background: #25D366;
    color: #fff;
    gap: 8px;
    font-size: 1rem;
}
.btn-whatsapp:hover { background: #1ebe5b; }

/* ==========================================================================
   Layout helpers — mobile-first: stacked by default, row on desktop.
   Use these instead of one-off inline flex/grid styles in templates so
   this stylesheet stays the single source of truth for responsiveness.
   ========================================================================== */
.me-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.me-stack-tight { gap: 12px; }

.me-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.me-grid-auto {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
    border-bottom: 1px solid var(--me-border);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 50;
}

.site-header .top-bar {
    background: var(--me-red);
    color: #fff;
    font-size: 0.75rem;
    padding: 6px 0;
}
.site-header .top-bar .container {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.site-header .main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    flex-wrap: wrap;
}

.site-header .main-nav ul {
    list-style: none;
    display: flex;
    gap: 0;
    margin: 0;
    padding: 0;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.site-logo img { max-height: 36px; width: auto; }
.site-logo .custom-logo-link { display: flex; align-items: center; flex-shrink: 0; }
.me-site-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--me-dark);
    white-space: nowrap;
}

.me-mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--me-tap);
    height: var(--me-tap);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
}

.me-primary-nav {
    display: none;
    width: 100%;
    order: 3;
}
.me-primary-nav.is-open { display: block; }
.me-primary-nav ul {
    flex-direction: column;
    width: 100%;
}
.me-primary-nav ul li { border-top: 1px solid var(--me-border); }
.me-primary-nav ul li a {
    display: block;
    padding: 14px 4px;
    min-height: var(--me-tap);
}

/* Header's own WhatsApp button collapses to an icon-only tap target on
   mobile so the header stays compact — full label returns on desktop. */
.site-header .main-nav > a.btn {
    width: var(--me-tap);
    padding: 0;
    flex-shrink: 0;
}
.site-header .main-nav > a.btn .me-btn-label { display: none; }

/* ==========================================================================
   Floating mobile WhatsApp button — the "authentic local shop app" touch;
   always reachable while scrolling, hidden on desktop where the header
   button already does the job.
   ========================================================================== */
.me-floating-whatsapp {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    font-size: 1.6rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    z-index: 60;
}

/* ==========================================================================
   Homepage category tiles — flex-wrap + centered instead of grid, so a
   leftover item on the last row centers itself rather than sticking to
   the left edge.
   ========================================================================== */
.me-categories-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}
.me-category-item {
    flex: 1 1 140px;
    max-width: 160px;
    text-align: center;
    border: 1px solid var(--me-border);
    border-radius: var(--me-radius);
    padding: 16px 10px;
}

/* ==========================================================================
   Homepage branches grid — sized so all 4 branch cards fit on one row on
   desktop instead of wrapping to a second line.
   ========================================================================== */
.me-branches-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 24px;
}
.me-branches-item {
    flex: 1 1 140px;
    max-width: 160px;
    text-align: center;
    border: 1px solid var(--me-border);
    border-radius: var(--me-radius);
    padding: 16px 10px;
}

/* ==========================================================================
   Product grid (used by archive + related products + homepage) — 2 tight
   columns on mobile like a native shopping app; widens on desktop.
   ========================================================================== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.product-card {
    border: 1px solid var(--me-border);
    border-radius: var(--me-radius);
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
}
.product-card .product-title { min-height: 2.4em; }

.product-card .price {
    color: var(--me-red);
    font-weight: 700;
    font-size: 1rem;
}

.stock-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    margin-top: 4px;
}
.stock-badge.in-stock { background: #e6f7ee; color: #1a7f4e; }
.stock-badge.out-of-stock { background: #fdecec; color: var(--me-red); }

/* ==========================================================================
   Archive filters — a bottom-sheet style drawer on mobile (toggled by a
   "Filters" button), a static sidebar on desktop.
   ========================================================================== */
.me-archive-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 0;
}

.me-filter-toggle {
    display: flex;
    width: 100%;
}

.me-filters {
    display: none;
    width: 100%;
    background: #fff;
    border: 1px solid var(--me-border);
    border-radius: var(--me-radius);
    padding: 16px;
}
.me-filters.is-open { display: block; }
.me-filters h3 { margin: 14px 0 6px; }
.me-filters h3:first-child { margin-top: 0; }
.me-filters select,
.me-filters input {
    width: 100%;
    min-height: var(--me-tap);
    padding: 10px 12px;
    border: 1px solid var(--me-border);
    border-radius: var(--me-radius);
    font-size: 1rem;
    margin-bottom: 8px;
}

.me-results { flex-grow: 1; min-width: 0; }

/* ==========================================================================
   Single product — gallery over info on mobile, side-by-side on desktop.
   ========================================================================== */
.me-product-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.me-gallery-thumbs { -webkit-overflow-scrolling: touch; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    background: var(--me-dark);
    color: #ccc;
    padding: 32px 0 16px;
}
.site-footer .me-stack { gap: 28px; }

/* ==========================================================================
   Tablet and up (768px+)
   ========================================================================== */
@media (min-width: 768px) {
    .container { padding: 0 24px; }

    .btn { width: auto; }
    .btn-whatsapp { width: 100%; } /* keep full-width where the template wants full-width WhatsApp CTAs, e.g. product page */

    .me-grid-auto { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; }
    .me-branches-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .me-hero-actions { flex-direction: row; }
    .me-stack { flex-direction: row; }

    .me-mobile-menu-toggle { display: none; }
    .me-primary-nav { display: block !important; width: auto; order: 0; }
    .me-primary-nav ul { flex-direction: row; gap: 0; align-items: center; }
    .me-primary-nav ul li {
        border-top: none;
        position: relative;
        padding: 0 18px;
    }
    .me-primary-nav ul li:first-child { padding-left: 0; }
    .me-primary-nav ul li:last-child { padding-right: 0; }
    .me-primary-nav ul li:not(:last-child)::after {
        content: "";
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 14px;
        background: var(--me-border);
    }
    .me-primary-nav ul li a {
        padding: 0;
        min-height: 0;
        font-weight: 600;
        font-size: 0.92rem;
        color: var(--me-dark);
        transition: color 0.15s ease;
    }
    .me-primary-nav ul li a:hover,
    .me-primary-nav ul li.current-menu-item > a,
    .me-primary-nav ul li.current_page_item > a {
        color: var(--me-red);
    }

    .site-header .main-nav > a.btn {
        width: auto;
        padding: 12px 20px;
    }
    .site-header .main-nav > a.btn .me-btn-label { display: inline; }

    .me-floating-whatsapp { display: none; }

    .product-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
    .product-card { padding: 16px; }

    .me-archive-layout { flex-direction: row; align-items: flex-start; gap: 30px; padding: 30px 0; }
    .me-filter-toggle { display: none; }
    .me-filters {
        display: block;
        width: 240px;
        flex-shrink: 0;
        border: none;
        padding: 0;
    }

    .me-product-layout { flex-direction: row; flex-wrap: wrap; }
    .me-product-gallery { flex: 1 1 400px; max-width: 500px; }
    .me-product-info { flex: 1 1 350px; }
}

/* ==========================================================================
   Desktop (1024px+)
   ========================================================================== */
@media (min-width: 1024px) {
    .site-header .top-bar { font-size: 0.85rem; padding: 8px 0; }

    .me-branches-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
}
