/* FuarApp PWA — mobile-first, tenant-themeable via CSS variables. */
:root {
    --primary: #1565C0;
    --secondary: #263238;
    --accent: #FF8F00;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --text: #1a2233;
    --text-dim: #6b7686;
    --border: #e3e8f0;
    --danger: #d32f2f;
    --success: #2e7d32;
    --warning: #ef6c00;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(15, 25, 50, .07);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}
#app { height: 100%; }

/* Boot splash */
.boot-splash {
    height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 18px;
    background: linear-gradient(160deg, #10203a, #1565C0);
}
.boot-logo { color: #fff; font-size: 34px; font-weight: 700; letter-spacing: 1px; }
.boot-spinner {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* App shell */
.shell { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    display: flex; align-items: center; gap: 12px;
    background: var(--primary); color: #fff;
    padding: 12px 16px; position: sticky; top: 0; z-index: 20;
    box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 700; font-size: 17px; flex: 1; display: flex; align-items: center; gap: 10px; }
.topbar .brand img { height: 28px; border-radius: 6px; background: #fff; padding: 2px; }
.topbar .fair-chip {
    background: rgba(255,255,255,.18); border-radius: 999px;
    padding: 4px 12px; font-size: 12px; white-space: nowrap;
    max-width: 40vw; overflow: hidden; text-overflow: ellipsis;
}
.offline-badge {
    background: var(--warning); color: #fff; font-size: 11px; font-weight: 600;
    padding: 3px 10px; border-radius: 999px;
}
.outbox-badge {
    background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
    padding: 3px 9px; border-radius: 999px;
}

.content { flex: 1; padding: 16px; padding-bottom: calc(76px + var(--safe-bottom)); max-width: 860px; width: 100%; margin: 0 auto; }

/* Bottom navigation (mobile-first) */
.bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    display: flex; background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 -2px 12px rgba(15,25,50,.08);
}
.bottomnav a {
    flex: 1; text-align: center; padding: 9px 4px 7px;
    color: var(--text-dim); text-decoration: none; font-size: 11px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bottomnav a .ico { font-size: 21px; line-height: 1; }
.bottomnav a.active { color: var(--primary); font-weight: 600; }

/* Cards & lists */
.card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 16px; }
.list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; background: var(--surface);
    border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 8px;
    cursor: pointer; border: 1px solid transparent;
}
.list-item:active { border-color: var(--primary); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }

/* Forms */
label { display: block; font-size: 12.5px; color: var(--text-dim); margin: 10px 0 4px; font-weight: 600; }
input, select, textarea {
    width: 100%; padding: 11px 12px; font-size: 15px;
    border: 1.5px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--primary); color: #fff; border: none;
    padding: 12px 20px; border-radius: 11px; font-size: 15px; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: opacity .15s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface); color: var(--primary); border: 1.5px solid var(--primary); }
.btn.ghost { background: transparent; color: var(--text-dim); border: 1.5px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.accent { background: var(--accent); }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.green { background: #e6f4e8; color: var(--success); }
.badge.red { background: #fdebea; color: var(--danger); }
.badge.orange { background: #fdf0e3; color: var(--warning); }
.badge.blue { background: #e7f0fb; color: var(--primary); }
.badge.gray { background: #eef1f6; color: var(--text-dim); }

/* Barcode scan area */
.scan-box {
    border: 2.5px dashed var(--primary); border-radius: var(--radius);
    background: var(--surface); padding: 22px 16px; text-align: center;
}
.scan-box input {
    text-align: center; font-size: 20px; letter-spacing: 2px; font-weight: 600;
    border-width: 0; border-bottom: 2px solid var(--border); border-radius: 0;
}
video.scanner { width: 100%; border-radius: var(--radius); background: #000; max-height: 320px; object-fit: cover; }

/* Login */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #10203a, var(--primary)); padding: 20px;
}
.login-card {
    width: 100%; max-width: 400px; background: var(--surface);
    border-radius: 20px; padding: 30px 26px; box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.login-card h1 { margin: 0 0 4px; font-size: 26px; color: var(--primary); }
.login-card .tag { color: var(--text-dim); font-size: 13.5px; margin-bottom: 18px; }

.error-text { color: var(--danger); font-size: 13.5px; margin-top: 10px; }
.hint { color: var(--text-dim); font-size: 12.5px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.mt { margin-top: 14px; }
.center { text-align: center; }

.totalbar {
    position: sticky; bottom: calc(64px + var(--safe-bottom)); background: var(--secondary); color: #fff;
    border-radius: var(--radius); padding: 14px 18px; display: flex; align-items: center;
    justify-content: space-between; box-shadow: var(--shadow); font-weight: 600;
}

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; color: var(--text-dim); font-size: 12px; padding: 8px 10px; border-bottom: 1.5px solid var(--border); }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); }

.warn-strip {
    background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
    border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin: 10px 0;
}

#blazor-error-ui {
    background: var(--danger); color: #fff; bottom: 0; left: 0; right: 0;
    padding: 12px 40px 12px 16px; position: fixed; z-index: 1000;
}
#blazor-error-ui .dismiss { position: absolute; right: 14px; top: 12px; cursor: pointer; }
#blazor-error-ui a { color: #fff; }

@media (min-width: 700px) {
    .content { padding-top: 24px; }
    body { font-size: 15.5px; }
}
