/* ===========================================================
   Bootstrap Theme Override — IntegerByte Brand
   ---------------------------------------------------------
   Bootstrap 5.3 ships every component's colors as CSS custom
   properties (--bs-*). Rather than recompiling Bootstrap's Sass
   (which needs a Node build step this project doesn't run),
   we re-point those variables at our own design tokens
   (tokens.css) right after bootstrap.min.css loads. This file
   must load AFTER bootstrap.min.css and AFTER tokens.css.
=========================================================== */

/* --- Global Bootstrap variables (cascades into focus rings,
       pagination, form-check, links, etc.) --- */
:root {
    --bs-primary: var(--ib-primary-500);
    --bs-primary-rgb: var(--ib-primary-rgb);
    --bs-link-color: var(--ib-primary-600);
    --bs-link-color-rgb: 214, 58, 22;
    --bs-link-hover-color: var(--ib-primary-700);
    --bs-link-hover-color-rgb: 178, 44, 16;
    --bs-body-font-family: var(--ib-font-sans);
    --bs-body-color: var(--ib-text);
    --bs-body-bg: var(--ib-bg);
    --bs-border-color: var(--ib-border);
    --bs-border-radius: var(--ib-radius-sm);
    --bs-border-radius-lg: var(--ib-radius-md);
    --bs-border-radius-sm: 8px;
}

body {
    font-family: var(--ib-font-sans);
}

/* --- Buttons --- */
.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--ib-primary-500);
    --bs-btn-border-color: var(--ib-primary-500);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--ib-primary-600);
    --bs-btn-hover-border-color: var(--ib-primary-600);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--ib-primary-700);
    --bs-btn-active-border-color: var(--ib-primary-700);
    --bs-btn-focus-shadow-rgb: var(--ib-primary-rgb);
    --bs-btn-disabled-bg: var(--ib-primary-300);
    --bs-btn-disabled-border-color: var(--ib-primary-300);
}

.btn-outline-primary {
    --bs-btn-color: var(--ib-primary-600);
    --bs-btn-border-color: var(--ib-primary-500);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--ib-primary-500);
    --bs-btn-hover-border-color: var(--ib-primary-500);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--ib-primary-600);
    --bs-btn-active-border-color: var(--ib-primary-600);
    --bs-btn-focus-shadow-rgb: var(--ib-primary-rgb);
    --bs-btn-disabled-color: var(--ib-primary-300);
    --bs-btn-disabled-border-color: var(--ib-primary-200);
}

.btn-secondary {
    --bs-btn-color: var(--ib-text);
    --bs-btn-bg: var(--ib-surface);
    --bs-btn-border-color: var(--ib-border);
    --bs-btn-hover-color: var(--ib-text);
    --bs-btn-hover-bg: var(--ib-surface-subtle);
    --bs-btn-hover-border-color: var(--ib-border);
    --bs-btn-active-color: var(--ib-text);
    --bs-btn-active-bg: var(--ib-surface-subtle);
    --bs-btn-active-border-color: var(--ib-border);
}

.btn-light {
    --bs-btn-color: var(--ib-text);
    --bs-btn-bg: var(--ib-surface);
    --bs-btn-border-color: var(--ib-border);
    --bs-btn-hover-bg: var(--ib-surface-subtle);
    --bs-btn-hover-border-color: var(--ib-border);
}

.btn-success {
    --bs-btn-bg: var(--ib-success);
    --bs-btn-border-color: var(--ib-success);
    --bs-btn-hover-bg: #116430;
    --bs-btn-hover-border-color: #116430;
}

.btn-danger {
    --bs-btn-bg: var(--ib-danger);
    --bs-btn-border-color: var(--ib-danger);
    --bs-btn-hover-bg: #b91c1c;
    --bs-btn-hover-border-color: #b91c1c;
}

.btn-warning {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--ib-warning);
    --bs-btn-border-color: var(--ib-warning);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #92400a;
    --bs-btn-hover-border-color: #92400a;
}

.btn,
.btn-check + .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: var(--ib-radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    min-height: 44px;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    box-shadow: var(--ib-shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, color .18s ease;
}

.btn:hover,
.btn:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--ib-shadow-md);
}

.btn-sm {
    min-height: 34px;
    font-size: 0.8rem;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
}

.btn-lg {
    min-height: 50px;
    font-size: 0.95rem;
}

/* --- Text / background / border utility colors --- */
.text-primary { color: var(--ib-primary-600) !important; }
.text-success { color: var(--ib-success) !important; }
.text-warning { color: var(--ib-warning) !important; }
.text-danger  { color: var(--ib-danger) !important; }
.text-info    { color: var(--ib-info) !important; }
.text-dark    { color: var(--ib-dark-900) !important; }
.text-secondary,
.text-muted   { color: var(--ib-text-muted) !important; }

.bg-primary { background-color: var(--ib-primary-500) !important; }
.bg-success { background-color: var(--ib-success) !important; }
.bg-warning { background-color: var(--ib-warning) !important; }
.bg-danger  { background-color: var(--ib-danger) !important; }
.bg-info    { background-color: var(--ib-info) !important; }
.bg-light   { background-color: var(--ib-dark-50) !important; }
/* Many card-headers use Bootstrap's bg-white utility directly (instead of
   the token-driven .card-header rule below) — route it through the same
   surface token so those headers go dark in dark mode instead of staying
   stuck white. */
.bg-white   { background-color: var(--ib-surface) !important; }

.border-primary { border-color: var(--ib-primary-500) !important; }

/* --- Alerts --- */
.alert-success { background-color: var(--ib-success-tint); border-color: var(--ib-success); color: #0f5c2c; }
.alert-danger   { background-color: var(--ib-danger-tint); border-color: var(--ib-danger); color: #9b1c1c; }
.alert-warning  { background-color: var(--ib-warning-tint); border-color: var(--ib-warning); color: #8a4308; }
.alert-info     { background-color: var(--ib-info-tint); border-color: var(--ib-info); color: #1d4ed8; }
.alert {
    border-radius: var(--ib-radius-md);
    border-width: 1px;
    box-shadow: var(--ib-shadow-sm);
}

/* --- Forms --- */
.form-control,
.form-select {
    border-radius: var(--ib-radius-sm);
    border: 1px solid var(--ib-border);
    min-height: 44px;
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ib-primary-400);
    box-shadow: 0 0 0 0.2rem rgba(var(--ib-primary-rgb), 0.15);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--ib-danger);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ib-text);
}

.invalid-feedback,
.form-text {
    font-size: 0.8rem;
}

/* --- Cards --- */
.card {
    background: var(--ib-surface);
    color: var(--ib-text);
    border: 1px solid var(--ib-border);
    border-radius: var(--ib-radius-lg);
    box-shadow: var(--ib-shadow-sm);
}

.dropdown-menu {
    background: var(--ib-surface);
    color: var(--ib-text);
}

.dropdown-item {
    color: var(--ib-text);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--ib-surface-subtle);
    color: var(--ib-text);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--ib-border);
    font-weight: 600;
}

/* --- Tables ---
   .ib-table is used on the Clients/Invoices list pages: consistent cell
   padding and vertical alignment so columns line up cleanly row to row,
   with the last column (actions) right-aligned to match its header. */
.table thead th {
    background: var(--ib-primary-50);
    color: var(--ib-primary-700);
    border-bottom: none;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
}

.ib-table th,
.ib-table td {
    padding: 0.9rem 1.25rem;
    vertical-align: middle;
    white-space: nowrap;
}

.ib-table td small,
.ib-table td .text-muted {
    white-space: normal;
}

/* Mobile stacked-card replacement for .ib-table below the md breakpoint —
   see the Clients/Invoices list pages, which render each row as one of
   these instead of squeezing a wide multi-column table sideways. */
.ib-row-card {
    border-bottom: 1px solid var(--ib-border);
}
.ib-row-card:last-child {
    border-bottom: none;
}

/* --- Delete-confirmation modal (replaces the browser's native confirm()) --- */
.ib-confirm-modal {
    background: var(--ib-surface);
    color: var(--ib-text);
    border: none;
    border-radius: var(--ib-radius-lg);
    box-shadow: var(--ib-shadow-lg);
}

.modal-backdrop.show {
    opacity: 0.6;
}

/* Bootstrap's table-light utility (used for a couple of table headers) bakes
   in a literal light-grey/dark-text pair that ignores the site theme —
   route it through the surface tokens so it doesn't look like a stray light
   patch on a dark page. */
.table-light,
.table-light > th,
.table-light > td {
    --bs-table-bg: var(--ib-surface-subtle);
    --bs-table-color: var(--ib-text);
}

.ib-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    color: var(--ib-danger);
    background: var(--ib-danger-tint);
}

.ib-confirm-icon-warning {
    color: #B45309;
    background: #FEF3E2;
}

/* --- Monthly-limit dialog (Invoice\Form / Guest\CreateInvoice) — a plain
   Alpine-driven overlay bound straight to a Livewire boolean via $wire,
   rather than Bootstrap's JS Modal component: it only ever needs to open in
   reaction to a server-side check (never a plain client click), so there's
   no Bootstrap data-bs-toggle trigger to hang it off, and binding through
   $wire keeps it in sync across every re-render without a wire:ignore
   workaround. */
.ib-limit-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 20, 0.6);
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ib-limit-modal {
    background: var(--ib-surface);
    color: var(--ib-text);
    border-radius: var(--ib-radius-lg);
    box-shadow: var(--ib-shadow-lg);
    max-width: 440px;
    width: 100%;
    padding: 2rem;
}

[x-cloak] {
    display: none !important;
}

/* --- Dropdowns / nav / pagination pick up --bs-primary automatically --- */
.dropdown-menu {
    border: none;
    border-radius: var(--ib-radius-md);
    box-shadow: var(--ib-shadow-lg);
}

/* Invoice status badges: distinct colors per status instead of one flat
   primary color for everything, so status is scannable at a glance. */
.ib-status-badge { font-weight: 600; }
.ib-status-draft { background: var(--ib-surface-subtle); color: var(--ib-text); }
.ib-status-sent { background: var(--ib-info-tint); color: var(--ib-info); }
.ib-status-paid { background: var(--ib-success-tint); color: var(--ib-success); }
.ib-status-partial { background: var(--ib-warning-tint); color: var(--ib-warning); }
.ib-status-overdue,
.ib-status-cancelled { background: var(--ib-danger-tint); color: var(--ib-danger); }

.badge {
    font-weight: 600;
    border-radius: var(--ib-radius-pill);
}

/* Invoice template picker cards (Business Profile) — highlight whichever
   template's radio is currently checked. */
.ib-template-card {
    background: var(--ib-surface);
    border-color: var(--ib-border) !important;
    transition: border-color .15s ease, background .15s ease;
}
.ib-template-card:has(.form-check-input:checked) {
    border-color: var(--ib-primary-500) !important;
    background: var(--ib-primary-50);
}
