/* ========================================================================== 
   Park ERP shared components
   Loaded after legacy modules so canonical contracts win during migration.
   ========================================================================== */

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

.card-header,
.panel-header,
.ds-card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    background: transparent;
}

.card-header h2,
.panel-header h2,
.ds-card-header h2 {
    color: var(--color-text-strong);
}

.btn,
.ds-button,
button[class*="-btn"],
a[class*="-btn"],
button[class*="-button"],
a[class*="-button"] {
    min-height: var(--touch-target);
    border-radius: var(--radius-md);
}

.btn {
    width: auto;
    padding: 0.625rem 1rem;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    font-weight: 750;
}

.btn-primary {
    width: auto;
    border-color: var(--color-brand-600);
    background: linear-gradient(135deg, var(--color-brand-600), var(--color-brand-700));
    color: var(--color-on-brand);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover:not(:disabled) {
    border-color: var(--color-brand-700);
    background: linear-gradient(135deg, var(--color-brand-700), var(--color-brand-800));
    color: var(--color-on-brand);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.26);
}

.btn-secondary {
    border-color: var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text-strong);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--color-brand-300);
    background: var(--color-brand-50);
    color: var(--color-brand-800);
}

.btn-danger {
    border-color: var(--color-danger-border);
    background: var(--color-danger-surface);
    color: var(--color-danger-text);
}

.badge,
.ds-badge {
    min-height: 1.625rem;
    padding: 0.2rem 0.625rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    background: var(--color-surface-subtle);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 750;
    line-height: 1.35;
}

.badge-success {
    border-color: var(--color-success-border);
    background: var(--color-success-surface);
    color: var(--color-success-text);
}

.badge-warning {
    border-color: var(--color-warning-border);
    background: var(--color-warning-surface);
    color: var(--color-warning-text);
}

.badge-danger,
.badge-error {
    border-color: var(--color-danger-border);
    background: var(--color-danger-surface);
    color: var(--color-danger-text);
}

.badge-info {
    border-color: var(--color-info-border);
    background: var(--color-info-surface);
    color: var(--color-info-text);
}

.table-wrap,
.ds-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
    border-color: var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-xs);
}

table caption {
    padding: var(--space-3) var(--space-4);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 750;
    text-align: right;
}

th,
td {
    padding: var(--density-row-padding) var(--space-4);
    border-color: var(--color-border);
}

th {
    background: var(--color-surface-subtle);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 800;
}

tbody tr:hover {
    background: color-mix(in srgb, var(--color-brand-50) 55%, transparent);
}

.page-title,
.ui-page-title {
    margin-block: 0 var(--density-section-gap);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}

.page-title h1,
.ui-page-title h1 {
    margin: 0;
    color: var(--color-text-strong);
    font-size: clamp(1.4rem, 2vw, var(--font-size-2xl));
    font-weight: 850;
    letter-spacing: -0.025em;
}

.page-title p,
.ui-page-title p {
    max-width: 68ch;
    margin: var(--space-1) 0 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.ui-empty-state,
.empty-box,
.ds-empty-state {
    min-height: 12rem;
    padding: var(--space-8);
    display: grid;
    place-items: center;
    align-content: center;
    gap: var(--space-2);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
    background: var(--color-surface-subtle);
    color: var(--color-text-muted);
    text-align: center;
}

.ui-empty-state__icon {
    width: 3rem;
    height: 3rem;
    color: var(--color-brand-500);
}

.alert,
.ds-alert {
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

#toast-container {
    z-index: var(--z-toast);
    width: min(25rem, calc(100vw - 2rem));
}

.park-toast {
    position: relative;
    min-height: var(--touch-target);
    padding: 0.75rem 1rem;
    display: grid;
    grid-template-columns: 1.25rem minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-elevated);
    color: var(--color-text-strong);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
}

.park-toast--success { border-inline-start: 4px solid var(--color-success-600); }
.park-toast--error { border-inline-start: 4px solid var(--color-danger-600); }
.park-toast--warning { border-inline-start: 4px solid var(--color-warning-600); }
.park-toast--info { border-inline-start: 4px solid var(--color-info-600); }
.park-toast--payment { border-inline-start: 4px solid var(--color-violet-600); }
.park-toast__icon { width: 1.25rem; height: 1.25rem; color: currentColor; }
.park-toast__text { min-width: 0; overflow-wrap: anywhere; }
.park-toast__close {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}
.park-toast__close:hover { background: var(--color-surface-muted); color: var(--color-text-strong); }

.park-toast-progress-track {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--color-surface-strong);
}

.park-toast-progress {
    width: 100%;
    height: 100%;
    background: var(--color-brand-500);
    transform-origin: right center;
}

.ui-icon {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.ui-inline-icon {
    width: 1.15em;
    height: 1.15em;
    display: inline-block;
    flex: 0 0 auto;
    margin-inline: 0.1em;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    vertical-align: -0.18em;
}

.ui-filter-bar {
    display: grid;
    grid-template-columns: minmax(14rem, 1fr) repeat(2, minmax(9rem, 0.35fr)) auto;
    gap: var(--space-3);
    align-items: end;
    padding: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-xs);
}

.ui-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--space-3);
}

.ui-kpi {
    min-width: 0;
    padding: var(--space-4);
    display: grid;
    gap: var(--space-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-xs);
}

.ui-kpi > span,
.ui-kpi > small {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.ui-kpi > strong {
    color: var(--color-text-strong);
    font-size: var(--font-size-xl);
    font-weight: 850;
}

.ui-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

button:not([class*="switch"]):not([class*="toggle"]),
[role="button"],
summary,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    min-block-size: var(--touch-target);
}

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

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
    min-block-size: var(--touch-target);
}

table {
    max-width: 100%;
}

.ui-icon-button {
    width: var(--touch-target);
    height: var(--touch-target);
    padding: 0;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
}

.ui-icon-button:hover {
    border-color: var(--color-brand-300);
    background: var(--color-brand-50);
    color: var(--color-brand-700);
}

.kiosk-pairing-shell {
    max-width: 67.5rem;
    margin-inline: auto;
}

.ui-skeleton,
[data-skeleton] {
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--color-surface-muted), var(--color-surface-strong), var(--color-surface-muted));
    background-size: 220% 100%;
    animation: park-skeleton 1.5s ease-in-out infinite;
}

@keyframes park-skeleton {
    to { background-position: -220% 0; }
}

/* Semantic bridge for historical Tailwind color utilities across all routes. */
.bg-blue-50,
.bg-blue-100,
.bg-sky-50,
.bg-sky-100 { background-color: var(--color-info-surface); }
.text-blue-500,
.text-blue-600,
.text-blue-700,
.text-blue-800,
.text-sky-500,
.text-sky-600,
.text-sky-700,
.text-sky-800 { color: var(--color-info-text); }
.border-blue-100,
.border-blue-200,
.border-blue-300,
.border-sky-100,
.border-sky-200,
.border-sky-300 { border-color: var(--color-info-border); }

.bg-green-50,
.bg-green-100,
.bg-emerald-50,
.bg-emerald-100 { background-color: var(--color-success-surface); }
.text-green-600,
.text-green-700,
.text-green-800,
.text-emerald-600,
.text-emerald-700,
.text-emerald-800 { color: var(--color-success-text); }
.border-green-100,
.border-green-200,
.border-green-300,
.border-emerald-100,
.border-emerald-200,
.border-emerald-300 { border-color: var(--color-success-border); }

.bg-amber-50,
.bg-amber-100,
.bg-yellow-50,
.bg-yellow-100,
.bg-orange-50,
.bg-orange-100 { background-color: var(--color-warning-surface); }
.text-amber-600,
.text-amber-700,
.text-amber-800,
.text-yellow-600,
.text-yellow-700,
.text-yellow-800,
.text-orange-600,
.text-orange-700,
.text-orange-800 { color: var(--color-warning-text); }
.border-amber-100,
.border-amber-200,
.border-amber-300,
.border-yellow-100,
.border-yellow-200,
.border-yellow-300,
.border-orange-100,
.border-orange-200,
.border-orange-300 { border-color: var(--color-warning-border); }

.bg-red-50,
.bg-red-100,
.bg-rose-50,
.bg-rose-100 { background-color: var(--color-danger-surface); }
.text-red-500,
.text-red-600,
.text-red-700,
.text-red-800,
.text-rose-500,
.text-rose-600,
.text-rose-700,
.text-rose-800 { color: var(--color-danger-text); }
.border-red-100,
.border-red-200,
.border-red-300,
.border-rose-100,
.border-rose-200,
.border-rose-300 { border-color: var(--color-danger-border); }

.bg-indigo-50,
.bg-indigo-100,
.bg-purple-50,
.bg-purple-100,
.bg-violet-50,
.bg-violet-100 { background-color: var(--color-violet-surface); }
.text-indigo-600,
.text-indigo-700,
.text-indigo-800,
.text-purple-600,
.text-purple-700,
.text-purple-800,
.text-violet-600,
.text-violet-700,
.text-violet-800 { color: var(--color-violet-text); }
.border-indigo-100,
.border-indigo-200,
.border-purple-100,
.border-purple-200,
.border-violet-100,
.border-violet-200 { border-color: var(--color-violet-border); }

.bg-cyan-50,
.bg-cyan-100,
.bg-teal-50,
.bg-teal-100 { background-color: var(--color-accent-surface); }
.text-cyan-600,
.text-cyan-700,
.text-cyan-800,
.text-teal-600,
.text-teal-700,
.text-teal-800 { color: var(--color-accent-text); }
.border-cyan-100,
.border-cyan-200,
.border-teal-100,
.border-teal-200 { border-color: var(--color-accent-border); }

.hover\:bg-blue-100:hover,
.hover\:bg-blue-50:hover { background-color: var(--color-info-surface); }
.hover\:bg-green-100:hover,
.hover\:bg-emerald-100:hover { background-color: var(--color-success-surface); }
.hover\:bg-red-100:hover,
.hover\:bg-rose-50:hover { background-color: var(--color-danger-surface); }
.hover\:bg-slate-50:hover,
.hover\:bg-slate-100:hover { background-color: var(--color-surface-muted); }

/* Dark-theme compatibility for the most common historical Tailwind utilities. */
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-white\/70,
html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-gray-50 {
    background-color: var(--color-surface) !important;
}

html[data-theme="dark"] .bg-slate-100,
html[data-theme="dark"] .bg-gray-100 {
    background-color: var(--color-surface-muted) !important;
}

html[data-theme="dark"] .text-slate-900,
html[data-theme="dark"] .text-slate-800,
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-gray-800 {
    color: var(--color-text-strong) !important;
}

html[data-theme="dark"] .text-slate-700,
html[data-theme="dark"] .text-slate-600,
html[data-theme="dark"] .text-gray-700,
html[data-theme="dark"] .text-gray-600 {
    color: var(--color-text) !important;
}

html[data-theme="dark"] .text-slate-500,
html[data-theme="dark"] .text-slate-400,
html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-400 {
    color: var(--color-text-muted) !important;
}

html[data-theme="dark"] .border-slate-100,
html[data-theme="dark"] .border-slate-200,
html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-200 {
    border-color: var(--color-border) !important;
}

@media (max-width: 640px) {
    .page-title,
    .ui-page-title {
        flex-direction: column;
    }

    .ui-filter-bar {
        grid-template-columns: 1fr;
    }

    .ui-dialog-actions {
        flex-direction: column-reverse;
    }

    .ui-dialog-actions > * {
        width: 100%;
    }
}
