/* Workshop ERP theme - on top of Bootstrap 5.3. No inline styles anywhere (strict CSP).
   Look: light page, white cards, deep-blue top bar, grouped sidebar (like ERPNext / Zoho / Odoo). */

/* small message after turning alerts on/off */
.push-toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 1090; max-width: 22rem; }

/* ---------- Brand colours (change here only) ----------
   The Android app uses the same values (workshop-erp-android: ui/theme/BrandColors.kt, task 004).
   Change both together so the website and the app stay one product. */
:root {
    --app-brand: #1e3a8a;          /* top bar */
    --app-brand-dark: #172e6e;
    --app-primary: #2563eb;        /* buttons, links, active menu */
    --app-primary-hover: #1d4ed8;
    --app-primary-soft: #e8efff;   /* active menu background */
    --app-accent: #f59e0b;         /* "+ New" button */
    --app-bg: #f4f6fb;             /* page background */
    --app-border: #e3e7ef;
    --app-muted: #6b7280;
    --app-sidebar-width: 240px;

    --bs-primary: var(--app-primary);
    --bs-primary-rgb: 37, 99, 235;
    --bs-link-color: var(--app-primary);
    --bs-link-color-rgb: 37, 99, 235;
    --bs-link-hover-color: var(--app-primary-hover);
    --bs-body-bg: var(--app-bg);
    --bs-border-color: var(--app-border);
    --bs-font-sans-serif: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

body {
    background: var(--app-bg);
}

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-hover);
    --bs-btn-hover-border-color: var(--app-primary-hover);
    --bs-btn-active-bg: var(--app-primary-hover);
    --bs-btn-disabled-bg: var(--app-primary);
    --bs-btn-disabled-border-color: var(--app-primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary-hover);
}

/* ---------- Top bar ---------- */
.app-topbar {
    background: var(--app-brand);
    min-height: 56px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.app-brand {
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.app-brand:hover, .app-brand:focus {
    color: #fff;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Compact OS symbol in a small white badge (logo colours need a light background) */
.app-brand-mark {
    height: 32px;
    width: auto;
    background: #fff;
    border-radius: 6px;
    padding: 2px 4px;
}

.btn-topbar {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: transparent;
}

.btn-topbar:hover, .btn-topbar:focus, .btn-topbar.show {
    color: #fff;
    background: var(--app-brand-dark);
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-new {
    color: #1f2937;
    background: var(--app-accent);
    border: 0;
    font-weight: 600;
}

.btn-new:hover, .btn-new:focus, .btn-new.show {
    color: #111827;
    background: #fbbf24;
}

.notif-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    font-size: 0.65rem;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--app-accent);
    color: #1f2937;
    font-weight: 700;
    font-size: 0.8rem;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: #fff;
    border-right: 1px solid var(--app-border);
}

@media (min-width: 992px) {
    .sidebar {
        width: var(--app-sidebar-width);
        min-height: calc(100vh - 56px);
        flex-shrink: 0;
        position: sticky;
        top: 56px;
        align-self: flex-start;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }
}

.side-menu {
    padding: 0.75rem 0.5rem 1.5rem;
}

.side-section {
    margin: 1rem 0.75rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--app-muted);
}

.side-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    margin: 1px 0;
    border-radius: 0.5rem;
    color: #374151;
    text-decoration: none;
    font-size: 0.93rem;
}

.side-link .bi {
    font-size: 1.05rem;
    color: var(--app-muted);
    width: 1.2rem;
    text-align: center;
}

.side-link:hover {
    background: #f3f4f6;
    color: #111827;
}

.side-link.active {
    background: var(--app-primary-soft);
    color: var(--app-primary);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--app-primary);
}

.side-link.active .bi {
    color: var(--app-primary);
}

/* ---------- Content: cards, tables, headings ---------- */
main.flex-grow-1 {
    min-width: 0; /* lets wide tables scroll instead of pushing the page */
}

@media (min-width: 992px) {
    main.flex-grow-1 {
        padding: 1.5rem 2rem !important;
    }
}

main h1.h4 {
    font-weight: 600;
    color: #111827;
}

.card {
    border-color: var(--app-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-header {
    background: #fafbfd;
    border-bottom-color: var(--app-border);
}

.table {
    --bs-table-bg: #fff;
    border-color: var(--app-border);
}

.table > thead th {
    background: #f8fafc;
    color: #4b5563;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom-width: 1px;
}

.table-responsive {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 0.75rem;
}

.table-responsive > .table {
    margin-bottom: 0;
}

.table td, .table th {
    vertical-align: middle;
}

.form-label {
    font-weight: 500;
    color: #374151;
}

.alert {
    border-radius: 0.6rem;
}

/* Dashboard tiles */
.tile {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem 1.1rem;
    height: 100%;
    color: inherit;
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 0.75rem;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.tile:hover {
    border-color: var(--app-primary);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
    color: inherit;
}

.tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 0.6rem;
    background: var(--app-primary-soft);
    color: var(--app-primary);
    font-size: 1.3rem;
}

.tile-title {
    font-weight: 600;
    color: #111827;
}

.tile-text {
    font-size: 0.85rem;
    color: var(--app-muted);
}

.dash-section {
    margin: 1.5rem 0 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--app-muted);
}

/* ---------- Login ---------- */
.login-card {
    max-width: 380px;
}

.login-brand {
    color: var(--app-brand);
    font-weight: 700;
}

.login-brand .bi {
    color: var(--app-accent);
}

/* Full logo on the login page (also the desktop app's start screen) */
.login-logo {
    display: block;
    width: 100%;
    max-width: 260px;
    height: auto;
    margin: 0 auto;
}

/* ---------- Existing helpers ---------- */

/* Amounts line up on the right */
.amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Bigger tap targets on phones + full-width row action buttons */
@media (max-width: 575.98px) {
    .btn, .form-control, .form-select {
        min-height: 44px;
    }
    .lead-row-actions {
        width: 100%;
    }
    .lead-row-actions > .btn,
    .lead-row-actions > form {
        width: 100%;
    }
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Two-step login pages */
.setup-card {
    max-width: 520px;
}

.qr-code {
    width: 220px;
    height: 220px;
    image-rendering: pixelated;
}

.otp-input {
    letter-spacing: 0.3em;
    font-variant-numeric: tabular-nums;
}

/* Enquiry photos: same-size tiles, whole photo opens on click */
.photo-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

/* Big tap targets for work-type ticks on tablets/phones */
.worktype-check {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

/* A4 quotation print sheet */
.print-sheet {
    max-width: 210mm;
    background: #fff;
}

@media print {
    body {
        background: #fff;
    }
    .no-print {
        display: none !important;
    }
    .print-sheet {
        max-width: 100%;
        border: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Native <progress> bar for CSP-safe progress bars without inline styles */
.job-progress {
    width: 100%;
    min-width: 90px;
    height: 0.65rem;
    border-radius: 999px;
    overflow: hidden;
    accent-color: var(--app-primary);
}

/* Store (task 007) */
.form-narrow {
    max-width: 40rem;
}

.bill-grid .col-item {
    min-width: 16rem;
}

.input-qty {
    max-width: 6rem;
}

/* A5 material issue slip */
.print-a5 {
    max-width: 148mm;
    page: a5;
}

@page a5 {
    size: A5;
    margin: 10mm;
}

/* Task 008: tax invoice print (multi-line settings text, signature box) */
.text-pre-line {
    white-space: pre-line;
}
.invoice-sign-space {
    height: 3.5rem;
}
.print-a5 {
    max-width: 148mm;
}
@media print {
    .print-keep {
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* Gate pass (task 010) */
.print-a6 {
    max-width: 105mm;
    page: a6;
}

@page a6 {
    size: A6;
    margin: 6mm;
}

.gate-qr {
    width: 34mm;
    height: 34mm;
}

.gate-photo {
    height: 120px;
    width: auto;
}

/* Gate check result: unmistakable at a glance */
.gate-result {
    width: 100%;
    padding: 1rem;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.05em;
}

.gate-result-ok {
    background: #198754;
}

.gate-result-stop {
    background: #dc3545;
}

.gate-stamp {
    border: 2px solid #000;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
}

/* Vehicle no. on the gate check result: as big as possible, full width */
.gate-vehicle-no {
    width: 100%;
    font-size: clamp(2.5rem, 9vw, 5rem);
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-align: center;
    border: 3px solid currentColor;
    border-radius: 0.5rem;
    padding: 0.25rem 0.5rem;
    word-break: break-all;
}

/* ===== Home: "Your work today" boxes (task 017) ===== */
.todo-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.todo {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1rem; border-radius: 14px; background: #fff;
    border: 1px solid var(--app-border); border-left: 5px solid var(--todo-color, var(--app-primary));
    color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s;
}
.todo:hover { box-shadow: 0 6px 18px rgba(30, 58, 138, .10); transform: translateY(-1px); color: inherit; }
.todo-count { font-size: 1.9rem; font-weight: 700; line-height: 1; min-width: 2.2ch; color: var(--todo-color, var(--app-primary)); }
.todo-label { font-weight: 600; line-height: 1.2; }
.todo-hint { font-size: .8rem; color: var(--app-muted); }
.todo > .bi { margin-left: auto; font-size: 1.35rem; color: var(--todo-color, var(--app-primary)); opacity: .75; }
.todo-danger  { --todo-color: #dc2626; }
.todo-warning { --todo-color: #d97706; }
.todo-success { --todo-color: #16a34a; }
.todo-primary { --todo-color: #2563eb; }
.todo.is-empty { --todo-color: #9ca3af; background: #fafbfc; border-left-color: #e5e7eb; }
.todo.is-empty .todo-label { font-weight: 500; color: var(--app-muted); }
.all-clear { border-radius: 14px; background: #ecfdf3; color: #166534; padding: .75rem 1rem; }
/* Phone: 2 compact boxes per row - big number on top, label under it */
@media (max-width: 575.98px) {
    .todo-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
    .todo { flex-direction: column; align-items: flex-start; gap: .25rem; padding: .7rem .75rem; position: relative; }
    .todo-count { font-size: 1.6rem; }
    .todo-label { font-size: .9rem; }
    .todo-hint { display: none; }
    .todo > .bi { position: absolute; top: .65rem; right: .7rem; font-size: 1.1rem; }
    /* top bar on one line: logo only, no name */
    .app-topbar { flex-wrap: nowrap; }
    .app-brand > span { display: none; }
}

/* Collapsible menu groups: rarely used links stay folded until needed */
.side-toggle {
    display: flex; width: calc(100% - 1.5rem); align-items: center; justify-content: space-between;
    background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
    font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
}
.side-toggle .chev { transition: transform .15s; font-size: .7rem; }
.side-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.side-link.side-toggle { width: 100%; padding: 0.5rem 0.75rem; font-size: .9rem; color: var(--app-muted); text-transform: none; letter-spacing: 0; }

/* "Next step" bar on records */
.next-step {
    background: var(--app-primary-soft); border: 1px solid #c9d8ff; border-radius: 12px;
    padding: .6rem .85rem; color: #1e3a8a;
}
.next-step-label {
    font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    background: #fff; border-radius: 999px; padding: .15rem .6rem; color: var(--app-primary);
}
