/* RKCNL Back Office — minimal custom styles layered on top of Bootstrap 5 */

html, body {
    height: 100%;
}

/* App-shell layout: the page itself never scrolls. body is a full-height column of
   navbar / shell / footer; only the shell's two panes (sidebar and content) scroll. This
   pins the footer to the bottom of the viewport instead of it sitting below a tall page. */
body {
    background-color: #f4f6f9;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Single source of truth for the fixed navbar's height: the bar, the content offset and the
   sidebar's sticky top all derive from this, so they can never drift apart. */
:root {
    --app-navbar-h: 48px;
}

/* ===== Top navbar — on-brand polish over Bootstrap's flat bg-dark ===== */
.app-navbar {
    /* --brand is set inline from the deployment's primary colour (Client Setup); falls back to green. */
    background: linear-gradient(100deg,
        color-mix(in srgb, var(--brand, #198754) 78%, #000) 0%,
        var(--brand, #198754) 100%) !important;
    border-bottom: 1px solid color-mix(in srgb, var(--brand, #198754) 55%, #000);
    box-shadow: 0 2px 10px rgba(9, 30, 20, .22);
    /* Compact: Bootstrap's default .5rem y-padding plus a 34px badge made the bar ~56px tall. */
    min-height: var(--app-navbar-h);
    padding-top: .25rem;
    padding-bottom: .25rem;
    /* Fixed band at the top of the column; never compressed by the scrolling shell. */
    flex-shrink: 0;
}

/* The middle band: fills the space between navbar and footer and clips its own overflow, so
   its two children (sidebar, main) are the things that scroll — not the page. */
.app-shell {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* main scrolls its content vertically. min-width:0 is also needed because main is a flex child:
   without it its automatic minimum size is its content's min-content width, so a wide table
   refuses to shrink and drags the pane sideways instead of scrolling inside its own
   .table-responsive. Applies to every wide table in the app, not just the reports. */
.app-shell > main {
    min-width: 0;
    overflow-y: auto;
}

.app-navbar .navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
}

/* building icon in a soft green gradient tile */
.app-navbar .brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: .5rem;
    background: linear-gradient(135deg, #24b869, #157347);
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 2px 8px rgba(25, 135, 84, .5), inset 0 1px 0 rgba(255, 255, 255, .3);
    transition: transform .15s ease, filter .15s ease;
}

.app-navbar .navbar-brand:hover .brand-badge {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.app-navbar .brand-text {
    letter-spacing: .015em;
}

.app-navbar .brand-accent {
    color: #5ee49b;
    font-weight: 600;
}

/* action buttons + bell */
.app-navbar .btn-light {
    font-weight: 600;
}

.app-navbar .btn-outline-light {
    border-color: rgba(255, 255, 255, .3);
}

.app-navbar .btn-outline-light:hover {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .45);
}

/* The bell anchor carries no colour class, so it inherited Bootstrap's blue link colour
   against the brand bar. Keep it white. */
.app-navbar a[title="Notifications"] {
    color: rgba(255, 255, 255, .9);
}

.app-navbar a[title="Notifications"]:hover {
    color: #fff;
}

.app-navbar .bi-bell {
    transition: transform .2s ease;
}

.app-navbar a[title="Notifications"]:hover .bi-bell {
    transform: rotate(10deg) scale(1.05);
}

/* Ring the unread count in the bar's own colour rather than a hardcoded dark green. */
.app-navbar .badge.bg-danger {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand, #198754) 78%, #000);
}

/* ===== Navbar: today's date + global search ===== */
.nav-date {
    color: rgba(255, 255, 255, .82);
    font-size: .78rem;
    white-space: nowrap;
    line-height: 1.1;
}

.nav-search {
    position: relative;
    flex: 1 1 auto;
    max-width: 420px;
}

.nav-search .form-control {
    height: 32px;
    font-size: .85rem;
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .22);
    color: #fff;
}

.nav-search .form-control::placeholder { color: rgba(255, 255, 255, .6); }

.nav-search .form-control:focus {
    background: #fff;
    color: #212529;
    box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .25);
    border-color: #fff;
}

.nav-search .form-control:focus::placeholder { color: #adb5bd; }

.nav-search .search-icon {
    position: absolute;
    left: .6rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, .7);
    font-size: .85rem;
    pointer-events: none;
}

.nav-search .form-control:focus + .search-icon { color: #6c757d; }
.nav-search .form-control { padding-left: 1.9rem; }

.search-results {
    position: absolute;
    top: calc(100% + .35rem);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 1060;
    display: none;
}

.search-results.show { display: block; }
.search-results .sr-head {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c757d;
    padding: .45rem .7rem .2rem;
}

.search-results a.sr-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .4rem .7rem;
    color: #212529;
    text-decoration: none;
    font-size: .85rem;
}

.search-results a.sr-item:hover,
.search-results a.sr-item.active { background: #eef6f1; }
.search-results a.sr-item i { color: #198754; }
.search-results .sr-sub { font-size: .72rem; color: #adb5bd; margin-left: auto; }
.search-results .sr-empty { padding: .7rem; color: #6c757d; font-size: .82rem; }

/* clickable user name -> profile */
.app-navbar .navbar-user {
    color: rgba(255, 255, 255, .78);
    font-size: .875rem;
    padding: .25rem .55rem;
    border-radius: .4rem;
    transition: background .15s ease, color .15s ease;
}

.app-navbar .navbar-user:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

.app-navbar .navbar-user .bi-person-circle {
    color: #5ee49b;
}

/* profile page avatar (initials fallback) */
.profile-avatar {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #24b869, #157347);
    box-shadow: 0 4px 12px rgba(25, 135, 84, .4), inset 0 1px 0 rgba(255, 255, 255, .3);
}

/* profile page avatar when a photo exists */
.profile-photo {
    object-fit: cover;
    background: none;
    border: 3px solid #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
}

#sidebar .nav-link {
    border-radius: .375rem;
    margin-bottom: 2px;
    font-size: .925rem;
}

#sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, .08);
}

.card {
    border: none;
    border-radius: .75rem;
}

.table > :not(caption) > * > * {
    padding: .65rem .75rem;
}

dl.row dt {
    font-weight: 600;
    color: #6c757d;
}

.login-card {
    max-width: 420px;
    margin: 8vh auto;
}

/* Vendor footer — "Powered by RKCNL iTech Limited". Pinned to the bottom of the column and
   never compressed, so it stays in view while the shell above it scrolls. */
.app-footer {
    padding: .5rem 1rem;
    text-align: center;
    border-top: 1px solid #e9ecef;
    background: #fff;
    flex-shrink: 0;
}
.login-footer { text-align: center; }
.powered-by {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: .8rem;
    color: #6c757d;
}
.powered-by strong { color: #495057; font-weight: 600; }
.powered-logo { height: 34px; width: auto; vertical-align: middle; }

/* Printing must undo the fixed-height, overflow-clipped shell — otherwise only the first
   viewport of a long report (e.g. a multi-page salary sheet) would print. Let the document
   flow and grow to its natural height instead. Per-view print CSS still hides the chrome. */
@media print {
    html, body {
        height: auto;
        overflow: visible;
        display: block;
    }
    .app-shell {
        overflow: visible;
        min-height: 0;
    }
    .app-shell > main {
        overflow: visible;
        padding: 0 !important;
    }
    /* Chrome is never part of a printed/saved-as-PDF document. */
    .app-navbar, #sidebar, #sidebar-backdrop, .app-footer, .d-print-none {
        display: none !important;
    }
    .card { box-shadow: none !important; }
}
