/* ==========================================================================
   MediaBooks.in — application stylesheet
   Layered on top of Bootstrap 5. Tokens first, components second, so a theme
   change is a variable edit rather than a search-and-replace.
   ========================================================================== */

:root {
    /* Brand — deep navy reads as "finance" without going corporate-grey. */
    --mb-primary:        #1e3a5f;
    --mb-primary-dark:   #16293f;
    --mb-primary-light:  #2d5182;
    --mb-accent:         #0f9d8f;
    --mb-accent-dark:    #0b7a6f;

    /* Status — the same six meanings recur across every module. */
    --mb-draft:      #64748b;
    --mb-pending:    #d97706;
    --mb-approved:   #16a34a;
    --mb-rejected:   #dc2626;
    --mb-paid:       #0f766e;
    --mb-onhold:     #0284c7;

    /* Surfaces */
    --mb-bg:          #f4f6f9;
    --mb-surface:     #ffffff;
    --mb-surface-alt: #fafbfc;
    --mb-border:      #e2e8f0;
    --mb-border-dark: #cbd5e1;

    /* Text */
    --mb-text:        #1f2937;
    --mb-text-muted:  #64748b;
    --mb-text-invert: #f8fafc;

    /* Money */
    --mb-credit:  #16a34a;
    --mb-debit:   #dc2626;

    /* Shape & depth */
    --mb-radius:    8px;
    --mb-radius-sm: 5px;
    --mb-shadow:    0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --mb-shadow-lg: 0 10px 25px rgba(15, 23, 42, .10);

    --mb-sidebar-width: 250px;
    --mb-header-height: 58px;

    --mb-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    /* Tabular figures keep amount columns aligned digit-for-digit. */
    --mb-font-mono: "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

/* -------------------------------------------------------------- base */

body {
    background: var(--mb-bg);
    color: var(--mb-text);
    font-family: var(--mb-font);
    font-size: .9rem;
    line-height: 1.55;
}

a { color: var(--mb-primary-light); text-decoration: none; }
a:hover { color: var(--mb-primary); text-decoration: underline; }

.mb-page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--mb-primary);
    margin: 0;
}

.mb-muted { color: var(--mb-text-muted); }

/* -------------------------------------------------------------- layout */

.mb-shell { display: flex; min-height: 100vh; }

.mb-sidebar {
    width: var(--mb-sidebar-width);
    flex: 0 0 var(--mb-sidebar-width);
    background: var(--mb-primary-dark);
    color: var(--mb-text-invert);
    padding: 1rem 0;
}

.mb-sidebar .nav-link {
    color: rgba(248, 250, 252, .75);
    padding: .55rem 1.15rem;
    border-radius: 0;
    font-size: .875rem;
}

.mb-sidebar .nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
    text-decoration: none;
}

.mb-sidebar .nav-link.active {
    background: var(--mb-primary);
    color: #fff;
    /* The left rule is the only "you are here" cue that survives a print. */
    box-shadow: inset 3px 0 0 var(--mb-accent);
}

.mb-sidebar-heading {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: rgba(248, 250, 252, .45);
    padding: 1rem 1.15rem .35rem;
}

.mb-main { flex: 1 1 auto; min-width: 0; }

.mb-header {
    height: var(--mb-header-height);
    background: var(--mb-surface);
    border-bottom: 1px solid var(--mb-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
}

.mb-content { padding: 1.25rem; }

/* -------------------------------------------------------------- cards */

.mb-card {
    background: var(--mb-surface);
    border: 1px solid var(--mb-border);
    border-radius: var(--mb-radius);
    box-shadow: var(--mb-shadow);
    margin-bottom: 1.25rem;
}

.mb-card-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--mb-border);
    background: var(--mb-surface-alt);
    border-radius: var(--mb-radius) var(--mb-radius) 0 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.mb-card-body { padding: 1rem; }

/* Stat tiles on the dashboard. */
.mb-stat { display: flex; flex-direction: column; gap: .15rem; }
.mb-stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mb-text-muted); }
.mb-stat-value { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- tables */

.mb-table { width: 100%; background: var(--mb-surface); font-size: .85rem; }

.mb-table thead th {
    background: var(--mb-surface-alt);
    border-bottom: 2px solid var(--mb-border-dark);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--mb-text-muted);
    white-space: nowrap;
    padding: .6rem .7rem;
}

.mb-table tbody td { padding: .55rem .7rem; border-bottom: 1px solid var(--mb-border); vertical-align: middle; }
.mb-table tbody tr:hover { background: #f8fafc; }

/* Amounts: right-aligned, monospaced, fixed-width digits. */
.mb-amount {
    text-align: right;
    font-family: var(--mb-font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.mb-amount-credit { color: var(--mb-credit); }
.mb-amount-debit  { color: var(--mb-debit); }

/* Masked PAN/bank values — visibly redacted, never mistaken for real data. */
.mb-masked {
    font-family: var(--mb-font-mono);
    letter-spacing: .04em;
    color: var(--mb-text-muted);
}

.mb-empty { text-align: center; padding: 2.5rem 1rem; color: var(--mb-text-muted); }

/* -------------------------------------------------------------- status */

.mb-badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    line-height: 1.4;
}

.mb-badge-draft    { background: #f1f5f9; color: var(--mb-draft); }
.mb-badge-pending  { background: #fef3c7; color: #92400e; }
.mb-badge-approved { background: #dcfce7; color: #15803d; }
.mb-badge-rejected { background: #fee2e2; color: #b91c1c; }
.mb-badge-paid     { background: #ccfbf1; color: #0f766e; }
.mb-badge-onhold   { background: #e0f2fe; color: #0369a1; }

/* -------------------------------------------------------------- forms */

.form-label { font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: .25rem; }
.form-label .mb-required { color: var(--mb-debit); }

.form-control, .form-select {
    font-size: .875rem;
    border-color: var(--mb-border-dark);
    border-radius: var(--mb-radius-sm);
}

.form-control:focus, .form-select:focus {
    border-color: var(--mb-primary-light);
    box-shadow: 0 0 0 .18rem rgba(45, 81, 130, .15);
}

.mb-field-error { color: var(--mb-debit); font-size: .76rem; margin-top: .2rem; }
.is-invalid { border-color: var(--mb-debit) !important; }

/* Amount inputs get the same tabular treatment as amount cells. */
input.mb-amount-input {
    text-align: right;
    font-family: var(--mb-font-mono);
    font-variant-numeric: tabular-nums;
}

.btn { font-size: .85rem; border-radius: var(--mb-radius-sm); }

.btn-mb-primary {
    background: var(--mb-primary);
    border-color: var(--mb-primary);
    color: #fff;
}
.btn-mb-primary:hover { background: var(--mb-primary-dark); border-color: var(--mb-primary-dark); color: #fff; }

.btn-mb-accent { background: var(--mb-accent); border-color: var(--mb-accent); color: #fff; }
.btn-mb-accent:hover { background: var(--mb-accent-dark); border-color: var(--mb-accent-dark); color: #fff; }

/* -------------------------------------------------------------- misc */

.mb-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.mb-toolbar .mb-spacer { margin-left: auto; }

/* Approval timeline on request/approval screens. */
.mb-timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--mb-border); }
.mb-timeline li { position: relative; padding: 0 0 1rem 1rem; }
.mb-timeline li::before {
    content: "";
    position: absolute;
    left: -1.42rem;
    top: .35rem;
    width: .6rem;
    height: .6rem;
    border-radius: 50%;
    background: var(--mb-border-dark);
    box-shadow: 0 0 0 3px var(--mb-bg);
}
.mb-timeline li.is-approved::before { background: var(--mb-approved); }
.mb-timeline li.is-rejected::before { background: var(--mb-rejected); }
.mb-timeline li.is-pending::before  { background: var(--mb-pending); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 992px) {
    .mb-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1040; transform: translateX(-100%); transition: transform .2s ease; }
    .mb-sidebar.is-open { transform: translateX(0); }
    .mb-content { padding: 1rem .75rem; }
}

/* -------------------------------------------------------------- print */

@media print {
    .mb-sidebar, .mb-header, .mb-toolbar, .btn { display: none !important; }
    body { background: #fff; }
    .mb-card { border: 1px solid #999; box-shadow: none; }
}

/* ==========================================================================
   Auth shell + navigation (Prompt 3)
   ========================================================================== */

.mb-guest-body {
    background: linear-gradient(160deg, var(--mb-primary-dark) 0%, var(--mb-primary) 55%, #14304f 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.mb-guest-wrap { width: 100%; max-width: 25rem; }

.mb-guest-card {
    background: var(--mb-surface);
    border-radius: var(--mb-radius);
    box-shadow: var(--mb-shadow-lg);
    padding: 2rem 1.75rem;
}

.mb-guest-brand { text-align: center; margin-bottom: 1.5rem; }

.mb-guest-logo {
    width: 3rem; height: 3rem;
    margin: 0 auto .6rem;
    border-radius: 12px;
    background: var(--mb-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; font-weight: 700;
}

.mb-guest-brand h1 { font-size: 1.15rem; font-weight: 600; color: var(--mb-primary); margin: 0; }
.mb-guest-brand p  { font-size: .78rem; color: var(--mb-text-muted); margin: .15rem 0 0; }

.mb-guest-note {
    margin: 1rem 0 0;
    font-size: .76rem;
    color: var(--mb-text-muted);
    text-align: center;
    line-height: 1.5;
}

.mb-guest-policy {
    background: var(--mb-surface-alt);
    border: 1px solid var(--mb-border);
    border-radius: var(--mb-radius-sm);
    padding: .6rem .8rem;
    margin-bottom: 1rem;
    font-size: .76rem;
    color: var(--mb-text-muted);
}
.mb-guest-policy ul { margin: .35rem 0 0; padding-left: 1.1rem; }

.mb-guest-footer {
    margin: 1.1rem 0 0;
    text-align: center;
    font-size: .72rem;
    color: rgba(255, 255, 255, .6);
}

/* -------------------------------------------------------------- sidebar */

.mb-sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 0 1.15rem 1rem;
    margin-bottom: .25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.mb-sidebar-logo {
    width: 1.9rem; height: 1.9rem;
    border-radius: 7px;
    background: var(--mb-accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .95rem;
    flex: 0 0 auto;
}

.mb-sidebar-title {
    font-size: .9rem; font-weight: 600; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mb-nav-icon {
    display: inline-block;
    width: 1.15rem;
    margin-right: .5rem;
    text-align: center;
    opacity: .85;
}

/* A module the user may reach but which is not built yet. Shown rather than
   hidden so the shape of the system stays visible during the build. */
.mb-nav-pending {
    color: rgba(248, 250, 252, .32) !important;
    cursor: default;
}
.mb-nav-pending:hover { background: transparent !important; }

.mb-nav-soon {
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    border: 1px solid currentColor;
    border-radius: 3px;
    padding: 0 .25rem;
    margin-left: .35rem;
    opacity: .8;
}

.mb-header .dropdown-menu { min-width: 15rem; }

/* ==========================================================================
   Activity timeline (Prompt 5) — the readable face of audit_logs
   ========================================================================== */

.mb-timeline li { padding-bottom: 1.1rem; }

.mb-timeline li:last-child { padding-bottom: 0; }

.mb-timeline-diff {
    margin-top: .35rem;
    padding: .4rem .55rem;
    background: var(--mb-surface-alt);
    border: 1px solid var(--mb-border);
    border-radius: var(--mb-radius-sm);
    font-size: .76rem;
}

.mb-timeline-diff-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .35rem;
    padding: .1rem 0;
}

.mb-timeline-field {
    min-width: 8rem;
    color: var(--mb-text-muted);
    font-weight: 600;
}

/* Old value struck through, new value emphasised: the direction of a change
   should be readable at a glance without reading the labels. */
.mb-diff-old {
    color: var(--mb-text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--mb-debit);
    word-break: break-word;
}

.mb-diff-arrow { color: var(--mb-text-muted); }

.mb-diff-new {
    color: var(--mb-text);
    font-weight: 600;
    word-break: break-word;
}

.mb-timeline-reason {
    margin-top: .35rem;
    padding: .35rem .55rem;
    border-left: 3px solid var(--mb-pending);
    background: #fffbeb;
    font-size: .76rem;
    color: #78350f;
    border-radius: 0 var(--mb-radius-sm) var(--mb-radius-sm) 0;
}

/* Revealed PII: visually distinct so a reader knows the value on screen is a
   real identifier, not a mask, and that the reveal was recorded. */
.mb-revealed {
    background: #fef3c7;
    color: #78350f;
    padding: 0 .3rem;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: .02em;
}
