/* ============================================================
   Bike Repair POS — Global Stylesheet
   Tablet-first, mobile-optimized, Bootstrap 5 compatible
   ============================================================ */

:root {
    --br-primary:      #0d6efd;
    --br-primary-dark: #0a58ca;
    --br-success:      #198754;
    --br-warning:      #f59e0b;
    --br-danger:       #dc3545;
    --br-info:         #0dcaf0;

    --br-bg:           #f2f4f8;
    --br-surface:      #ffffff;
    --br-border:       #e6e8eb;
    --br-border-soft:  #eef0f3;

    --br-text:         #1f2937;
    --br-text-muted:   #667085;
    --br-text-soft:    #98a2b3;

    --br-radius:       14px;
    --br-radius-sm:    10px;
    --br-radius-lg:    18px;

    --br-shadow-sm:    0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
    --br-shadow:       0 2px 8px rgba(16,24,40,.06);
    --br-shadow-md:    0 6px 18px rgba(16,24,40,.08);
    --br-shadow-primary: 0 6px 18px rgba(13,110,253,.35);

    --br-nav-h:        64px;
    --br-bottom-nav-h: 66px;
}

/* ---------- Base ---------- */
* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
    background: var(--br-bg);
    color: var(--br-text);
    font-size: 15px;
    line-height: 1.5;
    padding-bottom: calc(var(--br-bottom-nav-h) + 16px);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Make fixed header/nav more usable on tablets */
body.has-bottom-nav { padding-bottom: calc(var(--br-bottom-nav-h) + 16px); }

h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -0.01em; }

a { color: var(--br-primary); }

/* ---------- Navbar ---------- */
.navbar {
    min-height: var(--br-nav-h);
    background: var(--br-surface) !important;
    border-bottom: 1px solid var(--br-border-soft);
    padding: .5rem .75rem;
}
.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
}
.navbar-brand i { font-size: 1.25rem; }

/* Compact icon-only dropdown on phones */
@media (max-width: 575.98px) {
    .navbar .btn.dropdown-toggle span.username-label { display: none; }
}

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--br-border-soft);
    border-radius: var(--br-radius);
    box-shadow: var(--br-shadow);
    background: var(--br-surface);
    overflow: hidden;
}
.card-header {
    background: var(--br-surface);
    border-bottom: 1px solid var(--br-border-soft);
    font-weight: 600;
    padding: .75rem 1rem;
    border-radius: var(--br-radius) var(--br-radius) 0 0 !important;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.card-header i { color: var(--br-primary); }
.card-body { padding: 1rem; }
@media (min-width: 992px) {
    .card-body { padding: 1.25rem; }
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--br-radius-sm);
    font-weight: 500;
    padding: .5rem .9rem;
    transition: transform .08s ease, box-shadow .15s ease, background-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-lg { padding: .75rem 1.1rem; font-size: 1rem; border-radius: 12px; }
.btn-sm { padding: .3rem .55rem; font-size: .8rem; border-radius: 8px; }
.btn-primary { box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.btn-primary:hover { background: var(--br-primary-dark); }

/* Group buttons on tablets */
.btn-group > .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-top-left-radius: var(--br-radius-sm); border-bottom-left-radius: var(--br-radius-sm); }
.btn-group > .btn:last-child  { border-top-right-radius: var(--br-radius-sm); border-bottom-right-radius: var(--br-radius-sm); }

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: var(--br-radius-sm);
    border: 1px solid var(--br-border);
    padding: .55rem .85rem;
    font-size: 15px;
    background: var(--br-surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--br-primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,.15);
}
.form-control-lg { padding: .75rem 1rem; font-size: 1rem; border-radius: 12px; }
.form-label { font-weight: 500; color: var(--br-text-muted); font-size: .85rem; margin-bottom: .3rem; }
.input-group-text {
    background: var(--br-surface);
    border-color: var(--br-border);
    color: var(--br-text-muted);
    border-radius: var(--br-radius-sm);
}

/* Prevent iOS zoom on inputs */
@media (max-width: 767.98px) {
    .form-control, .form-select { font-size: 16px; }
}

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: transparent;
    color: var(--br-text);
    margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: .6rem .6rem; }
.table-sm > :not(caption) > * > * { padding: .5rem .55rem; }
.table thead th {
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--br-text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--br-border-soft);
}
.table-hover tbody tr:hover { background: #f8fbff; }

/* Rounded, scrollable table container */
.table-responsive {
    border-radius: var(--br-radius-sm);
    scrollbar-width: thin;
}
.table-responsive::-webkit-scrollbar { height: 6px; width: 6px; }
.table-responsive::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 999px; }

/* ---------- Badges ---------- */
.badge {
    font-weight: 500;
    padding: .35em .6em;
    border-radius: 6px;
    letter-spacing: .01em;
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: var(--br-radius-sm);
    border: 1px solid transparent;
    padding: .75rem 1rem;
    font-size: .92rem;
}

/* ---------- Modals ---------- */
.modal-content {
    border: none;
    border-radius: var(--br-radius);
    box-shadow: var(--br-shadow-md);
}
.modal-header {
    border-bottom: 1px solid var(--br-border-soft);
    padding: .9rem 1rem;
}
.modal-title { font-weight: 600; font-size: 1.05rem; }
.modal-body { padding: 1rem; }
.modal-footer {
    border-top: 1px solid var(--br-border-soft);
    padding: .75rem 1rem;
    gap: .5rem;
}

/* Make modal comfortable on tablets */
@media (min-width: 576px) {
    .modal-dialog { max-width: 520px; }
    .modal-dialog.modal-lg { max-width: 720px; }
}
@media (max-width: 575.98px) {
    .modal-dialog { margin: .5rem; }
    .modal-content { border-radius: var(--br-radius-sm); }
}

/* ---------- Dropdown ---------- */
.dropdown-menu {
    border: 1px solid var(--br-border-soft);
    border-radius: var(--br-radius-sm);
    box-shadow: var(--br-shadow-md);
    padding: .35rem;
    min-width: 200px;
}
.dropdown-item {
    border-radius: 8px;
    padding: .5rem .75rem;
    font-size: .92rem;
}
.dropdown-item:active { background: var(--br-primary); color: #fff; }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--br-surface);
    border-top: 1px solid var(--br-border-soft);
    display: flex;
    z-index: 1030;
    box-shadow: 0 -4px 20px rgba(16,24,40,.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
    height: var(--br-bottom-nav-h);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.bottom-nav::-webkit-scrollbar { display: none; }

.bottom-nav a {
    flex: 0 0 auto;
    min-width: 68px;
    text-align: center;
    padding: 8px 6px 6px;
    font-size: 11px;
    line-height: 1.15;
    color: var(--br-text-muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: color .15s ease, background-color .15s ease;
    border-radius: 10px;
    margin: 4px 2px;
}
.bottom-nav a:hover { color: var(--br-primary); background: #f5f9ff; }
.bottom-nav a.active {
    color: var(--br-primary);
    font-weight: 600;
    background: #eff5ff;
}
.bottom-nav a i { font-size: 20px; line-height: 1; margin: 0; }

/* On tablets, spread items more comfortably */
@media (min-width: 576px) {
    .bottom-nav a { flex: 1 1 auto; min-width: 76px; font-size: 12px; }
    .bottom-nav a i { font-size: 22px; }
}

/* ---------- Sticky totals bar ---------- */
.sticky-total {
    position: sticky;
    bottom: calc(var(--br-bottom-nav-h) + 8px);
    background: linear-gradient(135deg, var(--br-primary), #3b82f6);
    color: #fff;
    border-radius: var(--br-radius);
    padding: 14px 18px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--br-shadow-primary);
    z-index: 10;
}
.sticky-total.flex-column {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.sticky-total .small { font-weight: 500; opacity: .9; }
.sticky-total #grandTotal,
.sticky-total .sticky-total-value { font-size: 1.15rem; }
@media (max-width: 575.98px) {
    .sticky-total { padding: 12px 14px; font-size: .95rem; }
}

/* ---------- POS suggestion dropdown ---------- */
.pos-suggest {
    position: relative;
    z-index: 999;
    background: var(--br-surface);
    width: 100%;
    left: 0; right: 0;
    border: 1px solid var(--br-border);
    border-radius: var(--br-radius-sm);
    max-height: 280px;
    overflow-y: auto;
    box-shadow: var(--br-shadow-md);
    margin-top: 4px;
}
.pos-suggest div {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
    font-size: .92rem;
    transition: background-color .1s ease;
}
.pos-suggest div:last-child { border-bottom: none; }
.pos-suggest div:hover,
.pos-suggest div:active { background: #f0f7ff; }

/* ---------- Receipt preview / printable ---------- */
.receipt {
    font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    background: #fff;
    color: #000;
}

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-card {
    width: 100%;
    max-width: 420px;
}
.login-logo {
    width: 72px; height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--br-primary), #60a5fa);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    box-shadow: var(--br-shadow-primary);
    margin-bottom: .75rem;
}

/* ---------- Utility ---------- */
.pointer { cursor: pointer; }

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bg-soft-primary { background: #eff5ff !important; color: var(--br-primary); }
.bg-soft-success { background: #ecfdf5 !important; color: var(--br-success); }
.bg-soft-warning { background: #fff7ed !important; color: #b45309; }
.bg-soft-danger  { background: #fef2f2 !important; color: var(--br-danger); }

/* ---------- Toasts ---------- */
.toast { border: none; border-radius: var(--br-radius-sm); box-shadow: var(--br-shadow-md); }
.toast-body { font-size: .9rem; }

/* ---------- Loader/spinner overlay (optional) ---------- */
#brLoader {
    position: fixed; inset: 0;
    background: rgba(255,255,255,.7);
    display: none; align-items: center; justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}
#brLoader.show { display: flex; }

/* ---------- Large tablet / desktop tweaks ---------- */
@media (min-width: 992px) {
    body { font-size: 15.5px; }
    .card-header { padding: .85rem 1.1rem; }
}

/* ---------- Print ---------- */
@media print {
    .navbar, .bottom-nav, .btn, .sticky-total, .pos-suggest { display: none !important; }
    body { background: #fff !important; padding: 0 !important; }
    .card { box-shadow: none !important; border: none !important; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}