/* ============================================================
   JEGR MARKET — Global Stylesheet
   Theme: Black / Dark-Yellow, Glassmorphism, RTL (Kurdish Sorani)
   ============================================================ */

:root {
    --bg: #0d0d0d;
    --bg-soft: #161512;
    --panel: rgba(255, 255, 255, 0.04);
    --panel-border: rgba(255, 199, 0, 0.18);
    --yellow: #f2c14e;
    --yellow-dark: #c9960f;
    --yellow-soft: rgba(242, 193, 78, 0.14);
    --text: #f5f1e6;
    --text-muted: #a8a196;
    --danger: #e5484d;
    --success: #4caf50;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
    --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.45);
    --font-ku: 'Rabar', 'Noto Sans Arabic', 'Vazirmatn', Tahoma, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ku);
    direction: rtl;
    text-align: right;
    line-height: 1.7;
    min-height: 100vh;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

.container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------------- Glass panel base ---------------- */
.glass {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

/* ---------------- Navbar ---------------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 13, 13, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--panel-border);
}
.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-top: 14px;
    padding-bottom: 14px;
}
.navbar .logo {
    font-size: 26px;
    font-weight: 800;
    color: var(--yellow);
    letter-spacing: 1px;
}
.navbar .logo span { color: var(--text); }

.nav-links {
    display: flex;
    gap: 26px;
    font-weight: 600;
}
.nav-links a {
    color: var(--text-muted);
    transition: color .2s;
    position: relative;
}
.nav-links a:hover, .nav-links a.active { color: var(--yellow); }

.nav-search {
    flex: 1;
    max-width: 380px;
    display: flex;
    align-items: center;
    background: var(--bg-soft);
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    padding: 8px 16px;
}
.nav-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
}
.nav-search button {
    background: none;
    border: none;
    color: var(--yellow);
    font-size: 16px;
}

.nav-icons { display: flex; align-items: center; gap: 16px; }
.nav-toggle {
    display: none; /* shown only on mobile/tablet via media query */
    width: 42px; height: 42px;
    align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.nav-toggle:hover { background: var(--yellow-soft); color: var(--yellow); }
.icon-btn {
    position: relative;
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--text);
    transition: transform .2s, background .2s;
}
.icon-btn:hover { transform: translateY(-2px); background: var(--yellow-soft); color: var(--yellow); }
.badge {
    position: absolute;
    top: -4px; left: -4px;
    background: var(--yellow);
    color: #000;
    font-size: 11px;
    font-weight: 800;
    min-width: 18px; height: 18px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 26px;
    border-radius: 999px;
    font-weight: 700;
    border: none;
    transition: transform .15s ease, box-shadow .15s ease, background .2s;
    font-family: inherit;
}
.btn-primary {
    background: linear-gradient(135deg, var(--yellow), var(--yellow-dark));
    color: #161000;
    box-shadow: 0 6px 20px rgba(242, 193, 78, 0.25);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(242, 193, 78, 0.35); }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--yellow);
    color: var(--yellow);
}
.btn-outline:hover { background: var(--yellow-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ---------------- Hero ---------------- */
.hero {
    position: relative;
    margin-top: 24px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    /* Store photo behind a dark tint so the text stays readable */
    background:
        linear-gradient(to left, rgba(13,13,13,0.88) 35%, rgba(13,13,13,0.5) 100%),
        radial-gradient(circle at 30% 20%, rgba(242,193,78,0.18), transparent 60%),
        url('../images/store-front.jpg') center/cover no-repeat,
        var(--bg-soft);
    padding: 70px 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}
.hero h1 {
    font-size: 42px;
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 18px;
}
.hero h1 span { color: var(--yellow); }
.hero p { color: var(--text-muted); margin-bottom: 26px; max-width: 480px; }
.hero-visual {
    width: 320px; height: 320px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--yellow-soft), transparent);
    display: flex; align-items: center; justify-content: center;
    font-size: 90px;
}

/* ---------------- Section headers ---------------- */
.section { padding: 50px 0; }
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 26px;
}
.section-head h2 { font-size: 26px; font-weight: 800; }
.section-head h2 span { color: var(--yellow); }
.section-head a { color: var(--yellow); font-weight: 700; font-size: 14px; }

/* ---------------- Category grid ---------------- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 18px;
}
.category-card {
    padding: 22px 10px;
    text-align: center;
    transition: transform .2s, border-color .2s;
    cursor: pointer;
}
.category-card:hover { transform: translateY(-4px); border-color: var(--yellow); }
.category-card .icon { font-size: 34px; margin-bottom: 10px; }
.category-card .name { font-weight: 700; font-size: 14px; }

/* ---------------- Product grid & card ---------------- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 22px;
}
.product-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .2s;
    position: relative;
}
.product-card:hover { transform: translateY(-5px); border-color: var(--yellow); }
.product-card .thumb {
    position: relative;
    height: 170px;
    background: var(--bg-soft);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.discount-tag {
    position: absolute; top: 10px; right: 10px;
    background: var(--danger); color: #fff;
    font-size: 12px; font-weight: 800;
    padding: 4px 10px; border-radius: 999px;
}
.fav-btn {
    position: absolute; top: 10px; left: 10px;
    width: 34px; height: 34px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text);
    border: none;
}
.fav-btn.active { color: var(--danger); }

.product-info { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-info .cat { color: var(--text-muted); font-size: 12px; }
.product-info .title { font-weight: 700; font-size: 15px; min-height: 42px; }
.price-row { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.price-now { color: var(--yellow); font-weight: 800; font-size: 17px; }
.price-old { color: var(--text-muted); text-decoration: line-through; font-size: 13px; }
.rating { color: var(--yellow); font-size: 13px; }
.stock-status { font-size: 12px; font-weight: 700; }
.stock-status.in { color: var(--success); }
.stock-status.low { color: var(--yellow); }
.stock-status.out { color: var(--danger); }

.add-cart-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--yellow-soft);
    color: var(--yellow);
    border: 1px solid var(--panel-border);
    font-weight: 700;
    transition: background .2s;
}
.add-cart-btn:hover { background: var(--yellow); color: #161000; }

/* ---------------- Forms ---------------- */
.form-panel { padding: 34px; max-width: 460px; margin: 40px auto; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 14px; }
.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    border: 1px solid var(--panel-border);
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: border-color .2s;
}
.form-control:focus { border-color: var(--yellow); }
textarea.form-control { resize: vertical; min-height: 90px; }
/* Admin edit forms: comfortable on desktop, tighter on phones */
.admin-form { padding: 28px; max-width: 640px; }

/* Custom dropdown (mobile-friendly, styled) — replaces native <select> where
   we want full control of the panel size/scroll on phones. */
.custom-select { position: relative; }
.custom-select-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; text-align: start; cursor: pointer;
}
.custom-select-trigger .cs-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-arrow { transition: transform .2s; flex-shrink: 0; }
.custom-select.open .custom-select-arrow { transform: rotate(180deg); }
.custom-select-panel {
    display: none; position: absolute; top: calc(100% + 4px); inset-inline: 0;
    z-index: 60; max-height: 50vh; overflow-y: auto;
    background: var(--bg-soft); border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm); box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.custom-select.open .custom-select-panel { display: block; }
.custom-select-option { padding: 13px 16px; cursor: pointer; border-bottom: 1px solid var(--panel-border); }
.custom-select-option:last-child { border-bottom: none; }
.custom-select-option:hover,
.custom-select-option.selected { background: var(--yellow-soft); color: var(--yellow); }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 600;
}
.alert-success { background: rgba(76,175,80,0.15); color: var(--success); border: 1px solid rgba(76,175,80,0.3); }
.alert-danger { background: rgba(229,72,77,0.15); color: var(--danger); border: 1px solid rgba(229,72,77,0.3); }
.alert-warning { background: rgba(212,175,55,0.12); color: var(--yellow); border: 1px solid rgba(212,175,55,0.35); }

/* ---------------- Cart / Checkout ---------------- */
.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th, .cart-table td { padding: 14px; border-bottom: 1px solid var(--panel-border); text-align: right; }
.qty-control { display: flex; align-items: center; gap: 10px; }
.qty-control button {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--panel); border: 1px solid var(--panel-border); color: var(--text);
}
.summary-row { display: flex; justify-content: space-between; padding: 10px 0; color: var(--text-muted); }
.summary-row.total { color: var(--yellow); font-weight: 800; font-size: 18px; border-top: 1px solid var(--panel-border); margin-top: 8px; padding-top: 14px; }

/* ---------------- Dashboard (admin) ---------------- */
.dash-layout { display: flex; min-height: 100vh; }
.dash-sidebar {
    width: 250px; flex-shrink: 0;
    background: var(--bg-soft);
    border-left: 1px solid var(--panel-border);
    padding: 24px 16px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.dash-sidebar .logo { color: var(--yellow); font-weight: 800; font-size: 22px; margin-bottom: 30px; display: block; }
.dash-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-weight: 600; margin-bottom: 6px;
    transition: background .2s, color .2s;
}
.dash-nav a:hover, .dash-nav a.active { background: var(--yellow-soft); color: var(--yellow); }
.dash-main { flex: 1; min-width: 0; padding: 28px; } /* min-width:0 lets wide tables scroll inside instead of overflowing the page (which pushed the fixed mobile sidebar off-center) */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { padding: 22px; display: flex; flex-direction: column; gap: 8px; }
.stat-card .label { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.stat-card .value { font-size: 26px; font-weight: 800; color: var(--yellow); }
.stat-card .delta { font-size: 12px; color: var(--success); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: right; padding: 12px 14px; font-size: 13px;
    color: var(--text-muted); border-bottom: 1px solid var(--panel-border);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 14px; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.status-pill {
    display: inline-block; padding: 4px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 700;
}
.status-pill.pending { background: rgba(242,193,78,0.15); color: var(--yellow); }
.status-pill.confirmed, .status-pill.preparing { background: rgba(66,153,225,0.15); color: #63b3ed; }
.status-pill.out_for_delivery { background: rgba(159,122,234,0.15); color: #b794f4; }
.status-pill.delivered { background: rgba(76,175,80,0.15); color: var(--success); }
.status-pill.cancelled { background: rgba(229,72,77,0.15); color: var(--danger); }

/* ---------------- Footer ---------------- */
footer {
    background: var(--bg-soft);
    border-top: 1px solid var(--panel-border);
    padding: 50px 0 20px;
    margin-top: 60px;
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 30px; }
.footer-grid h4 { color: var(--yellow); margin-bottom: 16px; font-size: 15px; }
.footer-grid a, .footer-grid p { color: var(--text-muted); font-size: 14px; display: block; margin-bottom: 10px; }
.footer-bottom { text-align: center; color: var(--text-muted); font-size: 13px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--panel-border); }

/* ---------------- Skeleton loading ---------------- */
.skeleton { background: linear-gradient(90deg, var(--bg-soft) 25%, rgba(255,255,255,0.06) 50%, var(--bg-soft) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------------- Utilities ---------------- */
.text-center { text-align: center; }
.mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; } .mt-3 { margin-top: 30px; }
.text-muted { color: var(--text-muted); }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 10px; } .gap-2 { gap: 20px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
    .nav-toggle { display: flex; }
    /* Sections collapse into a dropdown menu under the navbar */
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        background: rgba(13, 13, 13, 0.98);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--panel-border);
        padding: 6px 0;
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    }
    .nav-links.open { display: flex; }
    .nav-links li { width: 100%; }
    .nav-links a {
        display: block;
        padding: 14px 24px;
        border-bottom: 1px solid var(--panel-border);
    }
    .nav-links li:last-child a { border-bottom: none; }
    .nav-links a:hover, .nav-links a.active { background: var(--yellow-soft); }
    .hero { flex-direction: column; text-align: center; padding: 40px 24px; }
    .hero-visual { width: 200px; height: 200px; font-size: 60px; }
    /* Off-canvas drawer via display toggle — reliable on every browser */
    .dash-sidebar { display: none !important; position: fixed !important; top: 0; right: 0; left: auto; height: 100vh; width: 270px; max-width: 85vw; transform: none !important; z-index: 1000; overflow-y: auto; box-shadow: -8px 0 30px rgba(0,0,0,0.5); }
    .dash-sidebar.open { display: block !important; }
    #dashToggle { display: flex !important; align-items: center; justify-content: center; }
    #dashClose { display: flex !important; align-items: center; justify-content: center; }
    .dash-sidebar .logo { padding-inline-start: 44px; }
    .dash-main { padding: 16px; }
    /* Backdrop shown behind the open sidebar */
    #dashBackdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; display: none; cursor: pointer; }
    #dashBackdrop.show { display: block; }

    /* --- Admin tables & toolbars on mobile --- */
    .dash-main .glass { overflow-x: auto; padding-left: 12px; padding-right: 12px; }
    /* Admin edit forms fill the width and use tighter padding on phones */
    .admin-form { max-width: 100%; padding: 18px 14px; }
    .admin-form .btn-block { padding-top: 14px; padding-bottom: 14px; }
    .data-table th, .data-table td { padding: 10px 8px; font-size: 13px; white-space: nowrap; }
    .data-table img { width: 38px !important; height: 38px !important; }
    /* search / action toolbars wrap and stretch to full width */
    .dash-main .flex.justify-between { flex-wrap: wrap; gap: 12px; }
    /* Filter/button toolbars (direct children of main) wrap instead of forcing
       horizontal page overflow — e.g. the orders status filters. */
    .dash-main > .flex { flex-wrap: wrap; }
    .dash-main form.flex { flex: 1 1 100%; }
    .dash-main form.flex .form-control { width: 100% !important; }
}
/* Any two-column (inline-grid) layout stacks on tablets/phones */
@media (max-width: 820px) {
    [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    /* Products page: filter goes on top (full width), results fill the screen */
    .shop-layout { flex-direction: column !important; }
    .shop-filter { width: 100% !important; }
    /* In the stacked (column) layout the results column must be pinned to the
       container width, else the auto-fill product grid (and 800px product images)
       expand it to their intrinsic width and blow the page far past the viewport. */
    .shop-layout > div { width: 100% !important; min-width: 0 !important; }
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .shop-filter form > div { flex-direction: row !important; flex-wrap: wrap; gap: 10px !important; }
    .shop-toolbar { flex-wrap: wrap; gap: 10px; }
    .shop-toolbar .form-control { max-width: 100% !important; flex: 1 1 45%; }
    .shop-toolbar .btn { flex: 1 1 100%; }
}
@media (max-width: 600px) {
    .nav-search { display: none; }
    .hero { padding: 40px 20px; }
    .hero h1 { font-size: 26px; }
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 14px; }
    /* full-width primary action button (e.g. add product) */
    .dash-main .flex.justify-between > .btn, .dash-main .flex.justify-between > .btn-primary { flex: 1 1 100%; text-align: center; }
    /* Wide admin/data tables keep their size and scroll instead of squishing */
    .data-table { min-width: 620px; }
    /* Narrow tables (few columns) instead fill the screen — no forced scroll */
    .data-table--fit { min-width: 0 !important; width: 100%; }
    .data-table--fit th, .data-table--fit td { white-space: normal; padding: 10px 6px; font-size: 12px; }
    .data-table--fit .flex { flex-wrap: wrap; gap: 4px; }
    /* Cart becomes stacked cards on phones (the narrow table cramped name+price) */
    .cart-table { min-width: 0 !important; }
    .cart-table thead { display: none; }
    .cart-table tr { display: block; border: 1px solid var(--panel-border); border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; }
    .cart-table td { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: none; padding: 7px 0; text-align: start; }
    .cart-table td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-size: 13px; font-weight: 600; }
    .cart-table td.flex { justify-content: flex-start; } /* product cell: image + name */
    .container { padding-left: 14px; padding-right: 14px; }
    /* Notification dropdown: on phones span the screen (with margins) instead of
       a fixed 320px box that overflows off the corner. */
    #notifDropdown {
        position: fixed !important;
        top: 64px !important;
        inset-inline: 10px !important;
        width: auto !important;
        max-width: none !important;
    }
}
