/*
 * CostMint global styles.
 *
 * The theme itself lives in Theme/CostMintTheme.cs; this file covers only what MudBlazor's
 * theming cannot reach - the pre-Blazor splash, the error bar, scrollbars, and a few layout
 * refinements that keep surfaces reading as bordered cards rather than floating shadows.
 */

html, body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent the iOS zoom-on-focus that fires for inputs under 16px. */
@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        font-size: 16px;
    }
}

/* ---- Splash shown before the WASM runtime boots ---- */

.costmint-splash {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #f8fafc;
    color: #0f172a;
}

.costmint-splash__mark {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.costmint-splash__name {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.costmint-splash__bar {
    width: 132px;
    height: 3px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.costmint-splash__bar span {
    display: block;
    width: 40%;
    height: 100%;
    border-radius: 999px;
    background: #10b981;
    animation: costmint-slide 1.1s ease-in-out infinite;
}

@keyframes costmint-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

@media (prefers-color-scheme: dark) {
    .costmint-splash { background: #0b1220; color: #f1f5f9; }
    .costmint-splash__bar { background: #1e293b; }
}

/* ---- App bar ---- */

/*
 * While the sidebar is open the brand block heads the drawer column, so the toolbar gives up its
 * left gutter and lets the block start at the viewport edge. The gutter is 16px but widens to 24px
 * from sm up, so cancelling it with a fixed negative margin leaves the block's right border sitting
 * a few pixels past the drawer's.
 */
.costmint-appbar--branded > .mud-toolbar {
    padding-left: 0;
}

/* ---- Surfaces ---- */

/* Borders and a whisper of shadow, rather than heavy elevation. */
.costmint-card {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.costmint-card--interactive:hover {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
}

/* Right-align money and quantities so decimal points line up down a column. */
.costmint-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Large dashboard figures read better with even digit widths. */
.costmint-metric {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* The recipe total stays in view while the ingredient list scrolls. */
.costmint-sticky-summary {
    position: sticky;
    top: 88px;
}

@media (max-width: 960px) {
    .costmint-sticky-summary {
        position: static;
    }
}

/* ---- Scrollbars ---- */

* {
    scrollbar-width: thin;
    scrollbar-color: var(--mud-palette-lines-inputs) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }

*::-webkit-scrollbar-thumb {
    background-color: var(--mud-palette-lines-inputs);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover { background-color: var(--mud-palette-text-secondary); }

/* ---- Blazor's unhandled-error bar ---- */

#blazor-error-ui {
    background: #fef3c7;
    color: #78350f;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
    font-size: 14px;
}

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

/* ---- Print ---- */

@media print {
    .mud-appbar, .mud-drawer, .costmint-no-print { display: none !important; }
    .mud-main-content { padding: 0 !important; margin: 0 !important; }
    .costmint-card { box-shadow: none; border-color: #cbd5e1; break-inside: avoid; }
}

/* ---------- Point of sale ---------- */

/* Tiles size themselves to the screen: four across on a laptop, two on a phone. */
.costmint-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.costmint-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px;
    min-height: 104px;
    cursor: pointer;
    user-select: none;
    transition: border-color 120ms ease, transform 120ms ease;
}

.costmint-tile:hover,
.costmint-tile:focus-visible {
    border-color: var(--mud-palette-primary);
    transform: translateY(-1px);
}

.costmint-tile__name {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.25;
}

.costmint-tile__variant {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.costmint-tile__price {
    margin-top: auto;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* How many are already in the cart, so a second tap is obviously a second one. */
.costmint-tile__count {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.costmint-cart-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.costmint-cart-line__name {
    flex: 1 1 auto;
    min-width: 0;
}

.costmint-cart-line__qty {
    min-width: 24px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.costmint-cart-line__total {
    min-width: 72px;
    text-align: right;
    font-weight: 500;
}

/* ---------- Receipt ---------- */

.costmint-receipt {
    font-size: 0.875rem;
}

.costmint-receipt__head {
    text-align: center;
    margin-bottom: 8px;
}

.costmint-receipt__ref {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.costmint-receipt__meta {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.costmint-receipt__line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
}

.costmint-receipt__total {
    font-weight: 700;
    font-size: 1rem;
    padding-top: 8px;
}

.costmint-receipt__foot {
    text-align: center;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

/* Printing a receipt should put the receipt on the paper, not the application around it. */
@media print {
    .costmint-receipt {
        font-size: 12pt;
    }
}
