/* =========================================================
   Inspirei Billing - Application stylesheet
   Built on Bootstrap 5.3 CSS custom properties so the app
   respects the administrator-chosen theme colour + dark mode.
   ========================================================= */

:root {
    --app-radius: 0.75rem;
    --app-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.06);
    --app-navbar-height: 56px;
    --app-topbar-color: #0d6efd;
    --app-sidebar-color: #1e2b4a;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* ---------- Navbar / Sidebar layout ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Coloured sidebar */
.app-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--app-sidebar-color) 0%, color-mix(in srgb, var(--app-sidebar-color) 68%, #000) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    border: 0;
}
@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
    }
}

.sidebar-head {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 0.5rem;
}
.sidebar-title {
    color: #fff;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    padding: 0.25rem 0 0.75rem;
}
.nav-group-label {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    padding: 0.9rem 1rem 0.3rem;
}
.side-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.9rem;
    margin: 0.1rem 0.75rem;
    border-radius: 0.55rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
}
.side-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.side-link.active {
    background: var(--bs-primary);
    color: #fff;
    font-weight: 600;
}
.side-link-icon {
    font-size: 1.05rem;
    width: 1.25em;
    text-align: center;
}

/* Top navigation bar (full width, always visible) */
.app-topbar {
    background: linear-gradient(135deg, var(--app-topbar-color) 0%, color-mix(in srgb, var(--app-topbar-color) 72%, #000) 100%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #fff;
    z-index: 1030;
    box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.12);
}
.app-brand-logo {
    max-height: 34px;
    max-width: 160px;
    height: auto;
    width: auto;
    border-radius: 6px;
}
.app-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 1.15rem;
}
.app-brand-name {
    color: #fff;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-user {
    max-width: 180px;
}
.app-user-name {
    max-width: 180px;
}
.app-nav-btn {
    flex-shrink: 0;
}

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

.app-main {
    flex: 1;
}

/* ---------- Cards & page header ---------- */
.app-card {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    background-color: var(--bs-body-bg);
}

.page-title {
    font-weight: 700;
}

/* ---------- KPI cards ---------- */
.kpi-card {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    background-color: var(--bs-body-bg);
    position: relative;
    overflow: hidden;
    padding: 1.1rem 1.25rem;
}
.kpi-card .kpi-icon {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.6rem;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.kpi-card .kpi-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
}
.kpi-card .kpi-value {
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.2;
}
.kpi-card .kpi-sub {
    font-size: 0.78rem;
    color: var(--bs-secondary-color);
}

/* ---------- Autocomplete (billing item picker) ---------- */
.ac-wrap {
    position: relative;
}
.ac-list {
    position: absolute;
    z-index: 1060;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 280px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.15);
    list-style: none;
    margin: 0.25rem 0 0 0;
    padding: 0.25rem 0;
    display: none;
}
.ac-list.show {
    display: block;
}
.ac-list li {
    padding: 0.45rem 0.75rem;
    cursor: pointer;
}
.ac-list li:hover,
.ac-list li.active {
    background: rgba(var(--bs-primary-rgb), 0.08);
}
.ac-list .ac-name {
    font-weight: 600;
}
.ac-list .ac-meta {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

/* ---------- Billing item table ---------- */
.min-h-input {
    min-height: 38px;
}
.billing-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(var(--bs-primary-rgb), 0.06);
    white-space: nowrap;
}
.billing-table input,
.billing-table textarea {
    font-size: 0.875rem;
}
.sum-box {
    font-size: 0.9rem;
}

/* ---------- Invoice status chips in ledger ---------- */
.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.35rem;
}

/* ---------- Tables ---------- */
.table th {
    font-weight: 600;
}
.table td,
.table th {
    vertical-align: middle;
}

/* ---------- Alert (login + misc) ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--bs-primary) 18%, var(--bs-body-bg)), var(--bs-body-bg));
}
.login-card {
    width: 100%;
    max-width: 420px;
}

/* ---------- Flash message ---------- */
.alert-flash {
    border-left: 4px solid var(--bs-primary);
}

/* ---------- Dark-mode fine-tuning ---------- */
[data-bs-theme="dark"] .app-card,
[data-bs-theme="dark"] .kpi-card {
    border-color: rgba(255, 255, 255, 0.12);
}

@media print {
    .app-sidebar, .app-topbar, .app-main nav, .no-print {
        display: none !important;
    }
}