/*
 * Subscriber-facing design system. Deliberately distinct from the
 * operator portal's dark terminal aesthetic (static/operator/css/
 * operator.css) - this is the customer-facing product surface and
 * targets a light-default, data-dense, professional SaaS look (think
 * Clearbit/Apollo.io/LinkedIn Sales Navigator), not an internal ops
 * tool. Overrides Bootstrap 5.3 defaults rather than replacing them -
 * loaded after bootstrap.min.css in base.html, and leans on
 * Bootstrap's --bs-* custom properties so most components (buttons,
 * forms, alerts, badges) pick up the new palette/spacing for free.
 */

:root,
[data-bs-theme="light"] {
    --bf-bg: #ffffff;
    --bf-bg-subtle: #f8f9fb;
    --bf-surface: #ffffff;
    --bf-border: #e3e6eb;
    --bf-border-strong: #d0d4dc;
    --bf-text: #1a1d29;
    --bf-text-secondary: #667085;
    --bf-text-muted: #98a2b3;
    --bf-accent: #4338ca;
    --bf-accent-hover: #372da3;
    --bf-accent-subtle: #eef0fd;
    --bf-quality-green: #16a34a;
    --bf-quality-amber: #d97706;
    --bf-quality-red: #dc2626;
    --bf-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

[data-bs-theme="dark"] {
    --bf-bg: #14161c;
    --bf-bg-subtle: #1a1d26;
    --bf-surface: #1c1f28;
    --bf-border: #2b2f3a;
    --bf-border-strong: #383e4d;
    --bf-text: #e7e9ee;
    --bf-text-secondary: #9aa1b1;
    --bf-text-muted: #6b7280;
    --bf-accent: #8b7ff0;
    --bf-accent-hover: #a196f5;
    --bf-accent-subtle: #232244;
    --bf-quality-green: #34c759;
    --bf-quality-amber: #f0a634;
    --bf-quality-red: #f16060;
    --bf-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
    --bs-border-radius: 4px;
    --bs-border-radius-sm: 3px;
    --bs-border-radius-lg: 4px;
    --bs-border-color: var(--bf-border);
    --bs-body-bg: var(--bf-bg);
    --bs-body-color: var(--bf-text);
    --bs-secondary-color: var(--bf-text-secondary);
    --bs-primary: var(--bf-accent);
    --bs-primary-rgb: 67, 56, 202;
    --bs-link-color: var(--bf-accent);
    --bs-link-hover-color: var(--bf-accent-hover);
    --bs-emphasis-color: var(--bf-text);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 0.9375rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: inherit;
    letter-spacing: -0.01em;
}

/* ---------- navbar ---------- */

.navbar {
    background: var(--bf-surface);
    border-bottom: 1px solid var(--bf-border) !important;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.navbar-brand {
    font-weight: 650;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--bf-text) !important;
}

.navbar-nav .nav-link {
    color: var(--bf-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: var(--bs-border-radius);
    transition: color 120ms ease, background-color 120ms ease;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
    color: var(--bf-text);
    background: var(--bf-bg-subtle);
}

#theme-toggle {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    color: var(--bf-text-muted);
    border-color: var(--bf-border);
}

#theme-toggle:hover {
    color: var(--bf-text-secondary);
    background: var(--bf-bg-subtle);
    border-color: var(--bf-border-strong);
}

/* ---------- footer ---------- */

footer {
    border-top: 1px solid var(--bf-border) !important;
    color: var(--bf-text-muted);
    font-size: 0.8125rem;
    padding: 1rem 0;
}

footer a {
    color: var(--bf-text-secondary);
}

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

.btn {
    font-weight: 550;
    font-size: 0.875rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--bs-border-radius);
}

.btn-sm {
    font-size: 0.8125rem;
    padding: 0.3rem 0.65rem;
}

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

.btn-primary:hover,
.btn-primary:focus {
    background: var(--bf-accent-hover);
    border-color: var(--bf-accent-hover);
}

.btn-outline-primary {
    color: var(--bf-accent);
    border-color: var(--bf-border-strong);
}

.btn-outline-primary:hover {
    background: var(--bf-accent);
    border-color: var(--bf-accent);
}

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

.btn-outline-secondary:hover {
    background: var(--bf-bg-subtle);
    color: var(--bf-text);
    border-color: var(--bf-border-strong);
}

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

.form-control,
.form-select {
    background: var(--bf-surface);
    border-color: var(--bf-border-strong);
    color: var(--bf-text);
    font-size: 0.875rem;
    padding: 0.4rem 0.65rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bf-accent);
    box-shadow: 0 0 0 3px var(--bf-accent-subtle);
}

.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bf-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.3rem;
}

.form-check-input:checked {
    background-color: var(--bf-accent);
    border-color: var(--bf-accent);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px var(--bf-accent-subtle);
}

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

.card {
    background: var(--bf-surface);
    border: 1px solid var(--bf-border);
    border-radius: var(--bs-border-radius);
    box-shadow: var(--bf-shadow);
}

.card-body {
    padding: 1.1rem 1.25rem;
}

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

.badge {
    font-weight: 550;
    font-size: 0.6875rem;
    letter-spacing: 0.02em;
    padding: 0.3em 0.55em;
}

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

.table {
    font-size: 0.875rem;
    color: var(--bf-text);
    --bs-table-bg: transparent;
}

.table > thead > tr > th {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 650;
    color: var(--bf-text-muted);
    border-bottom: 1px solid var(--bf-border);
    padding: 0.45rem 0.6rem;
    white-space: nowrap;
}

.table > tbody > tr > td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--bf-border);
    vertical-align: middle;
}

.table > tbody > tr:hover {
    background: var(--bf-bg-subtle);
}

.table-responsive {
    border: 1px solid var(--bf-border);
    border-radius: var(--bs-border-radius);
}

.table-responsive .table {
    margin-bottom: 0;
}

.table-responsive .table > thead > tr > th:first-child,
.table-responsive .table > tbody > tr > td:first-child {
    padding-left: 0.85rem;
}

/* A bare .form-check-input used directly in a <td> (no .form-check
   wrapper - see app/_business_row.html) inherits Bootstrap's -1.5em
   left margin meant for that wrapper's padding, which shifts it out
   of alignment with the row. Reset it back to 0 in this context. */
.table td > .form-check-input {
    margin-left: 0;
    vertical-align: middle;
}

/* Result name column - slightly bolder, sits next to the quality dot */
.result-name {
    font-weight: 560;
    color: var(--bf-text);
}

.quality-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.45rem;
    flex-shrink: 0;
}

.quality-dot.bg-success { background: var(--bf-quality-green) !important; }
.quality-dot.bg-warning { background: var(--bf-quality-amber) !important; }
.quality-dot.bg-danger  { background: var(--bf-quality-red) !important; }
.quality-dot.bg-secondary { background: var(--bf-text-muted) !important; }

.upgrade-inline-link {
    color: var(--bf-text-muted) !important;
    font-size: 0.8125rem;
    font-style: italic;
    text-decoration: none;
}

.upgrade-inline-link:hover {
    color: var(--bf-text-secondary) !important;
    text-decoration: underline;
}

/* ---------- search-in-progress feedback ----------
   Search now fires on explicit form submit only (not on every filter
   change - too easy to fire a search before you've finished picking
   state/county/type), so a visible "still working" signal matters
   more than before. Same opacity-toggle pattern already proven in the
   operator portal (static/operator/css/operator.css). */

.htmx-indicator {
    opacity: 0;
    transition: opacity 120ms ease-in;
}

.htmx-request.htmx-indicator,
.htmx-request .htmx-indicator {
    opacity: 1;
}

#search-filter-form.htmx-request ~ #search-results-wrapper {
    opacity: 0.5;
    transition: opacity 120ms ease-in;
    pointer-events: none;
}

.search-spinner {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    border: 2px solid var(--bf-border-strong);
    border-top-color: var(--bf-accent);
    border-radius: 50%;
    animation: bf-spin 650ms linear infinite;
}

@keyframes bf-spin {
    to { transform: rotate(360deg); }
}

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

.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: var(--bs-border-radius) !important;
    border-color: var(--bf-border);
    color: var(--bf-text-secondary);
    font-size: 0.8125rem;
    padding: 0.3rem 0.65rem;
}

.page-item.active .page-link {
    background: var(--bf-accent);
    border-color: var(--bf-accent);
}

.page-item.disabled .page-link {
    color: var(--bf-text-muted);
    background: transparent;
}

/* ---------- filter bar (search page) ---------- */

.filter-bar {
    background: var(--bf-bg-subtle);
    border: 1px solid var(--bf-border);
    border-radius: var(--bs-border-radius);
    padding: 0.85rem 1rem;
}

.filter-bar .form-label {
    margin-bottom: 0.25rem;
}

.filter-bar .form-check {
    font-size: 0.8125rem;
    color: var(--bf-text-secondary);
    margin-bottom: 0.15rem;
}

.filter-bar .form-check-label {
    font-size: 0.8125rem;
}

/* ---------- result summary strip ---------- */

.result-count {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--bf-text);
}

.quota-indicator {
    font-size: 0.75rem;
    color: var(--bf-text-muted);
}

/* ---------- progress / usage bar ---------- */

.progress {
    height: 0.4rem;
    background: var(--bf-bg-subtle);
    border-radius: 2px;
}

.progress-bar {
    background: var(--bf-accent);
}

/* ---------- alerts ---------- */

.alert {
    border-radius: var(--bs-border-radius);
    border: 1px solid transparent;
    font-size: 0.875rem;
}

/* ---------- stat cells (dashboard) ---------- */

.stat-cell {
    border: 1px solid var(--bf-border);
    border-radius: var(--bs-border-radius);
    background: var(--bf-surface);
    padding: 0.9rem 1.1rem;
}

.stat-cell-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bf-text-muted);
    font-weight: 650;
    margin-bottom: 0.3rem;
}

.stat-cell-value {
    font-size: 1.5rem;
    font-weight: 650;
    color: var(--bf-text);
    letter-spacing: -0.01em;
}

/* ---------- pricing / feature matrix (subscriptions page) ---------- */

.plan-current-row {
    background: var(--bf-accent-subtle);
}

.feature-check {
    color: var(--bf-quality-green);
    font-weight: 700;
}

.feature-dash {
    color: var(--bf-text-muted);
}

/* ---------- auth pages (login/register) ---------- */

.auth-card {
    background: var(--bf-surface);
    border: 1px solid var(--bf-border);
    border-radius: var(--bs-border-radius);
    box-shadow: var(--bf-shadow);
    padding: 2rem 2rem 1.75rem;
}

/* ---------- mobile ---------- */

@media (max-width: 767px) {
    .filter-bar {
        padding: 0.75rem;
    }
    .card-body {
        padding: 0.9rem 1rem;
    }
    .auth-card {
        padding: 1.5rem;
    }
}
