/* نقاط البيع POS — أنماط مستقلة، تعيد استخدام ألوان app.css فقط (لا تكرّر فئاته). */

.pos-root {
    direction: rtl;
    text-align: start;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.25rem;
    align-items: start;
}

/* سطح المكتب والتابلت: سلة جانبية */
.pos-cart {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.pos-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.pos-toolbar__search { flex: 1 1 240px; }
.pos-main { min-width: 0; }
.pos-patient-picker { display: flex; align-items: flex-start; gap: 0.5rem; }
.pos-patient-picker__search { flex: 1; min-width: 0; }
.pos-patient-picker > .mud-tooltip-root { margin-block-start: 0.5rem; }
.pos-patient-option { display: flex; flex-direction: column; gap: 0.25rem; text-align: start; }
.pos-patient-option small { color: var(--mud-palette-text-secondary); overflow-wrap: anywhere; }

.pos-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* شبكة المنتجات */
.pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.75rem;
}

.pos-product {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    min-height: 140px;
    padding: 0.9rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    background: var(--mud-palette-surface, #fff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    text-align: start;
    font: inherit;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    position: relative;
}

.pos-product:hover, .pos-product:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    outline: none;
}

.pos-product:active { transform: scale(0.98); }

.pos-product__category {
    font-size: 0.7rem;
    color: #7256a5;
    background: rgba(114, 86, 165, 0.1);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    align-self: flex-start;
}

.pos-product__name { font-weight: 700; font-size: 1rem; line-height: 1.4; }

.pos-product__code { font-size: 0.72rem; opacity: 0.6; letter-spacing: 0.03em; }

.pos-product__price { font-size: 1.25rem; font-weight: 700; margin-top: auto; padding-inline-end: 2rem; }

.pos-product__vat { display: block; font-size: 0.68rem; font-weight: 400; opacity: 0.6; }

.pos-product__add {
    position: absolute;
    inset-inline-end: 0.75rem;
    bottom: 0.75rem;
    color: #7256a5;
    opacity: 0.35;
}

.pos-product:hover .pos-product__add { opacity: 1; }

/* سطر السلة */
.pos-cart__header { display: flex; align-items: center; justify-content: space-between; }
.pos-cart__title { display: flex; align-items: center; gap: 0.5rem; }
.pos-cart__title .mud-chip { margin: 0; }

.pos-cart__items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 3rem;
}

.pos-cart__empty { display: flex; align-items: center; justify-content: center; gap: 0.5rem; text-align: start; opacity: 0.55; padding: 1rem 0; font-size: 0.85rem; }

.pos-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.03);
}

.pos-line__info { display: flex; flex-direction: column; min-width: 0; }
.pos-line__info b { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-line__info small { opacity: 0.6; }

.pos-line__controls { display: flex; align-items: center; gap: 0.35rem; grid-column: 1; grid-row: 2; }

.pos-qty {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.pos-line__qty { min-width: 1.5rem; text-align: center; font-weight: 700; }

.pos-line__amount { font-weight: 700; font-size: 1.05rem; white-space: nowrap; grid-column: 2; grid-row: 1; }

.pos-line__remove {
    grid-column: 2;
    grid-row: 2;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: #b3261e;
    cursor: pointer;
    border-radius: 10px;
}
.pos-line__remove:hover { background: rgba(179, 38, 30, 0.08); }

.pos-cart__vatnote { font-size: 0.78rem; margin: 0; }

/* المجاميع */
.pos-totals { margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.pos-totals div { display: flex; justify-content: space-between; gap: 0.5rem; }
.pos-totals dt { opacity: 0.7; font-size: 0.85rem; }
.pos-totals dd { margin: 0; font-weight: 600; font-size: 1rem; }

.pos-totals__grand {
    border-top: 1px dashed rgba(0, 0, 0, 0.15);
    padding-top: 0.4rem;
    margin-top: 0.2rem;
}
.pos-totals__grand dt { font-weight: 700; opacity: 1; }
.pos-totals__grand dd { font-size: 1.35rem; font-weight: 800; color: #7256a5; }

.pos-checkout { min-height: 56px; font-size: 1.05rem; }

.pos-cart__success .pos-cart__invoicelink { font-weight: 700; margin-inline-start: 0.5rem; }

.pos-cart__invoicelink { font-weight: 700; }

/* شريط الجوال السفلي والدرج مخفيان افتراضيًا */
.pos-mobile-bar {
    display: none;
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 20;
    height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0 1.25rem;
    border: none;
    border-radius: 18px 18px 0 0;
    background: #7256a5;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
}

.pos-mobile-drawer__content { padding: 1rem; }
.pos-mobile-drawer { direction: rtl; text-align: start; }
.pos-mobile-drawer__header { display: flex; justify-content: space-between; align-items: center; }
.pos-cart--mobile { padding: 0; border: none; box-shadow: none; position: static; max-height: none; }
.pos-cart--mobile .pos-line { grid-template-columns: minmax(0, 1fr) auto; }
.pos-cart--mobile .pos-line__amount { text-align: end; }

/* تابلت: سلة أضيق */
@media (max-width: 1100px) {
    .pos-root { grid-template-columns: minmax(0, 1fr) 300px; gap: 0.85rem; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* جوال: سلة شريط سفلي + درج */
@media (max-width: 767px) {
    .pos-root { display: block; padding-bottom: 80px; }
    .pos-cart { display: none; }
    .pos-cart--mobile { display: flex; }
    .pos-mobile-bar { display: flex; bottom: calc(68px + env(safe-area-inset-bottom)); }
    .pos-mobile-drawer { z-index: 1300; max-height: calc(100dvh - 80px); overflow-y: auto; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .pos-product { min-height: 150px; }
    .pos-totals__grand dd { font-size: 1.5rem; }
    .pos-line__amount { font-size: 1.15rem; }
}
/* Optional mint POS template: shared cart and payment behavior stays in Pos.razor. */
.pos-template-fresh {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
    padding: 20px;
    border: 1px solid #e3dded;
    border-radius: 24px;
    background: #e5f3ed;
}
.pos-template-fresh .section-heading { margin-block-end: 20px; }
.pos-template-fresh .pos-toolbar { background: #fff; border-radius: 16px; padding: 16px; }
.pos-template-fresh .pos-cart { background: #fff; border: 0; border-radius: 18px; padding: 20px; }
.pos-template-fresh .pos-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.pos-template-fresh .pos-product {
    min-height: 250px;
    align-items: center;
    text-align: center;
    background: #fff;
    border: 1px solid #e3dded;
    box-shadow: none;
    border-radius: 16px;
    padding: 16px;
    gap: 8px;
}
.pos-template-fresh .pos-product:hover { border-color: #378f84; background: #faf8fc; }
.pos-template-fresh .pos-product:focus-visible { outline: 3px solid #378f84; outline-offset: 2px; }
.pos-product__visual { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #e5f3ed; color: #378f84; }
.pos-product__visual .mud-icon-root { font-size: 32px; }
.pos-template-fresh .pos-product:nth-child(3n + 2) .pos-product__visual { color: #bc852d; background: #fff3dc; }
.pos-template-fresh .pos-product:nth-child(3n) .pos-product__visual { color: #567dad; background: #e7f0fb; }
.pos-template-fresh .pos-product__category { align-self: center; font-size: 12px; }
.pos-template-fresh .pos-product__name { font-size: 15px; }
.pos-template-fresh .pos-product__price { padding-inline: 0; margin-block-start: auto; font-size: 20px; }
.pos-template-fresh .pos-product__vat { font-size: 12px; }
.pos-template-fresh .pos-product__add {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    padding: 4px 10px;
    border-radius: 18px;
    background: #378f84;
    color: #fff;
    opacity: 1;
}
.pos-template-fresh .pos-product__add .mud-icon-root { font-size: 18px; }
.pos-template-fresh .pos-product__add small { font-size: 14px; }
.pos-template-fresh .pos-cart__header { padding-block-end: 12px; border-block-end: 1px solid #e3dded; }
.pos-template-fresh .pos-line { background: #f5f1f9; border-radius: 12px; padding: 12px; }
.pos-template-fresh .pos-totals__grand { border-block-start: 1px solid #e3dded; padding-block-start: 12px; margin-block-start: 8px; }
.pos-template-fresh .pos-checkout { border-radius: 28px; background: #378f84; }
.pos-template-fresh .pos-checkout:disabled { background: #e2e7e3; }
@media (max-width: 1100px) and (min-width: 768px) {
    .pos-template-fresh { grid-template-columns: minmax(0, 1fr) 300px; padding: 16px; gap: 16px; }
}
@media (max-width: 767px) {
    .pos-template-fresh { display: block; padding: 14px 14px 80px; border-radius: 18px; }
    .pos-template-fresh .pos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .pos-template-fresh .pos-product { min-height: 240px; padding: 12px; }
    .pos-template-fresh .pos-toolbar { padding: 12px; }
}
