/* Meryego shared visual QA layer. This preserves each workspace theme while
   standardizing interaction, accessibility, overflow, and responsive behavior. */
:root {
    --ui-coral: var(--coral, var(--orange, #f2684a));
    --ui-coral-dark: var(--coral-dark, var(--orange-dark, #d95135));
    --ui-navy: var(--navy, #172f38);
    --ui-green: var(--green, #176149);
    --ui-ink: var(--ink, #243238);
    --ui-muted: var(--muted, #6c7a7e);
    --ui-line: var(--line, #dfe5e3);
    --ui-canvas: var(--canvas, var(--cream, #f5f6f3));
    --ui-surface: var(--paper, var(--surface, #fff));
    --ui-danger: var(--danger, #b93c43);
    --ui-warning: var(--warning, #9d6715);
    --ui-radius-control: 10px;
    --ui-radius-card: 16px;
    --ui-radius-dialog: 18px;
    --ui-shadow-soft: 0 5px 20px rgba(23, 47, 56, .055);
    --ui-focus: 0 0 0 3px color-mix(in srgb, var(--ui-coral) 18%, transparent);
}

html { color-scheme: light; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 0; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, [role="button"], a { -webkit-tap-highlight-color: transparent; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid color-mix(in srgb, var(--ui-coral) 34%, transparent);
    outline-offset: 2px;
}
:where(input, select, textarea):focus-visible { border-color: var(--ui-coral) !important; box-shadow: var(--ui-focus) !important; }
:where(input, select, textarea)::placeholder { color: color-mix(in srgb, var(--ui-muted) 74%, white); opacity: 1; }
:where(input, select, textarea):disabled,
:where(input, select, textarea)[readonly] { background: #f1f3f2; border-color: var(--ui-line); color: var(--ui-muted); cursor: not-allowed; opacity: 1; }
:where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--ui-coral); }
:where(input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"]) { min-height: 42px; color-scheme: light; }
input[type="file"] { min-height: 44px; padding: 5px !important; line-height: 32px; }
input[type="file"]::file-selector-button { min-height: 32px; margin-right: 10px; padding: 0 12px; border: 1px solid var(--ui-line); border-radius: 8px; background: var(--ui-canvas); color: var(--ui-ink); font-weight: 700; cursor: pointer; }

:where(.button, .admin-button, .customer-button, .rider-button, .analytics-button) {
    min-height: 42px; border-radius: var(--ui-radius-control); line-height: 1.2; text-align: center;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
:where(.button, .admin-button, .customer-button, .rider-button, .analytics-button):hover:not(:disabled):not([aria-disabled="true"]) { filter: saturate(1.03); }
:where(.button, .admin-button, .customer-button, .rider-button, .analytics-button):active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(0); }
:where(button, .button, .admin-button, .customer-button, .rider-button, .analytics-button):disabled,
:where(.button, .admin-button, .customer-button, .rider-button, .analytics-button)[aria-disabled="true"] { box-shadow: none !important; cursor: not-allowed !important; filter: grayscale(.12); opacity: .52 !important; transform: none !important; }
:where(.button-small, .admin-button.small) { min-height: 34px; }
:where(.icon-button, [data-dismiss-alert], [data-modal-close], [data-close-modal]) { min-width: 40px; min-height: 40px; display: inline-grid; place-items: center; }

:where(.admin-card, .tracking-card, .account-card, .support-card, .analytics-panel, .pos-cart) { min-width: 0; border-color: var(--ui-line); box-shadow: var(--ui-shadow-soft); }
:where(.admin-grid, .dashboard-grid, .analytics-grid, .merchant-grid, .checkout-layout, .tracking-layout) > * { min-width: 0; }
:where(.table-wrap, .admin-table-wrap, .analytics-table-wrap, .pos-table-wrap) { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-color: #c3ccca transparent; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
:where(.table-wrap, .admin-table-wrap, .analytics-table-wrap, .pos-table-wrap)::-webkit-scrollbar { height: 8px; }
:where(.table-wrap, .admin-table-wrap, .analytics-table-wrap, .pos-table-wrap)::-webkit-scrollbar-thumb { border-radius: 10px; background: #c3ccca; }
:where(.data-table, .admin-table, .analytics-table, .pos-table) { font-variant-numeric: tabular-nums; }
:where(.data-table, .admin-table, .analytics-table, .pos-table) tbody tr { transition: background-color .14s ease; }
:where(.data-table, .admin-table, .analytics-table, .pos-table) tbody tr:hover { background: #fafbf9; }

:where(.badge, .status-badge, .delivery-badge, .tracking-status, .support-status, .support-priority, .pos-stock-badge, .chat-status) {
    min-height: 24px; padding: 5px 9px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px; font-size: 10px; font-weight: 800; line-height: 1.15; letter-spacing: .025em; white-space: nowrap;
}
:where(.status-badge, .delivery-badge):is(.accepted, .approved, .verified, .active, .paid, .delivered, .completed, .resolved, .closed) { background: #e8f5f0; color: #176149; }
:where(.status-badge, .delivery-badge):is(.pending, .pending_verification, .preparing, .ready_for_pickup, .unpaid, .open, .processing) { background: #fff4de; color: #8a5a0f; }
:where(.status-badge, .delivery-badge):is(.rider_assigned, .picked_up, .on_the_way, .reviewed) { background: #edf3fa; color: #315f86; }
:where(.status-badge, .delivery-badge):is(.cancelled, .rejected, .inactive, .unverified, .suspended, .problem) { background: #fff0f0; color: #a5363d; }

:where(.field-error, .form-error, .input-error, [data-field-error]) { color: var(--ui-danger); font-size: 11px; font-weight: 700; line-height: 1.4; }
:where(.admin-help, .field-help, .form-help, .helper-text) { color: var(--ui-muted); font-size: 11px; line-height: 1.45; }

dialog { width: min(560px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); margin: auto; border: 0; border-radius: var(--ui-radius-dialog); background: var(--ui-surface); color: var(--ui-ink); box-shadow: 0 24px 70px rgba(15, 31, 39, .24); overflow: auto; }
dialog::backdrop { background: rgba(15, 31, 39, .52); backdrop-filter: blur(2px); }
:where(.modal-head, .modal-header) { position: sticky; top: 0; z-index: 2; background: var(--ui-surface); }
:where(.modal-actions, .modal-footer) { position: sticky; bottom: 0; z-index: 2; background: #fafbf9; }
:where(.admin-profile > div, .notification-dropdown, .profile-dropdown, .dropdown-menu) { max-width: calc(100vw - 24px); max-height: min(480px, calc(100dvh - 88px)); overflow: auto; }
:where(.empty-admin, .customer-empty, .rider-empty-small, .rider-empty-page, .empty-state) { line-height: 1.55; }

[aria-busy="true"], .is-loading { cursor: progress; }
:where(button, .button, .admin-button, .customer-button, .rider-button).is-loading::before { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; content: ""; animation: meryego-spin .7s linear infinite; }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, #edf0ef 25%, #f7f8f7 45%, #edf0ef 65%); background-size: 220% 100%; animation: meryego-skeleton 1.2s ease-in-out infinite; color: transparent !important; }

:where(.leaflet-container, [data-map], .tracking-map, .route-map) { max-width: 100%; isolation: isolate; }
.leaflet-control-container { font-family: "DM Sans", sans-serif; }
.merchant-sidebar, .sidebar { min-height: 0; }
.sidebar-nav { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sidebar-nav::-webkit-scrollbar, .admin-sidebar nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track, .admin-sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb, .admin-sidebar nav::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(255,255,255,.22); }

@keyframes meryego-spin { to { transform: rotate(360deg); } }
@keyframes meryego-skeleton { to { background-position: -120% 0; } }

@media (max-width: 899px) {
    :where(.customer-main, .merchant-main, .rider-main, .admin-main) { min-width: 0; }
    :where(.simple-page-head, .customer-section-head, .page-head, .rider-page-head, .admin-page-head) { min-width: 0; }
    .mobile-nav, .rider-nav { grid-template-columns: none !important; grid-auto-flow: column; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; }
    .mobile-nav { grid-auto-columns: minmax(56px, 1fr); }
    .rider-nav { grid-auto-columns: minmax(48px, 1fr); }
    .mobile-nav::-webkit-scrollbar, .rider-nav::-webkit-scrollbar { display: none; }
    .mobile-nav a, .rider-nav a, .customer-bottom-nav a { min-width: 0; min-height: 48px; padding-inline: 3px; }
    .mobile-nav a, .rider-nav a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 640px) {
    :where(.simple-page-head, .page-head, .rider-page-head, .admin-page-head) { align-items: flex-start; flex-direction: column; }
    :where(.simple-page-head, .page-head, .rider-page-head, .admin-page-head) > :last-child:not(:only-child) { max-width: 100%; }
    :where(.admin-actions, .page-actions, .form-actions, .modal-actions, .modal-footer) { flex-wrap: wrap; }
    :where(.admin-actions, .page-actions) > :where(button, a, .button, .admin-button) { flex: 1 1 140px; }
    :where(.filter-actions, .modal-actions, .modal-footer) > :where(button, a, .button, .admin-button, .customer-button, .rider-button) { min-width: 0; }
    dialog { width: calc(100vw - 20px); max-width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 15px; }
    :where(.modal-body, .modal-head, .modal-header, .modal-actions, .modal-footer) { padding-inline: 16px; }
    .admin-row-menu > div { width: min(330px, calc(100vw - 24px)); right: 0; }
    .chat-composer, .chat-input-row { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (max-width: 390px) {
    .customer-header-inner { padding-inline: 12px; gap: 8px; }
    .header-cart > span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
    .customer-main, .rider-main, .admin-main { padding-inline: 12px; }
    .customer-bottom-nav a { font-size: 8px; }
    .active-progress { padding-inline: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
