/* ============================================================================
   Custom Billing Web Application Platform - application styles
   (Bootstrap is loaded first; this file adds the application shell + print CSS)
   ============================================================================ */

:root {
    --cb-navy: #10243e;
    --cb-navy-soft: #16314f;
    --cb-accent: #1d7fd6;
    --cb-accent-soft: #e8f2fc;
    --cb-green: #157f5b;
    --cb-red: #b3261e;
    --cb-amber: #a86612;
    --cb-surface: #f4f6fa;
    --cb-card: #ffffff;
    --cb-border: #dfe5ee;
    --cb-text: #1c2733;
    --cb-muted: #66748a;
    --cb-radius: 10px;
    --cb-shadow: 0 1px 2px rgba(16, 36, 62, .06), 0 6px 18px rgba(16, 36, 62, .06);
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--cb-surface);
    color: var(--cb-text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
}

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

.app-sidebar {
    width: 246px;
    flex: 0 0 246px;
    background: linear-gradient(180deg, var(--cb-navy) 0%, #0b1b2e 100%);
    color: #c7d3e3;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--cb-accent), #48b0f7);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: .5px;
}

.sidebar-brand-name {
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}

.sidebar-brand-sub {
    font-size: 11px;
    color: #8fa3bd;
}

.sidebar-nav {
    padding: 10px 8px 20px;
    flex: 1;
}

.sidebar-section {
    margin: 16px 10px 6px;
    font-size: 10.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #7590ad;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    margin: 2px 0;
    border-radius: 8px;
    color: #c7d3e3;
    text-decoration: none;
    font-size: 13.5px;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

.sidebar-link.active {
    background: var(--cb-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(29, 127, 214, .35);
}

.nav-ico {
    width: 16px;
    text-align: center;
    opacity: .9;
}

.sidebar-footer {
    padding: 12px 16px;
    font-size: 10.5px;
    color: #7d93b0;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

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

.app-topbar {
    height: 58px;
    background: var(--cb-navy-soft);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-topbar-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #57c08a;
    display: inline-block;
}

.app-topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    color: #a8bdd6;
}

.app-content {
    flex: 1;
    padding: 22px 24px 32px;
}

.app-footer {
    display: flex;
    justify-content: space-between;
    padding: 12px 24px;
    font-size: 11.5px;
    color: var(--cb-muted);
    border-top: 1px solid var(--cb-border);
    background: #fff;
}

/* ---------------------------------------------------------------- pages --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 21px;
    font-weight: 700;
    margin: 0;
    color: var(--cb-navy);
}

.page-subtitle {
    margin: 4px 0 0;
    color: var(--cb-muted);
    font-size: 12.5px;
}

.card-panel {
    background: var(--cb-card);
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius);
    padding: 18px;
    box-shadow: var(--cb-shadow);
    margin-bottom: 18px;
}

.card-panel h2, .card-panel h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--cb-navy);
}

.section-title {
    font-size: 12px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--cb-muted);
    font-weight: 700;
    margin-bottom: 10px;
}

/* --------------------------------------------------------------- stats --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--cb-border);
    border-left: 4px solid var(--cb-accent);
    border-radius: var(--cb-radius);
    padding: 14px 16px;
    box-shadow: var(--cb-shadow);
}

.stat-card.green { border-left-color: var(--cb-green); }
.stat-card.amber { border-left-color: var(--cb-amber); }
.stat-card.red { border-left-color: var(--cb-red); }

.stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--cb-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--cb-navy);
    margin-top: 4px;
}

.stat-note {
    font-size: 11.5px;
    color: var(--cb-muted);
}

/* -------------------------------------------------------------- tables --- */
.table-cb {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table-cb thead th {
    background: #eef2f8;
    color: var(--cb-navy);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 9px 10px;
    border-bottom: 1px solid var(--cb-border);
    white-space: nowrap;
}

.table-cb tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #eef1f6;
    vertical-align: middle;
}

.table-cb tbody tr:hover {
    background: #f8fafd;
}

.table-cb .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table-cb tfoot td {
    padding: 9px 10px;
    font-weight: 700;
    background: #f6f8fc;
    border-top: 2px solid var(--cb-border);
}

.table-wrap {
    overflow-x: auto;
}

/* ------------------------------------------------------------- controls --- */
.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--cb-navy);
    margin-bottom: 3px;
}

.form-control, .form-select {
    font-size: 13px;
    border-color: var(--cb-border);
    border-radius: 7px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--cb-accent);
    box-shadow: 0 0 0 .15rem rgba(29, 127, 214, .15);
}

.form-control-sm, .form-select-sm {
    font-size: 12.5px;
}

.btn {
    font-size: 13px;
    border-radius: 7px;
}

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

.btn-primary:hover {
    background: #1668b0;
    border-color: #1668b0;
}

.btn-navy {
    background: var(--cb-navy);
    border-color: var(--cb-navy);
    color: #fff;
}

.btn-navy:hover {
    background: #0b1b2e;
    color: #fff;
}

.btn-outline-secondary {
    border-color: var(--cb-border);
    color: var(--cb-text);
}

.btn-icon {
    padding: 2px 8px;
    font-size: 12px;
}

.badge-soft {
    background: var(--cb-accent-soft);
    color: #135f9f;
    font-weight: 600;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
}

.badge-open { background: #e6f4ec; color: var(--cb-green); }
.badge-cancelled { background: #fdeceb; color: var(--cb-red); }
.badge-dr { background: #fdeceb; color: var(--cb-red); }
.badge-cr { background: #e6f4ec; color: var(--cb-green); }

.alert-floating {
    position: sticky;
    top: 66px;
    z-index: 15;
}

/* --------------------------------------------------------- billing grid --- */
.billing-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.billing-grid th {
    background: #eef2f8;
    padding: 7px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--cb-navy);
    border-bottom: 1px solid var(--cb-border);
}

.billing-grid td {
    padding: 4px 6px;
    border-bottom: 1px solid #eef1f6;
    vertical-align: middle;
}

.billing-grid input {
    font-size: 12.5px;
    padding: 4px 6px;
    height: 30px;
}

.billing-grid .amount-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--cb-navy);
}

.product-thumb {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--cb-border);
    background: #f2f5f9;
}

.photo-preview {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--cb-border);
    background: #f2f5f9;
}

.summary-box {
    background: #f8fafd;
    border: 1px dashed var(--cb-border);
    border-radius: 8px;
    padding: 12px 14px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 3px 0;
}

.summary-row.total {
    border-top: 1px solid var(--cb-border);
    margin-top: 6px;
    padding-top: 8px;
    font-weight: 700;
    font-size: 15px;
    color: var(--cb-navy);
}

/* ------------------------------------------------------------- login --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #1b3b60 0%, #0c1b2d 65%);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 14px;
    padding: 26px 26px 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

.login-brand {
    text-align: center;
    margin-bottom: 18px;
}

.login-brand .sidebar-logo {
    margin: 0 auto 10px;
}

.login-brand h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--cb-navy);
}

.login-brand p {
    font-size: 12px;
    color: var(--cb-muted);
    margin: 0;
}

.login-hint {
    margin-top: 16px;
    padding: 10px 12px;
    background: #f6f8fc;
    border: 1px dashed var(--cb-border);
    border-radius: 8px;
    font-size: 11.5px;
    color: var(--cb-muted);
    line-height: 1.7;
}

/* ------------------------------------------------- invoice / preview --- */
.invoice-sheet {
    background: #fff;
    border: 1px solid var(--cb-border);
    border-radius: 8px;
    padding: 26px 30px;
    box-shadow: var(--cb-shadow);
    max-width: 860px;
    margin: 0 auto;
    color: #111;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 2px solid var(--cb-navy);
    padding-bottom: 12px;
}

.invoice-company-name {
    font-size: 19px;
    font-weight: 700;
    color: var(--cb-navy);
}

.invoice-company-address {
    font-size: 12px;
    line-height: 1.5;
    color: #333;
}

.invoice-tag {
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--cb-muted);
    font-weight: 700;
}

.invoice-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 14px 0 16px;
    font-size: 12.5px;
}

.invoice-meta .box {
    border: 1px solid var(--cb-border);
    border-radius: 6px;
    padding: 10px 12px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.invoice-table th,
.invoice-table td {
    border: 1px solid #c9d2df;
    padding: 6px 8px;
}

.invoice-table th {
    background: #eef2f8;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.invoice-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.invoice-totals {
    width: 320px;
    margin-left: auto;
    margin-top: 10px;
    font-size: 12.5px;
}

.invoice-totals td {
    padding: 5px 8px;
    border-bottom: 1px solid #e6eaf1;
}

.invoice-totals .grand td {
    border-top: 2px solid var(--cb-navy);
    border-bottom: 2px solid var(--cb-navy);
    font-weight: 700;
    font-size: 14px;
}

.invoice-gst-note {
    margin-top: 12px;
    border: 1px dashed #9fb2c8;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11.5px;
    background: #f8fbfe;
}

.invoice-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 22px;
    font-size: 11.5px;
    color: #333;
}

.signature-line {
    border-top: 1px solid #333;
    padding-top: 4px;
    min-width: 170px;
    text-align: center;
}

/* ------------------------------------------------------------ printing --- */
@media print {
    @page {
        size: A4;
        margin: 12mm;
    }

    body {
        background: #fff !important;
        font-size: 12px;
    }

    .app-sidebar,
    .app-topbar,
    .app-footer,
    .no-print,
    #blazor-error-ui,
    .sidebar-nav,
    .btn,
    .page-header .btn {
        display: none !important;
    }

    .app-content {
        padding: 0 !important;
    }

    .invoice-sheet {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    .card-panel {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .print-only {
        display: block !important;
    }

    a[href]:after {
        content: "";
    }
}

.print-only {
    display: none;
}

/* --------------------------------------------------------- responsive --- */
@media (max-width: 992px) {
    .app-shell {
        flex-direction: column;
    }

    .app-sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: relative;
        flex-direction: column;
    }

    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .sidebar-section,
    .sidebar-footer {
        display: none;
    }

    .app-topbar {
        position: relative;
    }
}

/* ------------------------------------------------------- blazor error --- */
#blazor-error-ui {
    background: #fdeceb;
    color: var(--cb-red);
    bottom: 0;
    display: none;
    left: 0;
    padding: .6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 13px;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
    top: .5rem;
}

/* ------------------------------------------------- public invoice page --- */
/* Blank layout: no sidebar/top bar; centred sheet on a neutral background. */
.public-body {
    background: #eef1f6;
    min-height: 100vh;
    padding: 24px 16px 40px;
}

.public-toolbar {
    max-width: 860px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.public-loading {
    max-width: 860px;
    margin: 40px auto;
    text-align: center;
    color: #66748a;
}

.public-error {
    max-width: 520px;
    margin: 60px auto;
    background: #fff;
    border: 1px solid #dfe5ee;
    border-radius: 10px;
    padding: 26px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(16, 36, 62, .06), 0 6px 18px rgba(16, 36, 62, .06);
}

.public-error h1 {
    font-size: 19px;
    color: #10243e;
    margin-bottom: 8px;
}

.public-footer-note {
    margin-top: 14px;
    font-size: 10.5px;
    color: #8a97a8;
    text-align: center;
    border-top: 1px dashed #dfe5ee;
    padding-top: 8px;
}

@media (max-width: 640px) {
    .public-body { padding: 10px 8px 24px; }
    .invoice-sheet { padding: 16px 14px; }
}

@media print {
    .public-body { background: #fff; padding: 0; }
    .public-toolbar, .public-footer-note { display: none !important; }
}
