/* ========== CSS Variables ========== */
:root {
    --font-family-base: "Tajawal", "Cairo", "Segoe UI", system-ui, sans-serif;
    --color-primary: #26aac0;
    --color-primary-dark: #1f8798;
    --color-accent: #ed1c24;
    --color-accent-dark: #c4181f;
    --color-success: #1d8f64;
    --color-warning: #f4b740;
    --color-danger: #d9534f;
    --color-ink: #22313f;
    --color-text: #4f5f6f;
    --color-muted: #8b98a7;
    --color-surface: #ffffff;
    --color-surface-soft: #f7fbfc;
    --color-border: #dce7eb;
    --shadow-soft: 0 6px 18px rgba(21, 53, 71, 0.06);
    --shadow-hover: 0 10px 22px rgba(21, 53, 71, 0.08);
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --container-width: 1280px;
}

/* ========== Reset & Base ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-base);
    background: #f5f7fa;
    color: var(--color-text);
    line-height: 1.7;
    min-height: 100vh;
}

a, button, input {
    font-family: inherit;
}

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

/* ========== Layout Shells ========== */
.page-shell {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 2rem;
}

.section-shell {
    max-width: var(--container-width);
    margin: 0 auto 2rem;
    padding: 0 2rem;
}

/* ========== Hero Panel ========== */
.hero-panel {
    position: relative;
    overflow: hidden;
    border-radius: 0 0 24px 24px;
    padding: 2.25rem 2rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
    box-shadow: var(--shadow-soft);
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 700px;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-title {
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.2;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.hero-subtitle {
    font-size: 1rem;
    opacity: 0.92;
    max-width: 56ch;
}

.hero-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    text-decoration: none;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: background-color 0.2s ease;
}

.hero-link:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* ========== Toolbar ========== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 2rem auto;
}

.toolbar-group {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.section-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: var(--color-ink);
    font-weight: 800;
}

.section-subtitle {
    color: var(--color-muted);
    font-size: 0.95rem;
    margin-top: 0.3rem;
}

/* ========== Search Box ========== */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: min(100%, 320px);
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.85rem 1.1rem;
    box-shadow: none;
}

.search-box i {
    color: var(--color-muted);
}

.search-box input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--color-ink);
    font-size: 0.95rem;
}

.search-box input::placeholder {
    color: var(--color-muted);
}

/* ========== Cards Grid (عام) ========== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1.5rem;
}

/* ========== Category & Product Cards ========== */
.category-card,
.product-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--shadow-soft);
}

.category-card:hover,
.product-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--color-border);
}

.card-image,
.product-image {
    width: 100%;
    height: fit-content;
    object-fit: cover;
}

.card-content,
.product-content {
    padding: 0 5px 5px;
}

.card-title,
.product-title {
    color: var(--color-ink);
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 0.45rem;
}

.card-products-count,
.product-description {
    color: var(--color-muted);
}

.product-price {
    color: var(--color-accent);
    font-weight: 800;
}

.card-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 0.85rem;
    background: rgba(38, 170, 192, 0.12);
    color: var(--color-primary-dark);
}

/* ========== Buttons ========== */
.primary-btn,
.slide-btn,
.add-to-cart-btn,
.checkout-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: 999px;
    padding: 0.9rem 1.35rem;
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    margin-top: 5px;
}

.primary-btn:hover,
.slide-btn:hover,
.add-to-cart-btn:hover:not(:disabled),
.checkout-action-btn:hover {
    background: var(--color-primary-dark);
}

.add-to-cart-btn:disabled,
.checkout-action-btn:disabled {
    opacity: 0.72;
    cursor: not-allowed;
    box-shadow: none;
}

/* ========== View Toggle ========== */
.view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--color-border);
    box-shadow: none;
}

.view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-primary-dark);
    cursor: pointer;
    transition: 0.2s ease;
    font-size: 1rem;
}

.view-btn.active,
.view-btn:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* ========== Quantity Controls ========== */
.quantity-selector,
.quantity-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.qty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-primary-dark);
    cursor: pointer;
    transition: 0.2s ease;
    font-size: 1rem;
    font-weight: 700;
}

.qty-btn:hover:not(:disabled) {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.qty-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.qty-input,
.item-quantity,
.item-quantity-input {
    min-width: 60px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface-soft);
    color: var(--color-ink);
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
}

.qty-input:focus,
.item-quantity-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(38, 170, 192, 0.2);
}

.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button,
.item-quantity-input::-webkit-inner-spin-button,
.item-quantity-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ========== Products Grid ========== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.2rem;
    margin: 2rem 0;
}

.product-card {
    display: flex;
    flex-direction: column;
}

.product-image-link {
    display: block;
    overflow: hidden;
}

.product-card:hover .product-image {
    transform: scale(1.03);
}

.product-content {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-title-link {
    text-decoration: none;
}

.product-title:hover {
    color: var(--color-primary);
}

.product-description {
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.add-to-cart-btn {
    width: 100%;
    padding: 0.7rem;
    border-radius: 14px;
    font-size: 0.9rem;
}

/* ========== Horizontal Layout ========== */
.products-grid.horizontal-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.products-grid.horizontal-layout .product-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
}

.products-grid.horizontal-layout .product-image-link {
    width: 150px;
    flex-shrink: 0;
}

.products-grid.horizontal-layout .product-image {
    width: fit-content;
    /*height: 150px;*/
    border-radius: 16px;
}

.products-grid.horizontal-layout .product-content {
    text-align: right;
    padding: 0.5rem;
}

.products-grid.horizontal-layout .quantity-selector {
    justify-content: flex-start;
}

.products-grid.horizontal-layout .add-to-cart-btn {
    width: auto;
    min-width: 180px;
}

/* ========== Products Grid ========== */
.products-grid {
    display: grid;
    gap: 1rem;
    margin: 2rem 0;
    transition: all 0.3s ease;
}

/* 2 columns (default) */
.products-grid.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* 3 columns */
.products-grid.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* 4 columns */
.products-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--shadow-soft);
}

.product-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--color-border);
}

/* Responsive */
@media (max-width: 1024px) {
    .products-grid.grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .products-grid.grid-2,
    .products-grid.grid-3,
    .products-grid.grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ========== No Results ========== */
.no-results {
    text-align: center;
    padding: 3rem;
    grid-column: 1 / -1;
    color: var(--color-muted);
}

.no-results i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--color-primary);
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem auto 0;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    padding: 0.65rem 0.95rem;
    border-radius: 12px;
    background: #fff;
    color: var(--color-primary-dark);
    border: 1px solid var(--color-border);
    text-decoration: none;
}

.pagination .active span,
.pagination a:hover {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

/* ========== Navbar ========== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 2rem;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
}

.nav-container {
    max-width: var(--container-width);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    background: var(--color-primary);
}

.logo-text {
    color: var(--color-ink);
    font-size: 1.4rem;
    font-weight: 800;
}

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

.nav-links a {
    position: relative;
    text-decoration: none;
    color: var(--color-text);
    font-weight: 700;
    padding-bottom: 0.25rem;
    transition: color 0.2s ease;
}

.nav-links a::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -0.2rem;
    width: 0;
    height: 3px;
    border-radius: 999px;
    background: var(--color-primary);
    transition: width 0.25s ease;
}

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

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

.nav-icons {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-icons i {
    font-size: 1.15rem;
    color: var(--color-text);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.nav-icons i:hover {
    color: var(--color-primary-dark);
}

.cart-badge {
    position: relative;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-size: 0.65rem;
    line-height: 1;
    font-weight: 700;
    padding: 0;
}

.menu-toggle {
    display: none;
    font-size: 1.4rem;
    color: var(--color-primary-dark);
    cursor: pointer;
}

/* ========== Footer ========== */
.footer {
    margin-top: 4rem;
    padding: 2rem;
    text-align: center;
    color: #d7e1e6;
    /* background: linear-gradient(135deg, #142330, #1d3846); */
}

.footer-copy {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #9db0bc;
}

/* ========== Cart Page ========== */
.cart-hero {
    margin-bottom: 2rem;
}

.cart-hero .hero-content {
    text-align: center;
    margin: 0 auto;
}

.checkout-main {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 2rem;
}

.cart-section {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.cart-header-row {
    display: grid;
    grid-template-columns: 2.5fr 1.2fr 1fr 0.5fr;
    background: var(--color-surface-soft);
    padding: 1.2rem 1.5rem;
    font-weight: 800;
    color: var(--color-ink);
    border-bottom: 1px solid var(--color-border);
}

.cart-item {
    display: grid;
    grid-template-columns: 2.5fr 1.2fr 1fr 0.5fr;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid rgba(220, 231, 235, 0.9);
    transition: 0.2s;
}

.cart-item:hover {
    background: rgba(38, 170, 192, 0.04);
}

.product-img {
    width: 64px;
    height: 64px;
    background: var(--color-surface-soft);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--color-primary-dark);
}

.product-details h3 {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
    color: var(--color-ink);
}

.stock-warning {
    font-size: 0.7rem;
    color: var(--color-danger);
    margin-top: 4px;
}

.quantity-wrap {
    justify-content: flex-start;
    width: fit-content;
}

.item-total-price {
    font-weight: 800;
    color: var(--color-danger);
    font-size: 1rem;
}

.delete-item {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #b91c1c;
    cursor: pointer;
    transition: 0.2s ease;
}

.delete-item:hover {
    transform: scale(1.1);
    color: var(--color-accent);
}

.summary-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 24px;
    padding: 1.6rem;
    position: sticky;
    top: 100px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.summary-title {
    font-size: 1.4rem;
    font-weight: 800;
    border-right: 4px solid var(--color-primary);
    padding-right: 12px;
    margin-bottom: 1.5rem;
    color: var(--color-ink);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.9rem;
    font-size: 0.95rem;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    font-weight: 800;
    font-size: 1.3rem;
    margin: 1rem 0 1.2rem;
    padding-top: 0.8rem;
    border-top: 2px dashed var(--color-border);
    color: var(--color-primary-dark);
}

.client-area {
    margin-top: 1rem;
}

.search-client-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.35rem 0.35rem 0.35rem 1rem;
    margin-bottom: 1rem;
}

.search-client-box i {
    color: var(--color-muted);
}

.search-client-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.7rem 0.5rem;
    outline: none;
    font-family: inherit;
}

.customers-dropdown {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.96);
    margin-bottom: 1rem;
}

.customer-option {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(220, 231, 235, 0.85);
    cursor: pointer;
    transition: 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.customer-option:hover {
    background: rgba(38, 170, 192, 0.08);
}

.customer-selected-badge {
    background: var(--color-primary);
    color: white;
    padding: 0.2rem 0.7rem;
    border-radius: 40px;
    font-size: 0.7rem;
}

.selected-customer-info {
    background: var(--color-surface-soft);
    border-radius: 18px;
    padding: 0.8rem;
    font-size: 0.85rem;
    margin-top: 0.8rem;
    color: var(--color-ink);
}

.checkout-action-btn {
    width: 100%;
    margin-top: 1.2rem;
    background: linear-gradient(135deg, #28a745, #218838);
}

/* ========== Offline Badge & Toast ========== */
.offline-badge {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #ffc107;
    color: #2d2f36;
    padding: 8px 18px;
    border-radius: 40px;
    font-size: 0.8rem;
    z-index: 999;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.toast-notify,
.toast-message {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: #28a745;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    z-index: 1100;
    font-weight: 500;
    transition: opacity 0.3s ease;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.toast-message.warning {
    background: #ffc107;
    color: #333;
}

.toast-message.error {
    background: #dc3545;
}

/* ========== Animations ========== */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========== Responsive ========== */
@media (max-width: 992px) {
    .page-shell,
    .section-shell,
    .navbar {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem 0 0.25rem;
    }

    .nav-links.active {
        display: flex;
    }

    .menu-toggle {
        display: block;
    }
}

@media (max-width: 900px) {
    .checkout-main {
        grid-template-columns: 1fr;
    }

    .cart-header-row {
        display: none;
    }

    .cart-item {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .product-card {
        flex-direction: column;
        text-align: center;
    }

    .quantity-wrap {
        margin: 0 auto;
    }

    .summary-card {
        position: static;
    }
}

@media (max-width: 768px) {
    .hero-panel {
        border-radius: 0 0 24px 24px;
        padding: 2rem 1rem;
    }

    .toolbar {
        align-items: stretch;
    }

    .toolbar-group,
    .search-box {
        width: 100%;
    }

    .cards-grid,
    .products-grid {
        grid-template-columns: 1fr;
    }

    .footer {
        margin-top: 3rem;
    }
}

@media (max-width: 680px) {
    .search-client-box {
        flex-wrap: wrap;
        border-radius: 24px;
        padding: 0.75rem;
    }

    .primary-btn {
        width: 100%;
    }
}

/* ========== Utility ========== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
