/* Compatibility component layer. Canonical values live in tokens.css. */

/* ========================================================================== 
   Park ERP compatibility components
   Historical shared selectors retained while route-level styles migrate.
   Canonical values are defined only in tokens.css.
   ========================================================================== */

@font-face {
    font-family: "Vazirmatn";
    src: url("/font/Vazirmatn-VariableFont_wght.ttf") format("truetype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

html.sidebar-compact {
    --sidebar-width: var(--sidebar-width-compact);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--color-canvas);
    font-family: var(--font-sans);
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--color-canvas);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-md);
    line-height: var(--line-height-normal);
    overscroll-behavior: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
input,
select {
    touch-action: manipulation;
}

button,
[role="button"],
a,
summary {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--color-info-700);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--color-info-600);
}

img,
svg {
    max-width: 100%;
}

hr {
    border: 0;
    border-top: 1px solid var(--color-border);
}

code,
kbd,
pre,
samp,
.direction-ltr,
.ltr {
    direction: ltr;
    font-family: var(--font-mono);
    text-align: left;
}

code {
    overflow-wrap: anywhere;
}

::selection {
    background: var(--color-brand-100);
    color: var(--color-brand-800);
}

:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}

[aria-disabled="true"],
:disabled {
    cursor: not-allowed;
}

.touch-target {
    min-height: var(--touch-target);
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--color-text-muted);
}

/* Shared form contract */
.ds-input,
.ds-select,
.ds-textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select,
textarea {
    max-width: 100%;
    min-height: var(--control-height);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-strong);
    transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease, background var(--motion-fast) ease;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select,
textarea {
    padding: 0.68rem 0.78rem;
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-subtle);
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
    border-color: var(--color-text-subtle);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-brand-500);
    box-shadow: var(--focus-ring);
    outline: 0;
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly],
textarea[readonly] {
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--color-brand-600);
}

/* Shared surfaces */
.card,
.panel,
.surface,
.ds-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-xs);
}

.ds-card-header,
.panel-header,
.card-header {
    border-bottom: 1px solid var(--color-border);
}

.table-wrap,
.ds-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
}

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

th {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 800;
    text-align: right;
}

th,
td {
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: rgba(248, 250, 252, 0.8);
}

/* Shared button contract. Existing module classes can opt in by matching suffixes. */
.ds-button,
.btn,
button[class*="-btn"],
a[class*="-btn"],
button[class*="-button"],
a[class*="-button"] {
    min-height: 2.45rem;
    border-radius: var(--radius-md);
    transition: transform var(--motion-fast) ease, background var(--motion-fast) ease, border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}

.ds-button:hover:not(:disabled),
.btn:hover:not(:disabled),
button[class*="-btn"]:hover:not(:disabled),
a[class*="-btn"]:hover,
button[class*="-button"]:hover:not(:disabled),
a[class*="-button"]:hover {
    transform: translateY(-1px);
}

.ds-button:active:not(:disabled),
.btn:active:not(:disabled),
button[class*="-btn"]:active:not(:disabled),
a[class*="-btn"]:active,
button[class*="-button"]:active:not(:disabled),
a[class*="-button"]:active {
    transform: translateY(0);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    padding: 0.55rem 0.9rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}
.btn:disabled { cursor: not-allowed; opacity: 0.58; }
.btn-primary { border-color: var(--color-brand-600); background: var(--color-brand-600); color: var(--color-on-brand); }
.btn-primary:hover:not(:disabled) { background: var(--color-brand-700); color: var(--color-on-brand); }
.btn-secondary { border-color: var(--color-border-strong); background: var(--color-surface); color: var(--color-text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--color-text-muted); background: var(--color-surface-subtle); color: var(--color-text-strong); }
.btn-danger { border-color: var(--color-danger-600); background: var(--color-danger-50); color: var(--color-danger-700); }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-600); color: var(--color-on-brand); }

.form-field { display: grid; gap: 0.35rem; }
.form-field > span { color: var(--color-text-secondary); font-size: var(--font-size-xs); font-weight: 800; }
.form-field > span b { color: var(--color-danger-600); }
.form-field > span small,
.form-field > small { color: var(--color-text-subtle); font-size: 0.75rem; line-height: 1.6; }
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: var(--control-height);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.62rem 0.75rem;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--color-brand-600); box-shadow: var(--focus-ring); outline: 0; }
.form-field input:invalid:not(:placeholder-shown) { border-color: var(--color-danger-600); }

/* Shared semantic notices */
.alert,
.ds-alert {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.78rem 0.92rem;
}

.alert-info,
.ds-alert--info {
    border-color: var(--color-info-text);
    background: var(--color-info-50);
    color: var(--color-info-text);
}

.alert-success,
.ds-alert--success {
    border-color: var(--color-success-text);
    background: var(--color-success-50);
    color: var(--color-success-text);
}

.alert-warning,
.ds-alert--warning {
    border-color: var(--color-warning-text);
    background: var(--color-warning-50);
    color: var(--color-warning-text);
}

.alert-error,
.alert-danger,
.ds-alert--danger {
    border-color: var(--color-danger-text);
    background: var(--color-danger-50);
    color: var(--color-danger-text);
}

.badge,
.ds-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.55rem;
    padding-inline: 0.58rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    background: var(--color-surface-subtle);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 800;
    white-space: nowrap;
}

/* HTMX */
.htmx-indicator {
    display: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-normal) ease;
}

.htmx-request .htmx-indicator,
.htmx-indicator.htmx-request {
    display: inline-flex;
    opacity: 1;
}

#page-content {
    transition: opacity 150ms ease-in-out;
}

#page-content.htmx-swapping {
    opacity: 0;
}

#page-content.htmx-settling {
    opacity: 1;
}

#htmx-loading {
    pointer-events: none;
}

/* Toast contract */
#toast-container {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 99999;
    display: grid;
    gap: 0.5rem;
    pointer-events: none;
}

#toast-container > * {
    pointer-events: auto;
}


.park-toast {
    position: relative;
    overflow: hidden;
}

.park-toast-progress-track {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.18);
    pointer-events: none;
}

.park-toast-progress {
    display: block;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.86);
    transform: scaleX(0);
    transform-origin: right center;
    will-change: transform;
}

/* Modal contract */
.ds-modal,
[class$="-modal"] {
    overscroll-behavior: contain;
}

body.modal-open,
body.settings-modal-open,
body.a13b-modal-open {
    overflow: hidden;
}

/* Scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-text-subtle) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--color-surface-strong);
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--color-surface-strong);
    background-clip: padding-box;
}

@media (max-width: 700px) {
    :root {
        --header-height: 3.75rem;
        --radius-lg: 1rem;
        --radius-xl: 1.15rem;
    }

    body {
        font-size: 0.88rem;
    }
}

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

@media print {
    :root {
        --color-canvas: var(--color-surface);
        --shadow-xs: none;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
    }

    body {
        background: var(--color-surface);
    }
}

/* Shared application logo */
.app-logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.app-logo-svg {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    filter: drop-shadow(0 10px 18px rgba(15, 23, 42, 0.16));
    transition: filter var(--motion-normal) ease;
}

.brand-link:hover .app-logo-svg {
    filter: drop-shadow(0 12px 22px rgba(37, 99, 235, 0.24));
}

.pos-layout-body {
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
}

.pos-layout-header {
    min-height: 3.5rem;
    background: linear-gradient(135deg, var(--color-surface-inverse), var(--color-info-solid));
}

.kiosk-layout-body {
    background: var(--color-surface-inverse);
    color: var(--color-on-brand);
    font-size: 1.125rem;
}

.kiosk-layout-body .kiosk-card {
    border-color: rgba(255, 255, 255, 0.1);
    background: var(--color-info-solid);
    color: var(--color-on-brand);
}

.kiosk-layout-body .balance-large {
    font-size: clamp(2.4rem, 8vw, 3rem);
    font-weight: 800;
}

/* Native progress contract used by dashboards and operational summaries. */
.ui-progress {
    display: block;
    width: 100%;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius-pill);
    appearance: none;
    background: rgba(148, 163, 184, 0.24);
    color: var(--color-info-500);
}
.ui-progress.is-blue { color: var(--color-info-500); }
.ui-progress.is-violet { color: var(--color-violet-600); }
.ui-progress.is-on-dark { background: rgba(255, 255, 255, 0.28); color: var(--color-surface); }
.ui-progress::-webkit-progress-bar { border-radius: inherit; background: transparent; }
.ui-progress::-webkit-progress-value { border-radius: inherit; background: currentColor; }
.ui-progress::-moz-progress-bar { border-radius: inherit; background: currentColor; }
.ui-modal-layer { z-index: 9998; }
.sales-chart-bar-fill { min-height: 2px; height: var(--chart-height, 2px); }

/* Shared, accessible contextual help drawer. */
.ui-help-trigger {
    display: inline-grid;
    width: 1.6rem;
    height: 1.6rem;
    place-items: center;
    margin-inline-start: 0.35rem;
    border: 1px solid var(--color-border, var(--color-border-strong));
    border-radius: 999px;
    background: var(--color-surface, var(--color-surface));
    color: var(--color-primary-700, var(--color-danger-text));
    font-weight: 800;
    line-height: 1;
    cursor: help;
}
.ui-help-trigger:hover { background: var(--color-surface-subtle); border-color: var(--color-danger-text); }
.ui-help-trigger:focus-visible,
.ui-help-close:focus-visible {
    outline: 3px solid rgba(166, 38, 38, 0.28);
    outline-offset: 2px;
}
.ui-help-layer[hidden] { display: none; }
.ui-help-layer { position: fixed; inset: 0; z-index: 10010; }
.ui-help-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(15, 23, 42, 0.48); }
.ui-help-drawer {
    position: absolute;
    inset-block: 0;
    inset-inline-end: 0;
    width: min(28rem, 92vw);
    overflow: auto;
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: -16px 0 40px rgba(15, 23, 42, 0.22);
}
.ui-help-drawer__header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}
.ui-help-drawer__header h2 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.ui-help-close { width: 2.5rem; height: 2.5rem; border: 0; border-radius: 0.6rem; background: var(--color-surface-muted); font-size: 1.5rem; cursor: pointer; }
.ui-help-drawer__body { display: grid; gap: 1rem; padding: 1.25rem; line-height: 1.9; }
.ui-help-drawer__body section { padding: 1rem; border-radius: 0.75rem; background: var(--color-surface-subtle); }
.ui-help-drawer__body h3 { margin: 0 0 0.4rem; font-size: 0.95rem; font-weight: 800; }
.ui-help-warning { border: 1px solid var(--color-warning-border); background: var(--color-surface-subtle) !important; color: var(--color-danger-text); }
.ui-help-open { overflow: hidden; }
.ui-empty-state { min-height: 12rem; text-align: center; }
