/* ============================================================ */
/*   ALTAWFEER MARKET - COMPLETE CLEAN CSS                      */
/*   Fixed: Button display, layout, mobile nav, cart controls   */
/* ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --primary: #10B981;
    --primary-dark: #059669;
    --primary-light: #D1FAE5;
    --accent: #F59E0B;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --secondary: #1E293B;
    --text: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 40px rgba(16, 185, 129, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 30px;
    --transition: all 0.25s ease;
    --nav-height: 65px;
}

/* ===== RESET ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
}

/* ===== LAYOUT ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ===== HEADER ===== */
header {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: var(--nav-height);
    z-index: 1000;
    display: flex;
    align-items: center;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo img {
    height: 58px;
    width: auto;
    border-radius: var(--radius-sm);
    object-fit: contain;
}


.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 4px 0;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
}

.cart-btn {
    background: var(--primary-light);
    color: var(--primary-dark) !important;
    padding: 7px 16px;
    border-radius: var(--radius-xl);
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(16, 185, 129, 0.25);
    font-size: 0.9rem;
}

/* Admin Nav */
.admin-nav {
    background: var(--secondary);
    color: white;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.admin-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
}

.admin-nav h2 {
    margin: 0;
    font-size: 1.2rem;
}

/* Btn Primary */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-xl);
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* ===== HERO ===== */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 2.5rem 2rem;
    margin: 1.25rem 0;
    border-radius: var(--radius-lg);
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.hero::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 280px;
    height: 280px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    filter: blur(40px);
    pointer-events: none;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 0.4rem;
    letter-spacing: -0.5px;
}

.hero p {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 1.75rem;
}

/* ===== SEARCH ===== */
.search-container {
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    background: white;
    padding: 5px;
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.search-input {
    flex: 1;
    border: none;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    outline: none;
    background: transparent;
    color: var(--text);
}

.search-container button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: var(--radius-xl);
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.search-container button:hover {
    background: var(--primary-dark);
}

/* ===== CATEGORY SCROLLER ===== */
.category-container {
    display: flex;
    overflow-x: auto;
    gap: 0.6rem;
    padding: 0.75rem 0;
    margin-bottom: 1.25rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-container::-webkit-scrollbar {
    display: none;
}

.category-item {
    flex: 0 0 auto;
    background: var(--surface);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-xl);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.category-item span {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.category-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-item:hover span {
    color: var(--primary);
}

.category-item.active {
    background: var(--primary);
    border-color: var(--primary);
}

.category-item.active span {
    color: white;
}

.category-item.sub-category {
    background: #F1F5F9;
    border-style: dashed;
    padding: 0.3rem 0.7rem;
    transform: scale(0.93);
    margin-right: -8px;
    gap: 5px;
}

.category-item.sub-category.active {
    background: var(--primary-dark);
    border-style: solid;
}

.category-item.sub-category.active span {
    color: white;
}

.category-img-wrapper {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    background: #f0f0f0;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.sub-img {
    width: 22px;
    height: 22px;
}

.category-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== SECTION TITLE ===== */
.section-title {
    margin-bottom: 1.5rem;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 1rem 0 1.25rem;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--primary);
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb strong {
    color: var(--text);
}

/* ===== BACK BUTTON ===== */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 6px 14px;
    border-radius: var(--radius-xl);
    font-weight: 700;
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
    transition: var(--transition);
}

.back-btn:hover {
    background: var(--primary);
    color: white;
}

/* ===== CATEGORY CARDS GRID (Homepage) ===== */
.cat-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 3rem;
}

.cat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    text-align: center;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.cat-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--primary-light);
}

.cat-card-img {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(to bottom, #F8FAFC, #FFFFFF);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.cat-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s ease;
}

.cat-card:hover .cat-card-img img {
    transform: scale(1.1);
}




.cat-card-body {
    padding: 12px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.cat-card-body h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 4px 0;
}

.cat-card-count {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 3px 12px;
    border-radius: 50px;
    border: 1px solid rgba(16, 185, 129, 0.1);
}

/* ===== SUB-CATEGORY PILLS ROW ===== */
.sub-cat-row {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.5rem 0 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-bottom: 0.5rem;
}

.sub-cat-row::-webkit-scrollbar {
    display: none;
}

.sub-cat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 6px 14px 6px 8px;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: var(--transition);
    flex-shrink: 0;
}

.sub-cat-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.sub-cat-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.sub-pill-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    background: #f0fdf4;
    flex-shrink: 0;
    border: 2px solid rgba(16, 185, 129, 0.2);
}

.sub-pill-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== PRODUCT GRID ===== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 5rem;
}

/* ===== PRODUCT CARD ===== */
.product-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-light);
}

.product-img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    padding: 15px;
    background: white;
    transition: transform 0.5s ease;
}

.product-card:hover .product-img {
    transform: scale(1.05);
}

.product-info {
    padding: 10px 12px 50px;
    /* bottom padding for the button */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-name {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 8px;
    height: 2.7rem;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    color: var(--text);
}

.product-price {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 900;
    margin-top: auto;
    letter-spacing: -0.5px;
}

/* ===== FLOATING QTY CONTROL (ADD BUTTON) ===== */
.floating-qty-control {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    border-radius: 50px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 15px rgba(16, 185, 129, 0.25);
    height: 36px;
    border: 1px solid rgba(16, 185, 129, 0.1);
}

/* Collapsed: just a green + button */
.floating-qty-control .qty-btn.minus {
    display: none;
    width: 34px;
    height: 34px;
    background: #f3f4f6;
    color: var(--text);
    border: none;
    font-size: 1.1rem;
    font-weight: 900;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.floating-qty-control .qty-num {
    display: none;
    padding: 0 10px;
    font-weight: 900;
    font-size: 0.95rem;
    background: white;
    color: var(--text);
    min-width: 32px;
    text-align: center;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.floating-qty-control .qty-btn.plus {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 14px;
    height: 34px;
    font-size: 1rem;
    font-weight: 900;
    transition: var(--transition);
    white-space: nowrap;
}

.floating-qty-control .qty-btn.plus::after {
    content: 'إضافة';
    font-size: 0.82rem;
    font-weight: 800;
}

.floating-qty-control .qty-btn.plus:hover {
    background: var(--primary-dark);
}

/* Expanded: shows - [qty] + */
.floating-qty-control.expanded .qty-btn.minus {
    display: flex;
}

.floating-qty-control.expanded .qty-num {
    display: flex;
}

.floating-qty-control.expanded .qty-btn.plus {
    padding: 0;
    width: 34px;
}

.floating-qty-control.expanded .qty-btn.plus::after {
    display: none;
}

/* ===== SALE BADGE ===== */
.sale-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ef4444;
    color: white;
    padding: 2px 9px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 900;
    z-index: 2;
}

/* ===== FORMS ===== */
.form-control {
    width: 100%;
    padding: 11px 15px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
    font-family: 'Cairo', sans-serif;
    background: white;
    color: var(--text);
    direction: rtl;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== FOOTER ===== */
footer {
    background: #111827;
    color: white;
    padding: 3.5rem 0 2rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 3rem;
}

.footer-section h3 {
    margin-bottom: 1rem;
    font-weight: 800;
    color: var(--primary);
}

.footer-section p,
.footer-section a {
    color: #94A3B8;
    font-weight: 500;
    line-height: 1.8;
}

.footer-section a {
    display: block;
    margin-bottom: 0.5rem;
}

.footer-section a:hover {
    color: white;
}

/* ===== MOBILE BOTTOM NAV ===== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.93);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    height: 62px;
    justify-content: space-around;
    align-items: center;
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 999;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-muted);
    position: relative;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.35rem;
}

.nav-label {
    font-size: 0.72rem;
    font-weight: 800;
}

.cart-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: #EF4444;
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 50px;
    font-weight: 900;
    min-width: 18px;
    text-align: center;
}

/* ===== HEADER ACTIONS (cart + user) ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name-desktop {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary);
}

.logout-btn,
.login-btn,
.profile-btn {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 5px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    transition: var(--transition);
    text-decoration: none;
}

.logout-btn:hover,
.login-btn:hover,
.profile-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== WEIGHT CONTROLS (Attara) ===== */
.weight-controls {
    margin-top: 6px;
}

.desired-price-input {
    border: 1.5px solid var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    width: 100%;
    text-align: center;
    font-weight: 800;
    color: var(--primary);
    font-size: 0.9rem;
    outline: none;
    background: white;
}

.desired-price-input:focus {
    border-color: var(--primary);
}

/* ===== ADMIN TABLES ===== */
.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.order-table {
    width: 100%;
    border-collapse: collapse;
}

.order-table th {
    background: #F1F5F9;
    padding: 14px 15px;
    text-align: right;
    font-weight: 800;
    font-size: 0.9rem;
    white-space: nowrap;
}

.order-table td {
    padding: 13px 15px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

/* ===================================================
   RESPONSIVE - MOBILE FIRST
   =================================================== */
@media (max-width: 768px) {

    /* --- Header --- */
    .nav-links {
        display: none;
    }

    .mobile-bottom-nav {
        display: flex;
    }

    .user-name-desktop {
        display: none;
    }

    .logout-btn,
    .login-btn {
        display: none;
    }

    /* Tighter header on mobile */
    header {
        height: 56px;
    }

    :root {
        --nav-height: 56px;
    }

    .logo img {
        height: 48px;
    }

    .cart-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    /* --- Hero Compact --- */
    .hero {
        padding: 1.4rem 1rem;
        margin: 0.5rem 0;
        border-radius: var(--radius-md);
    }

    .hero h1 {
        font-size: 1.4rem;
        margin-bottom: 0.2rem;
    }

    .hero p {
        font-size: 0.83rem;
        margin-bottom: 1rem;
    }

    .search-container {
        padding: 4px;
    }

    .search-input {
        padding: 8px 12px;
        font-size: 0.88rem;
    }

    .search-container button {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    /* --- Category Cards 2-col on mobile --- */
    .cat-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem;
    }

    .cat-card-img {
        width: 100% !important;
        height: 140px !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }


    .cat-card-img img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }



    .cat-card-body {
        padding: 8px !important;
    }

    .cat-card-body h3 {
        font-size: 0.85rem !important;
    }

    /* --- Products 2-col --- */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .product-card {
        border-radius: var(--radius-sm);
    }

    .product-img {
        height: 120px;
        padding: 8px;
    }

    .product-name {
        font-size: 0.83rem;
        height: 2.4rem;
    }

    .product-price {
        font-size: 0.92rem;
    }

    /* --- Floating qty control --- */
    .floating-qty-control {
        bottom: 8px;
        left: 8px;
        height: 30px;
    }

    .floating-qty-control .qty-btn.plus {
        height: 30px;
        font-size: 0.9rem;
        padding: 0 10px;
    }

    .floating-qty-control.expanded .qty-btn.plus {
        width: 30px;
    }

    .floating-qty-control .qty-btn.minus {
        width: 30px;
        height: 30px;
    }

    /* --- Extra bottom padding so bottom nav doesn't cover content --- */
    main.container {
        padding-bottom: 90px !important;
    }

    footer {
        padding-bottom: 85px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    /* --- Sub-cat pills smaller on mobile --- */
    .sub-cat-pill {
        padding: 5px 12px 5px 6px !important;
        font-size: 0.85rem !important;
    }

    .sub-pill-img,
    .sub-cat-pill div {
        width: 40px !important;
        height: 40px !important;
    }

    /* --- Section titles --- */
    .section-title h2 {
        font-size: 1.2rem;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .cat-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero h1 {
        font-size: 1.25rem;
    }
}