html, body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    direction: rtl;
    margin: 0;
    background-color: #f0f2f8;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

/* ── Layout ── */
.admin-shell .mud-drawer {
    width: 260px !important;
    border-inline-end: 1px solid #e2e8f0;
}

.admin-main {
    min-height: calc(100dvh - 64px);
    max-width: none;
    margin-inline: auto;
    transition: padding-inline 0.2s ease, margin-inline 0.2s ease;
}

.admin-main-inner {
    width: 100%;
    max-width: 100%;
    min-width: 0; /* يسمح لجداول التمرير داخل المساحة المتقلصة */
}

.admin-shell .mud-main-content.admin-main {
    max-width: 100%;
    overflow-x: hidden;
}

.admin-nav .mud-nav-link {
    border-radius: 10px;
    margin: 2px 8px;
    min-height: 44px;
}

.admin-nav-section {
    color: #94a3b8 !important;
    font-weight: 600;
}

.admin-drawer-header {
    min-height: 64px;
    display: flex;
    align-items: center;
    padding-inline: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.admin-appbar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.admin-inbox-panel {
    width: min(360px, 92vw);
    max-height: min(420px, 70vh);
    overflow: auto;
}

.admin-inbox-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.admin-inbox-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    white-space: normal;
    max-width: 320px;
}

.admin-inbox-item--unread .mud-typography-subtitle2 {
    font-weight: 700;
    color: #5b4bb4;
}

.admin-inbox-row--unread td {
    font-weight: 600;
    background: rgba(91, 75, 180, 0.06);
}


.admin-appbar-title {
    font-weight: 700;
    letter-spacing: 0.01em;
}

.admin-stat-card {
    height: 100%;
}

.admin-shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.admin-shortcut-btn {
    width: 100%;
    justify-content: center;
}

.admin-toolbar-field {
    flex: 1 1 220px;
    min-width: min(100%, 220px);
}

.working-hours-editor {
    background: #fafbff;
    border-color: #e2e8f0 !important;
}

.working-hours-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.working-hours-table {
    min-width: 420px;
}

.working-hours-day {
    font-weight: 600;
    white-space: nowrap;
}

.working-hours-time {
    max-width: 110px;
}

.working-hours-time--valid .mud-input-slot {
    background: #f0fdf4;
}

.working-hours-time--invalid .mud-input-slot {
    background: #fff1f2;
}

.working-hours-row--closed {
    opacity: 0.65;
}

@media (max-width: 599.98px) {
    .working-hours-table {
        min-width: 100%;
    }

    .working-hours-time {
        max-width: none;
    }
}

.admin-user-chip {
    max-width: 140px;
}

.admin-page-header {
    margin-bottom: 1rem;
}

.admin-page-title {
    font-weight: 700;
    line-height: 1.3;
}

.admin-page-subtitle {
    line-height: 1.5;
}

/* ── Cards & papers ── */
.admin-main .mud-paper {
    border-radius: 14px !important;
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.admin-form-grid .mud-input-control {
    margin-bottom: 0;
}

/* ── Tables: force real horizontal scroll (do not shrink columns) ── */
.admin-table-wrap,
.orders-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: scroll !important; /* always show horizontal bar track */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    scrollbar-gutter: stable both-edges;
}

.admin-table-wrap--tall {
    overflow-y: auto !important;
    max-height: min(70vh, 640px);
}

.admin-table-wrap::-webkit-scrollbar,
.orders-table-wrap::-webkit-scrollbar {
    height: 14px;
}

.admin-table-wrap::-webkit-scrollbar-track,
.orders-table-wrap::-webkit-scrollbar-track {
    background: #eef2ff;
    border-radius: 0 0 14px 14px;
}

.admin-table-wrap::-webkit-scrollbar-thumb,
.orders-table-wrap::-webkit-scrollbar-thumb {
    background: #7c6bc4;
    border-radius: 8px;
    border: 3px solid #eef2ff;
}

.admin-table-wrap .mud-table,
.orders-table-wrap .mud-table {
    overflow: visible !important;
    width: max-content !important;
    min-width: 100%;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.admin-table-wrap .mud-table-container,
.orders-table-wrap .mud-table-container {
    overflow: visible !important;
    max-height: none !important;
}

.admin-table-wrap .mud-table-root,
.orders-table-wrap .mud-table-root {
    width: max-content !important;
    min-width: 1100px !important;
    table-layout: auto !important;
}

.orders-table-wrap .mud-table-root {
    min-width: 1300px !important;
}

.admin-table-wrap .mud-table-root th,
.admin-table-wrap .mud-table-root td,
.orders-table-wrap .mud-table-root th,
.orders-table-wrap .mud-table-root td {
    white-space: nowrap !important;
    vertical-align: middle;
}

.admin-data-table,
.orders-table {
    min-width: unset; /* width comes from table-root */
}

.admin-drawer {
    width: 260px !important;
}

.admin-drawer .mud-nav-link {
    white-space: nowrap;
}

.admin-drawer .admin-nav-section {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.orders-col-num,
.orders-col-date,
.orders-col-money,
.orders-col-courier,
.orders-col-text {
    white-space: nowrap;
}

.orders-col-courier {
    min-width: 160px;
    font-weight: 600;
}

/* ── Order tracking dialog ── */
.order-pipeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-inline-start: 4px;
}

.order-pipeline__step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    position: relative;
    padding-bottom: 18px;
}

.order-pipeline__step:not(:last-child)::before {
    content: "";
    position: absolute;
    inset-inline-start: 15px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}

.order-pipeline__step--done:not(:last-child)::before,
.order-pipeline__step--current:not(:last-child)::before {
    background: #5b4bb4;
}

.order-pipeline__marker {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.85rem;
    z-index: 1;
    background: #e2e8f0;
    color: #64748b;
}

.order-pipeline__step--done .order-pipeline__marker {
    background: #5b4bb4;
    color: #fff;
}

.order-pipeline__step--current .order-pipeline__marker {
    background: #5b4bb4;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(91, 75, 180, 0.18);
}

.order-pipeline__title {
    font-weight: 700;
    color: #0f172a;
    line-height: 1.35;
}

.order-pipeline__subtitle {
    color: #64748b;
    font-size: 0.85rem;
    margin-top: 2px;
}

.order-pipeline__step--pending .order-pipeline__title {
    color: #94a3b8;
}

.order-tracking-list {
    display: flex;
    flex-direction: column;
}

.order-tracking-item {
    display: flex;
    gap: 12px;
    min-height: 64px;
}

.order-tracking-item__rail {
    width: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.order-tracking-item__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #14b8a6;
    margin-top: 4px;
    flex-shrink: 0;
}

.order-tracking-item--latest .order-tracking-item__dot {
    background: #5b4bb4;
    box-shadow: 0 0 0 4px rgba(91, 75, 180, 0.16);
}

.order-tracking-item__line {
    width: 2px;
    flex: 1;
    background: #e2e8f0;
    margin-top: 4px;
}

.order-tracking-item__content {
    flex: 1;
    padding-bottom: 16px;
    min-width: 0;
}

/* ── Media thumbnails ── */
.admin-media-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: middle;
}

.admin-media-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    flex-shrink: 0;
    vertical-align: middle;
}

.admin-media-thumb--link {
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease;
}

.admin-media-thumb--link:hover {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.35);
}

.admin-media-thumb img {
    width: 100%;
    height: 100%;
    display: block;
}

.admin-media-open-btn {
    flex-shrink: 0;
}

.admin-media-link-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    direction: rtl;
}

.admin-media-link-label {
    color: #757575;
    font-size: 0.75rem;
}

.admin-media-link-url {
    word-break: break-all;
    unicode-bidi: plaintext;
}

/* ── Supplier image & location pickers ── */
.supplier-image-field,
.location-picker {
    height: 100%;
}

.supplier-image-preview .admin-media-thumb {
    width: 120px !important;
    height: 120px !important;
    border-radius: 12px;
}

.supplier-image-path {
    word-break: break-all;
    unicode-bidi: plaintext;
    direction: ltr;
    text-align: left;
}

.supplier-image-actions {
    min-width: 0;
}

.location-picker-map {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #f5f5f5;
}

.location-picker-map--interactive {
    height: 280px;
    min-height: 220px;
    z-index: 0;
}

.location-picker-map iframe {
    display: block;
    width: 100%;
    height: 220px;
    border: 0;
}

.location-picker-saved-address,
.location-picker-map-address {
    word-break: break-word;
}

.location-picker-search {
    width: 100%;
}

@media (min-width: 960px) {
    .location-picker-map--interactive {
        height: 300px;
    }
}

/* ── Menu item variants editor ── */
.menu-item-variants-editor {
    border-color: rgba(91, 75, 180, 0.25) !important;
    background: linear-gradient(180deg, rgba(91, 75, 180, 0.04) 0%, #fff 100%);
}

.menu-item-variants-table-wrap {
    overflow-x: auto;
}

.menu-item-variants-actions-col {
    white-space: nowrap;
    width: 96px;
}

/* ── Mobile & tablet ── */
@media (max-width: 959.98px) {
    .admin-main {
        padding: 12px !important;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .admin-page-title {
        font-size: 1.25rem !important;
    }

    .admin-page-subtitle {
        font-size: 0.85rem !important;
    }

    .admin-hide-mobile {
        display: none !important;
    }

    .admin-user-chip {
        display: none !important;
    }

    .mud-button-root,
    .mud-icon-button {
        min-height: 44px;
        min-width: 44px;
    }

    .mud-button-root.mud-button-filled,
    .mud-button-root.mud-button-outlined {
        padding-inline: 14px;
    }

    .admin-toolbar .mud-button-root {
        flex: 1 1 auto;
        justify-content: center;
    }

    .admin-toolbar .mud-button-root {
        min-width: calc(50% - 0.5rem);
    }

    .mud-chip {
        max-width: 100%;
    }

    .mud-drawer {
        width: min(280px, 88vw) !important;
    }

    .mud-table-pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (min-width: 960px) {
    .admin-hide-desktop {
        display: none !important;
    }

    .admin-main {
        padding: 20px 24px !important;
    }
}

/* ── Blazor error UI ── */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}
