/* ===========================================================================
   SawSoft.Web — mobilní klient (handheld / tablet)
   Design tokeny přenesené z WPF DesignTokens.xaml, aby appka ladila s desktopem.
   Mobile-first, velké dotykové cíle (min. 44 px, PIN klávesy ~64 px).
   =========================================================================== */

:root {
    /* Primární (modrá) */
    --primary: #2D89EF;
    --primary-600: #1F75D7;
    --primary-700: #155CB0;
    --primary-100: #D7E7FD;
    --primary-50: #EBF3FE;
    /* Stavové */
    --success: #27AE60;
    --danger: #E74C3C;
    --danger-700: #C0392B;
    --warning: #F39C12;
    /* Povrchy a text */
    --bg: #F5F6F8;
    --surface: #FFFFFF;
    --text: #111827;   /* N.900 */
    --muted: #6B7280;  /* N.500 */
    --border: #DDE1E6; /* N.200 */
    --n-100: #ECEEF1;
    /* Rozměry */
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 1px 2px rgba(17, 24, 39, .06);
    --shadow-lg: 0 10px 30px rgba(17, 24, 39, .12);
    --tap: 48px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

#app { height: 100%; }

h1, h2, h3 { margin: 0; font-weight: 600; }
h1:focus { outline: none; }

.page-title { font-size: 1.5rem; margin: .25rem 0 1rem; }
.text-muted { color: var(--muted); }

/* ---- Tlačítka -------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .12s ease, opacity .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-block { display: flex; width: 100%; margin-top: 1rem; }

.btn-primary { background: var(--primary); border-color: var(--primary-600); color: #fff; }
.btn-primary:not(:disabled):active { background: var(--primary-700); }

.btn-danger { background: var(--danger); border-color: var(--danger-700); color: #fff; }
.btn-danger:not(:disabled):active { background: var(--danger-700); }

/* ===========================================================================
   Přihlašovací obrazovka
   =========================================================================== */
.login-screen {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
}

.login-logo {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-600);
    text-align: center;
    letter-spacing: .5px;
    margin-bottom: 1rem;
}

.login-subtitle { color: var(--muted); text-align: center; margin-bottom: 1rem; }

.login-status { text-align: center; padding: .75rem; color: var(--muted); }
.login-status--warn { color: var(--warning); }
.login-status--err  { color: var(--danger); font-weight: 600; }

/* Dlaždice uživatelů */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .75rem;
}

.user-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 1rem .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    min-height: 110px;
    justify-content: center;
}
.user-tile:active { background: var(--primary-50); }

.user-name { font-weight: 600; text-align: center; line-height: 1.2; }

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary-700);
    font-weight: 700;
}
.user-avatar--lg { width: 56px; height: 56px; font-size: 1.25rem; }

/* Krok PIN */
.login-back {
    border: none;
    background: none;
    color: var(--primary-600);
    font-size: 1rem;
    font-weight: 600;
    padding: .25rem 0;
    cursor: pointer;
}

.login-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    margin: .5rem 0 1rem;
}
.login-selected-name { font-weight: 600; font-size: 1.1rem; }

.pin-dots {
    display: flex;
    justify-content: center;
    gap: .6rem;
    margin: .5rem 0 1rem;
    min-height: 18px;
}
.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    transition: background-color .1s ease, border-color .1s ease;
}
.pin-dot--on { background: var(--primary); border-color: var(--primary); }
.pin-dot--min { border-color: var(--primary-100); } /* 4. tečka = minimum */

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .6rem;
    margin-top: .5rem;
}
.pin-key {
    min-height: 64px;
    font-size: 1.5rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.pin-key:not(:disabled):active { background: var(--primary-50); }
.pin-key--util { color: var(--muted); font-size: 1.25rem; }

/* ===========================================================================
   Aplikační shell (po přihlášení)
   =========================================================================== */
.app-shell {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}
.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: .75rem;
    height: 56px;
    padding: 0 1rem;
    background: var(--primary-600);
    color: #fff;
    box-shadow: var(--shadow);
}
.app-brand { font-weight: 700; letter-spacing: .5px; }
.app-user { margin-left: auto; font-weight: 600; opacity: .95; }
.btn-logout {
    min-height: 36px;
    padding: 0 .75rem;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: var(--radius-sm);
    background: transparent;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.btn-logout:active { background: rgba(255, 255, 255, .15); }

.app-body { flex: 1; padding: 1rem; }

/* Menu na úvodní obrazovce */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.menu-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 120px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
}
.menu-tile:active { background: var(--primary-50); }
.menu-icon { font-size: 2rem; line-height: 1; }
.menu-label { font-weight: 600; }

.notfound { text-align: center; padding: 2rem 1rem; }
.notfound .btn { margin-top: 1rem; }

/* ===========================================================================
   Sken + karta balíku (sdílené se Skladem/Hledáním)
   =========================================================================== */
.scan-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.scan-input {
    flex: 1;
    min-height: var(--tap);
    padding: 0 .9rem;
    font-size: 1.05rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
}
.scan-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.scan-go { flex: 0 0 auto; }

.scan-status { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }
.scan-status--empty { color: var(--danger); font-weight: 600; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}
.card + .card { margin-top: 1rem; }
.card--info { border-left: 4px solid var(--primary); }
.card--danger { border-left: 4px solid var(--danger); }

.card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card-title { font-size: 1.25rem; font-weight: 700; }

.chip {
    margin-left: auto;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.chip--ok     { background: #E7F6EE; color: var(--success); }
.chip--warn   { background: #FDF1DE; color: #B9770E; }
.chip--danger { background: #FDE7E4; color: var(--danger-700); }
.chip--muted  { background: var(--n-100); color: var(--muted); }

.card-metrics { display: flex; gap: 1.5rem; padding: .25rem 0 .75rem; }
.metric { display: flex; align-items: baseline; gap: .3rem; }
.metric-val { font-size: 1.5rem; font-weight: 700; color: var(--primary-700); }
.metric-lbl { color: var(--muted); }

.kv-list { border-top: 1px solid var(--n-100); padding-top: .5rem; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; font-weight: 600; }

.items { margin-top: .75rem; border-top: 1px solid var(--n-100); }
.items-empty { color: var(--muted); padding: .75rem 0; text-align: center; }
.item-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--n-100);
}
.item-row:last-child { border-bottom: none; }
.item-row--spent { opacity: .5; text-decoration: line-through; }
.item-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.item-name { font-weight: 600; }
.item-dim { color: var(--muted); font-size: .9rem; }
.item-qty { text-align: right; display: flex; flex-direction: column; gap: .1rem; white-space: nowrap; }
.item-vol { color: var(--muted); font-size: .9rem; }

/* ===========================================================================
   Formulář příjmu
   =========================================================================== */
.form { display: flex; flex-direction: column; gap: 1rem; }
.chip-row { display: flex; }
.chip-row .chip { margin-left: 0; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field-lbl { color: var(--muted); font-weight: 600; }

.select, .num-input {
    min-height: var(--tap);
    padding: 0 .75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    width: 100%;
}
.select:focus, .num-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.assort { display: flex; flex-direction: column; gap: .75rem; }
.assort-head { font-weight: 700; }
.assort-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.assort-top { display: flex; gap: .5rem; align-items: center; }
.assort-top .select { flex: 1; }
.row-del {
    flex: 0 0 auto;
    width: var(--tap); height: var(--tap);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--danger);
    font-size: 1.1rem;
    cursor: pointer;
}
.row-del:disabled { opacity: .4; }

.dim-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.dim-grid label { display: flex; flex-direction: column; gap: .2rem; }
.dim-grid span { color: var(--muted); font-size: .8rem; text-align: center; }
.dim-grid .num-input { text-align: center; padding: 0 .3rem; }

.done { text-align: center; padding: 1.5rem 1rem; }
.done-icon {
    width: 64px; height: 64px; margin: 0 auto .5rem;
    border-radius: 50%;
    background: #E7F6EE; color: var(--success);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 700;
}
.done-title { color: var(--muted); }
.done-code { font-size: 1.6rem; font-weight: 700; color: var(--primary-700); }

/* ===========================================================================
   Hledání / přehled skladu
   =========================================================================== */
.search-controls { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.search-wh { flex: 0 0 auto; }
.search-count { color: var(--muted); font-weight: 600; margin-bottom: .5rem; }

.row-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .75rem 1rem;
    margin-bottom: .5rem;
    cursor: pointer;
}
.row-card--open { border-color: var(--primary); }
.row-line { display: flex; align-items: center; gap: .5rem; }
.row-code { font-weight: 700; font-size: 1.05rem; }
.row-sub { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); margin-top: .25rem; font-size: .9rem; }
.row-card--open + .card { margin-top: 0; margin-bottom: .75rem; border-top-left-radius: 0; border-top-right-radius: 0; }

/* ===========================================================================
   Výdej / prodej
   =========================================================================== */
.partner-list { margin-top: .75rem; display: flex; flex-direction: column; }
.partner-list .row-card { text-align: left; width: 100%; }

.cart-partner {
    display: flex; align-items: center; gap: .5rem;
    padding: .6rem .9rem; margin-bottom: .75rem;
    background: var(--primary-50); border-radius: var(--radius-sm);
    font-weight: 700;
}
.cart-partner > span:first-child { flex: 1; }

.link-btn {
    border: none; background: none; color: var(--primary-600);
    font-weight: 600; cursor: pointer; padding: .1rem .2rem; font-size: .9rem;
}

.pick-row {
    display: flex; flex-direction: column; gap: .1rem; align-items: flex-start;
    width: 100%; text-align: left;
    padding: .6rem 0; border: none; border-bottom: 1px solid var(--n-100);
    background: none; cursor: pointer;
}
.pick-row:last-child { border-bottom: none; }

.pending-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .5rem 0; }
.pending-grid label { display: flex; flex-direction: column; gap: .2rem; }
.pending-grid span { color: var(--muted); font-size: .8rem; }
.pending-info { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--text); font-weight: 600; margin-bottom: .5rem; }

.cart-line { align-items: flex-start; }
.cart-line .link-btn { color: var(--danger); }

.totals { margin: 1rem 0; border-top: 1px solid var(--border); padding-top: .5rem; }
.totals .kv > span:last-child { font-variant-numeric: tabular-nums; }
.total-incl { font-size: 1.15rem; font-weight: 700; }
.total-incl > span:first-child { color: var(--text) !important; }

.pay-choice { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 1rem 0; }
.pay-btn {
    min-height: 56px; font-size: 1.05rem; font-weight: 700;
    border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); cursor: pointer;
}
.pay-btn--on { border-color: var(--primary); background: var(--primary-50); color: var(--primary-700); }

/* ===========================================================================
   Blazor systémové prvky (chybová lišta + loader) — přebarveno do palety
   =========================================================================== */
.validation-message { color: var(--danger); }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}
.loading-progress circle {
    fill: none;
    stroke: var(--n-100);
    stroke-width: .6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}
.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto .2rem;
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Načítám"); }
