/*
 * Prisha brand layer — loaded last, after Cuba's style.css and responsive.css.
 *
 * Cuba's own primary purple was repainted to the brand teal inside style.css
 * (docs/ui-theme-patches.md); this file holds the things that are ours rather
 * than a recolour of theirs: the logo sizing, the table chrome, the pagination
 * row, the toolbar alignment and the coloured dashboard tiles.
 *
 * Nothing in here redefines a Bootstrap or Cuba component from scratch — each
 * rule is an override on a selector those files already style.
 */

:root {
    --prisha-green: #6EAE40;
    --prisha-green-dark: #5A9433;
    --prisha-teal: #00797C;
    --prisha-teal-dark: #005F61;
    --prisha-ink: #22313F;
    --prisha-surface: #F4F8F6;
    --prisha-line: #E4ECE7;
    --prisha-gradient: linear-gradient(135deg, var(--prisha-teal) 0%, var(--prisha-green) 100%);
}

/* ---------------------------------------------------------------- branding */

/* The artwork is 2.1:1, not the 3.5:1 of the stock Cuba wordmark, so it is
   sized here rather than left at its natural width — and kept modest, or a
   square-ish logo turns the sidebar head into a banner. */
.logo-wrapper img,
.page-header .header-logo-wrapper .logo-wrapper img {
    width: 132px;
    height: auto;
}

.logo-icon-wrapper img,
.sidebar-links li.back-btn img {
    width: 36px;
    height: auto;
}

/* Cuba hangs a box-shadow under the sidebar's logo block, which reads as a
   rule drawn across the menu above the first section heading. */
.page-wrapper.compact-wrapper .page-body-wrapper div.sidebar-wrapper .logo-wrapper,
.page-wrapper.compact-wrapper .page-body-wrapper div.sidebar-wrapper .logo-icon-wrapper {
    box-shadow: none;
}

/* The login card's logo. Without a width it renders at its natural 420px,
   which is most of the card. */
.login-card .logo img,
.login-card .logo-wrapper img {
    width: 150px;
    height: auto;
}

.login-card .logo {
    margin-bottom: 8px;
}

/* ------------------------------------------------------------ page heading */

.page-title h3 {
    font-weight: 600;
    color: var(--prisha-ink);
}

.page-title .breadcrumb-item.active {
    color: var(--prisha-teal);
    font-weight: 500;
}

/* --------------------------------------------------------------- card head */

.card .card-header {
    border-bottom: 1px solid var(--prisha-line);
}

.card .card-header h5 {
    font-weight: 600;
    color: var(--prisha-ink);
}

/* A heading, a sub-line and the page's actions on one baseline, wrapping to
   their own row on a narrow screen instead of squeezing the buttons. */
.card-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-toolbar .card-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ---------------------------------------------------------------- buttons */

/*
 * Feather renders each `<i data-feather>` as a 24px `<svg>`, which on a button
 * sits on the text baseline and drags the label onto a second line. Laying the
 * button out as a flex row puts icon and label side by side at any font size,
 * and is why no view needs its own spacing hacks.
 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.btn svg,
.btn .feather {
    width: 16px;
    height: 16px;
    stroke-width: 2.2;
    flex: 0 0 auto;
}

.btn-sm svg,
.btn-sm .feather {
    width: 14px;
    height: 14px;
}

/* ------------------------------------------------- action-column icons */

/*
 * Cuba's own action column (`.product-action` on its product list) is a flex
 * row of 34px squares with an 8px gap, never a run of inline links — and that
 * is the shape this column borrows. The wrapper is what makes it work: half
 * these buttons are `<a>` and half are a `<button>` inside a `<form>`, and
 * inline-flex boxes with an SVG for a first child take their baseline from
 * the glyph's bottom edge, so inline markup drops the form buttons about half
 * a line below the links and spaces them by whatever whitespace the Blade
 * happened to leave. A flex row aligns and spaces them regardless.
 */
.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* The column is right-aligned (`th`/`td.text-end`), so the row of tiles is
   too — `text-align` means nothing to a flex container. */
td.text-end .table-actions {
    justify-content: flex-end;
}

/*
 * The control. No tile: a box around a 24px glyph only shrank the glyph, so
 * the icon is the button. The 34px square stays as the hit area (a 24px
 * target is below the 32px minimum for a tap) — it is just invisible until
 * hover. Bootstrap's `.btn-link` underline has to go, or it paints a rule
 * under the glyph, and `.btn`'s padding would squeeze the icon.
 */
.btn.btn-icon {
    gap: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    background: none;
    border-radius: 8px;
    line-height: 1;
    vertical-align: middle;
    text-decoration: none;
}

/*
 * Feather draws on a `0 0 24 24` viewBox, so stroke-width is in viewBox
 * units rather than pixels: `2` at a 16px render size came out as
 * 2/24*16 = 1.33 device px, a half-covered line that anti-aliased to pale
 * grey and left the glyph looking faint. Keep `stroke = 48 / size` so the
 * stroke lands on two whole pixels at whatever size this is.
 */
.btn.btn-icon svg,
.btn.btn-icon .feather {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

/* Teal, not Cuba's low-contrast link grey. With no tile to fill, hover is
   the glyph darkening over a faint wash of the brand surface. */
.btn-link.btn-icon {
    color: var(--prisha-teal);
    transition: color .15s ease, background-color .15s ease;
}

.btn-link.btn-icon:hover,
.btn-link.btn-icon:active {
    color: var(--prisha-teal-dark);
    background-color: var(--prisha-surface);
}

.btn-link.btn-icon:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 121, 124, 0.22);
}

/*
 * Delete, in red. This is `.btn-icon-danger` and not Cuba's `.txt-danger`
 * because that class is `color: #fc564a !important`, which no rule here can
 * override on hover.
 */
.btn-link.btn-icon.btn-icon-danger {
    color: #DC3545;
}

.btn-link.btn-icon.btn-icon-danger:hover,
.btn-link.btn-icon.btn-icon-danger:active {
    color: #B02A37;
    background-color: #FDF2F3;
}

.btn-link.btn-icon.btn-icon-danger:focus-visible {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.22);
}

/* A spent control (a built-in row that cannot be deleted). */
.btn.btn-icon:disabled,
.btn.btn-icon.disabled {
    color: #B6C0C7;
    background: none;
    opacity: 1;
}

.btn-brand {
    background: var(--prisha-gradient);
    border: none;
    color: #fff;
}

.btn-brand:hover,
.btn-brand:focus {
    color: #fff;
    filter: brightness(1.06);
}

/* ------------------------------------------------------------- filter bar */

.filter-bar {
    background: var(--prisha-surface);
    border: 1px solid var(--prisha-line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 18px;
}

/* Most filter forms are the Bootstrap row itself, so the gutter's negative
   side margins have to go or the first field hangs over the panel's edge. */
.filter-bar.row {
    --bs-gutter-x: 0.75rem;
    margin-left: 0;
    margin-right: 0;
}

.filter-bar .form-label {
    margin-bottom: 4px;
}

.filter-bar .form-control,
.filter-bar .form-select {
    background-color: #fff;
}

.filter-bar .filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* A checkbox filter sits on the same line as the buttons; without this the
   flex row shrinks its label and the text runs under the first button. */
.filter-bar .filter-actions .form-check {
    flex: 0 0 auto;
    margin-bottom: 0;
}

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

.table-responsive {
    border: 1px solid var(--prisha-line);
    border-radius: 12px;
}

.table {
    margin-bottom: 0;
}

/* The gradient is on the row, not the cell: per-cell it restarts at every
   column and the header reads as stripes. */
.table > thead > tr {
    background: linear-gradient(90deg, var(--prisha-teal) 0%, var(--prisha-green) 100%);
}

.table > thead > tr > th {
    background-color: transparent;
    color: #fff;
    border-bottom: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 14px 16px;
    white-space: nowrap;
    vertical-align: middle;
}

/* Bootstrap paints cells with an inset box-shadow, which otherwise covers
   the row gradient on a .table-striped / .table-hover table. */
.table > thead > tr > th {
    --bs-table-accent-bg: transparent;
    --bs-table-bg-type: transparent;
    box-shadow: none;
}

.table > thead > tr > th:first-child {
    border-top-left-radius: 12px;
}

.table > thead > tr > th:last-child {
    border-top-right-radius: 12px;
}

.table > tbody > tr > td {
    padding: 13px 16px;
    vertical-align: middle;
    border-color: var(--prisha-line);
}

.table.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: #FAFCFB;
    --bs-table-bg-type: #FAFCFB;
}

.table.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: #EFF6F2;
    --bs-table-bg-type: #EFF6F2;
}

.table > tbody > tr:last-child > td {
    border-bottom: none;
}

/* The last column holds the action tiles, which .table-actions already keeps
   on one line; this stops the column itself from being sized as if the
   tiles could wrap. */
.table > tbody > tr > td:last-child {
    white-space: nowrap;
}

/* A coordinate linked out to a map, in its own column. Inline text, not a
   tile, so it keeps 18px rather than the action column's 16px, and takes the
   brand teal so it reads as a link. Scoped to .map-pin rather than every link
   in a table: an action button is a link too, and .btn-link.btn-icon above
   already colours it. */
.map-pin svg {
    width: 18px;
    height: 18px;
    color: var(--prisha-teal);
    vertical-align: middle;
}

/* ------------------------------------------------------------- pagination */

/*
 * The row under every table: a plain-language count on the left, the pager on
 * the right, stacked on a phone. Laravel's own Bootstrap-5 pagination view is
 * what renders the list (AppServiceProvider), so only the colours are ours.
 */
.table-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 18px;
}

.table-foot .pagination {
    margin-bottom: 0;
}

.table-foot nav {
    margin-left: auto;
}

.pagination .page-link {
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 3px;
    border: 1px solid var(--prisha-line);
    border-radius: 9px;
    color: var(--prisha-ink);
    font-weight: 500;
}

.pagination .page-item.active .page-link {
    background: var(--prisha-gradient);
    border-color: transparent;
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #AEBBC4;
    background: #fff;
}

.pagination .page-link:hover {
    background: var(--prisha-surface);
    color: var(--prisha-teal);
}

.table-foot .pagination-summary {
    color: #6B7C8A;
    font-size: 13px;
}

/* ------------------------------------------------- breakdown mini-cards */

/*
 * The bucket counts above a report's filters (partials/stat-chips). An
 * auto-fit grid rather than a flex row: every card takes an equal share of
 * one line, and the set wraps only when a card would fall under 132px, so
 * seven buckets fit a laptop and still read on a phone.
 */
.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 10px;
}

.mini-stat {
    position: relative;
    overflow: hidden;
    padding: 10px 12px 10px 16px;
    background: #fff;
    border: 1px solid var(--prisha-line);
    border-radius: 11px;
}

/* The accent is a bar down the left edge, not a fill: a row of seven filled
   cards fights the table underneath it. */
.mini-stat::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--mini-accent, var(--prisha-teal));
}

.mini-stat-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    color: #6B7C8A;
}

.mini-stat-value {
    display: block;
    margin-top: 2px;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--mini-accent, var(--prisha-teal));
}

.mini-stat-primary   { --mini-accent: #00797C; }
.mini-stat-success   { --mini-accent: #2E7D32; }
.mini-stat-info      { --mini-accent: #1B6CA8; }
.mini-stat-warning   { --mini-accent: #B5701A; }
.mini-stat-danger    { --mini-accent: #C0392B; }
.mini-stat-secondary { --mini-accent: #5B6B77; }

/* --------------------------------------------------------- dashboard tiles */

/*
 * Six headline cards, one accent each. The accent name arrives from
 * DashboardService with the rest of the tile, so the palette is decided once,
 * in PHP, and this file only knows how to paint it.
 */
.stat-tile {
    position: relative;
    overflow: hidden;
    border: none;
    border-radius: 14px;
    color: #fff;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 26px rgba(34, 49, 63, 0.18);
}

/* A soft disc behind the icon, bleeding off the top-right corner. */
.stat-tile::after {
    content: "";
    position: absolute;
    top: -38px;
    right: -28px;
    width: 116px;
    height: 116px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.13);
}

.stat-tile .stat-label,
.stat-tile .stat-sub {
    color: rgba(255, 255, 255, 0.86);
}

.stat-tile .stat-value {
    color: #fff;
    font-weight: 700;
    font-size: 24px;
    line-height: 1.2;
}

.stat-tile .stat-icon {
    position: relative;
    z-index: 1;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.22);
}

.stat-tile .stat-icon svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.stat-tile.tile-teal    { background: linear-gradient(135deg, #00797C 0%, #0FA3A6 100%); }
.stat-tile.tile-green   { background: linear-gradient(135deg, #4E9B2E 0%, #85C455 100%); }
.stat-tile.tile-blue    { background: linear-gradient(135deg, #1B6CA8 0%, #3FA9DE 100%); }
.stat-tile.tile-amber   { background: linear-gradient(135deg, #D98324 0%, #F5B759 100%); }
.stat-tile.tile-violet  { background: linear-gradient(135deg, #5B4B9B 0%, #8E7CD6 100%); }
.stat-tile.tile-rose    { background: linear-gradient(135deg, #C0392B 0%, #EF7A6B 100%); }

/* ----------------------------------------------------------------- badges */

.badge {
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 0.42em 0.7em;
    border-radius: 7px;
}

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

.card {
    border-radius: 14px;
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: #6B7C8A;
}

.empty-state svg {
    width: 34px;
    height: 34px;
    color: var(--prisha-teal);
    opacity: 0.6;
}

/* ========================================================== dark mode ====

 * Cuba's dark theme is `body.dark-only` (`js/script.js` toggles it from the
 * moon in the header and remembers it in `localStorage["mode-cuba"]`). Its own
 * rules live in `style.css`, which loads *before* this file — so every literal
 * light colour above beat them and the panel kept a white table, a white
 * filter panel and near-black headings on a near-black page. Worst on the
 * Medical Reps and Telecallers lists, which are nothing but a filter panel and
 * a striped table.
 *
 * Two parts. First the four brand tokens are repointed at Cuba's dark palette
 * — `#1d1e26` page, `#262932` card, `#374558` line — which fixes every rule
 * above that was already written against a token (headings, card head rule,
 * filter panel, table borders, pager). Then the rules that hardcoded a hex:
 * table stripes, input fills, the icon-button washes and the muted greys.
 *
 * `--prisha-teal` and `--prisha-green` are deliberately *not* repointed: the
 * table head, the active page and the dashboard tiles are white-on-gradient
 * and read as well on a dark page as a light one. Text that merely takes the
 * accent is a different matter — #00797C on #262932 is under 3:1 — so those
 * few rules switch to `--prisha-accent`, a lighter teal for dark surfaces.
 */

body.dark-only {
    --prisha-ink: rgba(255, 255, 255, 0.82);
    --prisha-surface: #22242e;
    --prisha-line: #374558;
    --prisha-accent: #3BBFC2;
    --prisha-muted: rgba(255, 255, 255, 0.5);
}

/* ------------------------------------------------------- dark · headings */

body.dark-only .page-title .breadcrumb-item.active {
    color: var(--prisha-accent);
}

/* ----------------------------------------------------- dark · filter bar */

/* The fields sit on the tinted panel, so they take the card colour rather
   than the page colour — otherwise the inputs vanish into the panel. */
body.dark-only .filter-bar .form-control,
body.dark-only .filter-bar .form-select {
    background-color: #262932;
    border-color: var(--prisha-line);
    color: rgba(255, 255, 255, 0.7);
}

/* --------------------------------------------------------- dark · tables */

/*
 * The striped rows were the white background: #FAFCFB won over Cuba's
 * `--light-datatable-odd`. Both stripe and hover stay a step off the card
 * colour in the same direction Bootstrap takes them in light mode — odd rows
 * a shade darker, hover a shade lighter.
 */
body.dark-only .table.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: #1f212a;
    --bs-table-bg-type: #1f212a;
}

body.dark-only .table.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: #2d313d;
    --bs-table-bg-type: #2d313d;
}

body.dark-only .table > tbody > tr > td,
body.dark-only .table > tbody > tr > th {
    color: rgba(255, 255, 255, 0.72);
}

body.dark-only .map-pin svg {
    color: var(--prisha-accent);
}

/* --------------------------------------------- dark · action-column icons */

body.dark-only .btn-link.btn-icon {
    color: var(--prisha-accent);
}

body.dark-only .btn-link.btn-icon:hover,
body.dark-only .btn-link.btn-icon:active {
    color: #6FD4D6;
    background-color: rgba(59, 191, 194, 0.14);
}

/* Bootstrap's own red is too dark to sit on #262932; the wash is the same
   colour at low alpha rather than the pink tint used in light mode. */
body.dark-only .btn-link.btn-icon.btn-icon-danger {
    color: #FF7A85;
}

body.dark-only .btn-link.btn-icon.btn-icon-danger:hover,
body.dark-only .btn-link.btn-icon.btn-icon-danger:active {
    color: #FF9AA2;
    background-color: rgba(255, 122, 133, 0.15);
}

body.dark-only .btn.btn-icon:disabled,
body.dark-only .btn.btn-icon.disabled {
    color: rgba(255, 255, 255, 0.25);
}

/* -------------------------------------------------------- dark · buttons */

/*
 * `.btn-light` is the Cancel / Reset / Back button on every form and filter
 * bar. Cuba recolours its *text* to white in dark mode but leaves Bootstrap's
 * `#f8f9fa` fill, which is white text on a white button. The `!important` is
 * forced: Cuba's colour rule carries one.
 */
body.dark-only .btn-light {
    background-color: #262932;
    border-color: var(--prisha-line);
    color: rgba(255, 255, 255, 0.72) !important;
}

body.dark-only .btn-light:hover,
body.dark-only .btn-light:focus {
    background-color: #2d313d;
    border-color: #44546b;
}

/* ----------------------------------------------------- dark · pagination */

body.dark-only .pagination .page-link {
    background-color: #1d1e26;
    color: rgba(255, 255, 255, 0.7);
}

body.dark-only .pagination .page-link:hover {
    background-color: #2d313d;
    color: var(--prisha-accent);
}

body.dark-only .pagination .page-item.disabled .page-link {
    background: #1d1e26;
    color: rgba(255, 255, 255, 0.25);
}

body.dark-only .table-foot .pagination-summary {
    color: var(--prisha-muted);
}

/* --------------------------------------------------------- dark · badges */

/*
 * Cuba's `.badge-light-*` is a translucent wash with the *solid* colour as
 * its text — fine on white, under 3:1 on #262932. The wash stays; the text
 * moves to the light end of each hue. These are the status and region chips
 * on every list and detail screen.
 */
body.dark-only .badge-light-primary   { color: #4FCFD2; }
body.dark-only .badge-light-success   { color: #8FDB89; }
body.dark-only .badge-light-info      { color: #74C4EC; }
body.dark-only .badge-light-warning   { color: #F3C36B; }
body.dark-only .badge-light-danger    { color: #FF9AA2; }
body.dark-only .badge-light-secondary { color: #B9C4CE; }

/* ---------------------------------------------------- dark · mini-cards */

body.dark-only .mini-stat {
    background: #262932;
}

body.dark-only .mini-stat-label {
    color: var(--prisha-muted);
}

/* The accents are chosen for contrast against white; each moves to the light
   end of the same hue so the figure and its bar still read on #262932. */
body.dark-only .mini-stat-primary   { --mini-accent: #4FCFD2; }
body.dark-only .mini-stat-success   { --mini-accent: #7FD67A; }
body.dark-only .mini-stat-info      { --mini-accent: #6CBEE8; }
body.dark-only .mini-stat-warning   { --mini-accent: #E9B861; }
body.dark-only .mini-stat-danger    { --mini-accent: #F08A7D; }
body.dark-only .mini-stat-secondary { --mini-accent: #A9B6C1; }

/* ----------------------------------------------------------- dark · misc */

body.dark-only .empty-state {
    color: var(--prisha-muted);
}

body.dark-only .empty-state svg {
    color: var(--prisha-accent);
}
