/**
 * TemptingKart Inventory — modern SaaS UI (Bootstrap 5 + Inter)
 */

:root {
    --tk-primary: #2563eb;
    --tk-primary-dark: #1d4ed8;
    --tk-bg-page: #f5f7fb;
    --tk-sidebar-bg: #1e3a8a;
    --tk-sidebar-hover: rgba(255, 255, 255, 0.12);
    --tk-radius-card: 12px;
    --tk-radius-btn: 8px;
    --tk-shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.08);
    --tk-bottomnav-h: 4.25rem;
    --tk-topnav-h: 52px;
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
}

html {
    scroll-behavior: smooth;
}

body.app-body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--tk-bg-page);
    color: #1e293b;
    min-height: 100vh;
    padding-top: var(--tk-topnav-h);
    overflow-x: hidden;
}

@media (max-width: 767.98px) {
    body.app-body {
        padding-bottom: calc(var(--tk-bottomnav-h) + env(safe-area-inset-bottom, 0px));
    }
}

/* ----- Top navbar (white bar, logo on white) ----- */
.app-topnav {
    z-index: 1030;
    min-height: var(--tk-topnav-h);
    background-color: #fff !important;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.app-topnav-inner {
    min-height: calc(var(--tk-topnav-h) - 2px);
}

.app-topnav-menu-btn {
    border-radius: var(--tk-radius-btn);
    color: #1e293b !important;
}

.app-topnav-menu-btn:hover,
.app-topnav-menu-btn:focus {
    background-color: #f1f5f9;
    color: #0f172a !important;
}

.app-brand {
    margin-right: 0;
}

/* Extra white “pad” for logos with transparency; seamless on white bar */
.app-brand-bg {
    display: inline-flex;
    align-items: center;
    background-color: #fff;
    border-radius: 8px;
    padding: 2px 4px;
    line-height: 0;
}

.app-brand-logo {
    max-height: 36px;
    width: auto;
    height: auto;
    object-fit: contain;
    vertical-align: middle;
}

/* ----- Auth (login) ----- */
.auth-body {
    font-family: 'Inter', system-ui, sans-serif;
    background: linear-gradient(165deg, #eff6ff 0%, var(--tk-bg-page) 45%, #e0e7ff 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-wrap {
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    max-height: 72px;
    width: auto;
}

.auth-card {
    border-radius: var(--tk-radius-card);
}

.auth-form .form-control-lg {
    min-height: 48px;
}

/* ----- Shell layout ----- */
.app-shell {
    display: flex;
    min-height: calc(100vh - var(--tk-topnav-h));
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--tk-sidebar-bg) 0%, #172554 100%);
    position: sticky;
    top: var(--tk-topnav-h);
    align-self: flex-start;
    height: calc(100vh - var(--tk-topnav-h));
}

.app-main-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
}

.app-main-inner {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* Sidebar & offcanvas links */
.app-side-links .app-side-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255, 255, 255, 0.88);
    font-weight: 500;
    border-radius: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-side-links .app-side-link:hover {
    background: var(--tk-sidebar-hover);
    color: #fff;
}

.app-side-links .app-side-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-left: 3px solid #fff;
    padding-left: calc(1.25rem - 3px);
}

.app-side-links .app-side-link i {
    font-size: 1.15rem;
    opacity: 0.95;
}

a.app-sidebar-signout:hover {
    color: #fff !important;
    text-decoration: none;
}

.app-offcanvas .app-side-link {
    color: #334155;
    padding: 0.85rem 1rem;
}

.app-offcanvas .app-side-link:hover {
    background: #f1f5f9;
}

.app-offcanvas .app-side-link.active {
    background: #eff6ff;
    color: var(--tk-primary);
    border-left: 3px solid var(--tk-primary);
    padding-left: calc(1rem - 3px);
}

.app-offcanvas .app-side-link.text-danger {
    color: #dc2626 !important;
}

/* ----- Cards ----- */
.tk-card,
.card.tk-card {
    border: none;
    border-radius: var(--tk-radius-card);
    box-shadow: var(--tk-shadow-soft);
    background: #fff;
}

.tk-card .card-header {
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.tk-card .card-body {
    padding: 1rem 1.25rem;
}

@media (min-width: 768px) {
    .tk-card .card-body {
        padding: 1.25rem 1.5rem;
    }
}

.card-metric {
    border: none !important;
    border-radius: var(--tk-radius-card);
    box-shadow: var(--tk-shadow-soft);
}

.card-metric .card-body {
    padding: 1.25rem 1.35rem;
}

.card-metric.card-metric-warn {
    border-left: 4px solid #facc15 !important;
}

.stat-value {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    line-height: 1.1;
}

.page-heading {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #0f172a;
}

/* ----- Tables ----- */
.tk-table-wrap {
    border-radius: var(--tk-radius-card);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--tk-shadow-soft);
}

.tk-table-wrap .table {
    margin-bottom: 0;
}

.tk-table-wrap thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: #64748b;
    border-bottom-width: 1px;
    background: #fafbfc;
}

.tk-table-wrap tbody td {
    vertical-align: middle;
    border-color: #f1f5f9;
}

.tk-table-wrap .table > :not(caption) > * > * {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.table-actions {
    white-space: nowrap;
}

.low-stock-row {
    background-color: rgba(250, 204, 21, 0.12);
}

/* ----- Buttons ----- */
.btn.tk-btn-primary,
.tk-btn-primary {
    min-height: 44px;
    border-radius: var(--tk-radius-btn);
    font-weight: 600;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

.btn-primary {
    background-color: var(--tk-primary);
    border-color: var(--tk-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--tk-primary-dark);
    border-color: var(--tk-primary-dark);
}

.btn-outline-primary {
    color: var(--tk-primary);
    border-color: var(--tk-primary);
}

.btn-outline-primary:hover {
    background-color: var(--tk-primary);
    border-color: var(--tk-primary);
}

.btn-sm {
    min-height: 38px;
}

/* ----- Forms ----- */
.form-control,
.form-select {
    min-height: 44px;
    border-radius: var(--tk-radius-btn);
    border-color: #e2e8f0;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--tk-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

.form-label {
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.35rem;
}

/* ----- Mobile bottom navigation ----- */
.app-bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    min-height: var(--tk-bottomnav-h);
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: #fff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
}

.app-bottomnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    transition: color 0.15s ease;
}

.app-bottomnav-item .app-bottomnav-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.app-bottomnav-item:hover {
    color: var(--tk-primary);
}

.app-bottomnav-item.active {
    color: var(--tk-primary);
}

/* Five items: tighter labels on narrow phones */
.app-bottomnav--5 .app-bottomnav-item {
    font-size: 0.58rem;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
}

.app-bottomnav--5 .app-bottomnav-icon {
    font-size: 1.15rem;
}

/* Custom pricing form */
.tk-custom-pricing-card .card-body {
    padding: 1.25rem 1.35rem;
}

@media (min-width: 768px) {
    .tk-custom-pricing-form .form-control-lg,
    .tk-custom-pricing-form .form-select-lg {
        min-height: 48px;
    }
}

/* ----- Floating add (products) ----- */
.fab-add-product {
    position: fixed;
    right: 1rem;
    bottom: calc(var(--tk-bottomnav-h) + 1rem + env(safe-area-inset-bottom, 0px));
    z-index: 1025;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    line-height: 1;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

@media (min-width: 768px) {
    .fab-add-product {
        display: none !important;
    }
}

/* ----- Alerts ----- */
.tk-alert {
    border-radius: var(--tk-radius-btn);
    border: none;
}

/* Toasts sit below fixed navbar */
.tk-toast-wrap {
    top: calc(var(--tk-topnav-h) + 0.5rem) !important;
    z-index: 1080;
}

/* ----- Print labels: screen preview (unchanged layout dimensions) ----- */
.label-preview-wrap {
    background: #e9ecef;
    padding: 1rem;
    border-radius: var(--tk-radius-card);
}

.label-preview {
    width: 50mm;
    height: 30mm;
    background: #fff;
    border: 1px dashed #999;
    margin: 0.5rem;
    display: inline-flex;
    vertical-align: top;
    box-sizing: border-box;
}

.label-inner {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 1mm 1.5mm;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.label-store {
    font-size: 2.2mm;
    font-weight: 600;
    line-height: 1;
    color: #333;
}

.label-product {
    font-size: 2.8mm;
    font-weight: 600;
    line-height: 1.1;
    max-height: 7mm;
    overflow: hidden;
}

.label-price {
    font-size: 5mm;
    font-weight: 800;
    line-height: 1;
}

.label-sku {
    font-size: 2mm;
    line-height: 1;
    color: #444;
}

.label-barcode-img {
    display: block;
    max-width: 100%;
    height: 8mm;
    object-fit: contain;
    object-position: left bottom;
    image-rendering: pixelated;
}

#print-area {
    display: none;
}

@media print {
    .app-bottomnav,
    .app-topnav,
    .app-sidebar,
    .app-footer,
    .fab-add-product,
    .tk-toast-wrap {
        display: none !important;
    }

    body.app-body {
        background: #fff !important;
        padding-top: 0 !important;
        overflow: visible !important;
    }

    /* Thermal labels only — avoids blank prints on other pages */
    body.tk-print-label-page * {
        visibility: hidden;
    }

    body.tk-print-label-page #print-area,
    body.tk-print-label-page #print-area * {
        visibility: visible;
    }

    body.tk-print-label-page #print-area {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    body.tk-print-label-page {
        margin: 0 !important;
        padding: 0 !important;
        width: 50mm;
        min-height: 0;
        background: #fff !important;
    }

    body.tk-print-label-page .label-page {
        width: 50mm;
        height: 30mm;
        margin: 0;
        padding: 0;
        page-break-after: always;
        break-after: page;
        box-sizing: border-box;
    }

    body.tk-print-label-page .label-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    body.tk-print-label-page .label-inner {
        border: none;
        padding: 1mm 1.5mm;
    }

    body.tk-print-label-page .label-barcode-img {
        height: 7mm;
    }
}

/* ----- Utilities ----- */
.max-w-label-ui {
    max-width: 720px;
}
