/* ==========================================================================
   Company Reminders — design tokens & components
   See STYLE_GUIDE.md for usage rules.
   ========================================================================== */

:root {
    /* Brand */
    --cr-primary: #2563eb;
    --cr-primary-hover: #1d4ed8;
    --cr-primary-soft: #eff6ff;

    /* Neutrals */
    --cr-navy: #0f172a;
    --cr-text: #1e293b;
    --cr-text-muted: #64748b;
    --cr-border: #e2e8f0;
    --cr-surface: #ffffff;
    --cr-bg: #f6f8fb;
    --cr-neutral-soft: #f1f5f9;

    /* Semantic */
    --cr-success: #047857;
    --cr-success-soft: #ecfdf5;
    --cr-warning: #b45309;
    --cr-warning-soft: #fffbeb;
    --cr-danger: #dc2626;
    --cr-danger-soft: #fef2f2;
    --cr-info: #0e7490;
    --cr-info-soft: #ecfeff;

    /* Shape & depth (flat: hairline borders, minimal shadow) */
    --cr-radius: 10px;
    --cr-radius-sm: 8px;
    --cr-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);

    --cr-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    /* Motion */
    --cr-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --cr-speed: 0.15s;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

body {
    font-family: var(--cr-font);
    background-color: var(--cr-bg);
    color: var(--cr-text);
    font-size: 0.9375rem;
    -webkit-font-smoothing: antialiased;
    /* Footer sits at the viewport bottom even when content is short */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--cr-navy);
    font-weight: 600;
    letter-spacing: -0.01em;
}

a {
    color: var(--cr-primary);
    text-decoration: none;
}

a:hover {
    color: var(--cr-primary-hover);
}

.text-muted {
    color: var(--cr-text-muted) !important;
}

/* --------------------------------------------------------------------------
   Top navigation
   -------------------------------------------------------------------------- */

.cr-navbar {
    background: var(--cr-surface);
    border-bottom: 1px solid var(--cr-border);
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
}

.cr-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--cr-navy);
    font-weight: 700;
    font-size: 1rem;
}

.cr-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--cr-primary);
    color: #fff;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.cr-navbar .nav-link {
    color: var(--cr-text-muted);
    font-weight: 500;
    padding: 0.5rem 0.875rem;
    border-radius: var(--cr-radius-sm);
}

.cr-navbar .nav-link:hover {
    color: var(--cr-navy);
    background: var(--cr-neutral-soft);
}

.cr-navbar .nav-link.active {
    color: var(--cr-primary);
    background: var(--cr-primary-soft);
}

/* --------------------------------------------------------------------------
   Page scaffolding
   -------------------------------------------------------------------------- */

.cr-main {
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    width: 100%;
    flex: 1;
}

.cr-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.cr-page-header h1 {
    font-size: 1.375rem;
    margin: 0;
}

.cr-page-header .cr-page-sub {
    color: var(--cr-text-muted);
    font-size: 0.875rem;
    margin: 0.125rem 0 0;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

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

.card-header {
    background: var(--cr-surface);
    border-bottom: 1px solid var(--cr-border);
    border-radius: var(--cr-radius) var(--cr-radius) 0 0 !important;
    padding: 0.875rem 1.125rem;
}

.card-header h2,
.card-header h5 {
    font-size: 0.9375rem;
    margin: 0;
}

.card-header .cr-count {
    color: var(--cr-text-muted);
    font-weight: 500;
}

/* Card-header tabs — mutually exclusive flows within one card.
   Sits where a .card-header would, so it inherits the same hairline and
   radius instead of Bootstrap's default tab chrome. */
.cr-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--cr-surface);
    border-bottom: 1px solid var(--cr-border);
    border-radius: var(--cr-radius) var(--cr-radius) 0 0;
    padding: 0 0.625rem;
}

.cr-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.875rem 0.5rem;
    margin-bottom: -1px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--cr-text-muted);
    background: none;
    transition: color var(--cr-speed) var(--cr-ease),
                border-color var(--cr-speed) var(--cr-ease);
}

.cr-tabs .nav-link:hover {
    color: var(--cr-text);
}

.cr-tabs .nav-link.active {
    color: var(--cr-primary);
    border-bottom-color: var(--cr-primary);
    background: none;
}

.cr-tabs .nav-link:focus-visible {
    outline: 2px solid var(--cr-primary);
    outline-offset: -2px;
}

/* KPI stat cards */
.cr-stat {
    padding: 1rem 1.125rem;
}

.cr-stat .cr-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--cr-text-muted);
    margin-bottom: 0.25rem;
}

.cr-stat .cr-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cr-navy);
    line-height: 1.2;
}

.cr-stat .cr-stat-hint {
    font-size: 0.8125rem;
    color: var(--cr-text-muted);
}

/* Overdue KPI: red accent when the count is non-zero */
.cr-stat-overdue {
    border-color: #fecaca;
    background: var(--cr-danger-soft);
}

.cr-stat-overdue .cr-stat-label,
.cr-stat-overdue .cr-stat-value {
    color: var(--cr-danger);
}

/* --------------------------------------------------------------------------
   Buttons — flat, one primary per view
   -------------------------------------------------------------------------- */

.btn {
    font-weight: 500;
    border-radius: var(--cr-radius-sm);
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem;
}

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

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

.btn-outline-primary {
    color: var(--cr-primary);
    border-color: var(--cr-border);
}

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

.btn-outline-danger {
    color: var(--cr-danger);
    border-color: var(--cr-border);
}

.btn-outline-danger:hover {
    background: var(--cr-danger-soft);
    border-color: var(--cr-danger);
    color: var(--cr-danger);
}

.btn-secondary,
.btn-outline-secondary {
    color: var(--cr-text);
    background: var(--cr-surface);
    border-color: var(--cr-border);
}

.btn-secondary:hover,
.btn-outline-secondary:hover {
    background: var(--cr-neutral-soft);
    border-color: var(--cr-border);
    color: var(--cr-navy);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--cr-navy);
    margin-bottom: 0.375rem;
}

.form-control {
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius-sm);
    padding: 0.5625rem 0.75rem;
    font-size: 0.9375rem;
    color: var(--cr-text);
}

.form-control:focus {
    border-color: var(--cr-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-text {
    color: var(--cr-text-muted);
    font-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
   Status pills — the only colour-coded element
   -------------------------------------------------------------------------- */

.status-pill {
    display: inline-block;
    padding: 0.1875rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.status-pending  { color: var(--cr-warning); background: var(--cr-warning-soft); }
.status-verified { color: var(--cr-success); background: var(--cr-success-soft); }
.status-inactive { color: var(--cr-text-muted); background: var(--cr-neutral-soft); }
.status-overdue  { color: var(--cr-danger); background: var(--cr-danger-soft); }
.status-active   { color: var(--cr-success); background: var(--cr-success-soft); }

/* --------------------------------------------------------------------------
   Entity rows (officers, PSCs, reminders, search results)
   -------------------------------------------------------------------------- */

.cr-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cr-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--cr-border);
}

.cr-row:last-child {
    border-bottom: 0;
}

.cr-row-main {
    min-width: 0;
    flex: 1 1 16rem;
}

.cr-row-title {
    font-weight: 600;
    color: var(--cr-navy);
    font-size: 0.9375rem;
}

.cr-row-meta {
    color: var(--cr-text-muted);
    font-size: 0.8125rem;
    margin-top: 0.125rem;
}

.cr-row-status {
    font-size: 0.8125rem;
    margin-top: 0.375rem;
}

.cr-row-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    align-items: center;
}

/* Empty states */
.cr-empty {
    text-align: center;
    padding: 2.5rem 1.25rem;
    color: var(--cr-text-muted);
}

.cr-empty i {
    font-size: 1.75rem;
    color: #cbd5e1;
    display: block;
    margin-bottom: 0.625rem;
}

.cr-empty p {
    margin-bottom: 1rem;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table {
    font-size: 0.875rem;
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--cr-text-muted);
    border-bottom: 1px solid var(--cr-border);
    padding: 0.625rem 1.125rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1.125rem;
    border-color: var(--cr-border);
    vertical-align: middle;
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

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

.alert-success {
    color: var(--cr-success);
    background: var(--cr-success-soft);
    border-color: #a7f3d0;
}

.alert-danger {
    color: var(--cr-danger);
    background: var(--cr-danger-soft);
    border-color: #fecaca;
}

/* --------------------------------------------------------------------------
   Auth pages (sign in / create account)
   -------------------------------------------------------------------------- */

.cr-auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background: var(--cr-bg);
}

.cr-auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--cr-surface);
    border: 1px solid var(--cr-border);
    border-radius: 14px;
    box-shadow: var(--cr-shadow);
    padding: 2rem;
}

.cr-auth-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    justify-content: center;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 1.0625rem;
    color: var(--cr-navy);
}

.cr-auth-sub {
    text-align: center;
    color: var(--cr-text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.cr-auth-forgot {
    font-size: 0.8125rem;
}

.cr-auth-switch {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: var(--cr-text-muted);
}

/* Sign-in split layout: auth card + product summary, centred as one unit.
   The info panel is desktop-only; on smaller screens the card stands alone. */
.cr-auth-split {
    width: 100%;
    max-width: 1000px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4.5rem;
}

.cr-auth-split .cr-auth-card {
    flex: 0 1 400px;
}

.cr-auth-info {
    flex: 0 1 480px;
    min-width: 0;
}

.cr-auth-info-title {
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.875rem;
}

.cr-auth-info-lead {
    color: var(--cr-text-muted);
    line-height: 1.6;
    margin-bottom: 1.75rem;
}

.cr-auth-feature {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
}

.cr-auth-feature + .cr-auth-feature {
    margin-top: 1.25rem;
}

.cr-auth-feature-icon {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--cr-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.cr-auth-feature h3 {
    font-size: 0.9375rem;
    margin-bottom: 0.125rem;
}

.cr-auth-feature p {
    color: var(--cr-text-muted);
    font-size: 0.875rem;
    margin: 0;
}

@media (max-width: 991.98px) {
    .cr-auth-info {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   Account settings
   -------------------------------------------------------------------------- */

.cr-danger-card {
    border-color: #fecaca;
}

.cr-danger-card .card-header {
    border-bottom-color: #fecaca;
}

.cr-account-meta {
    font-size: 0.8125rem;
    margin-top: 1rem;
    text-align: right;
}

/* --------------------------------------------------------------------------
   Footer / version stamp
   -------------------------------------------------------------------------- */

footer.cr-footer {
    width: 100%;
    background: var(--cr-surface);
    border-top: 1px solid var(--cr-border);
    text-align: center;
    color: var(--cr-text-muted);
    font-size: 0.75rem;
    line-height: 1.7;
    margin: 0;
    padding: 0;
}

.cr-footer-inner {
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.25rem 1rem;
}

.cr-footer-text {
    font-weight: 500;
    color: var(--cr-text);
    margin: 0;
}

.cr-footer-more a {
    color: #e51463;
    text-decoration: none;
}

.cr-footer-more a:hover {
    color: #e51463;
    text-decoration: underline;
}

.cr-footer-policies {
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.cr-footer-policies a {
    color: var(--cr-text-muted);
    text-decoration: none;
    transition: color var(--cr-speed) var(--cr-ease);
}

.cr-footer-policies a:hover {
    color: var(--cr-primary);
}

.cr-footer-version {
    font-variant-numeric: tabular-nums;
    margin: 0;
}

/* On auth pages, pin the footer to the bottom; spacing comes from
   .cr-footer-inner so it matches the logged-in pages exactly */
footer.cr-footer.cr-footer-auth {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
}

/* --------------------------------------------------------------------------
   Motion — micro animations
   Fast (150ms) and subtle, in keeping with the flat design. Everything here
   is decorative: prefers-reduced-motion collapses it all (see bottom).
   -------------------------------------------------------------------------- */

@keyframes cr-fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@keyframes cr-pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.25); }
    100% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

@keyframes cr-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

/* Content enters with a soft fade-up, gently staggered */
.cr-main > *,
.cr-auth-card {
    animation: cr-fade-up 0.35s var(--cr-ease) both;
}

.cr-main > *:nth-child(2) { animation-delay: 0.04s; }
.cr-main > *:nth-child(3) { animation-delay: 0.08s; }
.cr-main > *:nth-child(4) { animation-delay: 0.12s; }
.cr-main > *:nth-child(5) { animation-delay: 0.16s; }
.cr-main > *:nth-child(n+6) { animation-delay: 0.2s; }

/* Interactive feedback */
a {
    transition: color var(--cr-speed) var(--cr-ease);
}

.btn {
    transition: background-color var(--cr-speed) var(--cr-ease),
                border-color var(--cr-speed) var(--cr-ease),
                color var(--cr-speed) var(--cr-ease),
                box-shadow var(--cr-speed) var(--cr-ease),
                transform 0.1s var(--cr-ease);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.cr-navbar .nav-link,
.dropdown-item {
    transition: background-color var(--cr-speed) var(--cr-ease),
                color var(--cr-speed) var(--cr-ease);
}

.form-control {
    transition: border-color var(--cr-speed) var(--cr-ease),
                box-shadow var(--cr-speed) var(--cr-ease);
}

/* List rows and table rows tint on hover so scanning has a focal point */
.cr-row {
    transition: background-color var(--cr-speed) var(--cr-ease);
}

.cr-row:hover {
    background-color: rgba(241, 245, 249, 0.55);
}

.table tbody tr td {
    transition: background-color var(--cr-speed) var(--cr-ease);
}

.table tbody tr:hover td {
    background-color: rgba(241, 245, 249, 0.55);
}

/* Dropdown menu eases in */
.dropdown-menu.show {
    animation: cr-fade-up 0.18s var(--cr-ease) both;
}

/* Overdue KPI pulses a few times on load to draw the eye, then rests */
.cr-stat-overdue {
    animation: cr-pulse-ring 1.6s var(--cr-ease) 0.6s 3;
}

/* Empty-state icons drift gently */
.cr-empty i {
    animation: cr-float 3.5s ease-in-out infinite;
}

/* Submitting form: busy button (spinner icon swapped in by footer JS) */
.cr-btn-busy {
    pointer-events: none;
    opacity: 0.75;
}

/* Accessibility: collapse all decorative motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal-content {
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius);
}

.modal-header,
.modal-footer {
    border-color: var(--cr-border);
}

.modal-title {
    font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Impersonation banner (admin viewing as another user)
   -------------------------------------------------------------------------- */

.cr-impersonation-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.875rem;
    padding: 0.625rem 1rem;
    background: var(--cr-warning-soft);
    color: var(--cr-warning);
    border-bottom: 1px solid #fcd9a5;
    font-size: 0.875rem;
    font-weight: 500;
}

.cr-impersonation-bar .cr-impersonation-who strong {
    color: var(--cr-navy);
}

.cr-impersonation-bar form {
    margin: 0;
}

/* --------------------------------------------------------------------------
   Admin table row actions (compact icon buttons)
   -------------------------------------------------------------------------- */

.cr-table-actions {
    display: flex;
    gap: 0.375rem;
    align-items: center;
    justify-content: flex-end;
}

.cr-table-actions form {
    margin: 0;
    display: inline-flex;
}

.cr-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: var(--cr-radius-sm);
    line-height: 1;
}

.cr-self-badge {
    font-size: 0.75rem;
    color: var(--cr-text-muted);
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Long-form prose (policy pages)
   -------------------------------------------------------------------------- */

.cr-prose {
    padding: 1.5rem 1.75rem 1.75rem;
    color: var(--cr-text);
    max-width: 46rem;
}

.cr-prose > *:first-child {
    margin-top: 0;
}

.cr-prose h2 {
    font-size: 1.0625rem;
    margin: 1.75rem 0 0.625rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--cr-border);
}

.cr-prose > h2:first-of-type {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}

.cr-prose h3 {
    font-size: 0.9375rem;
    margin: 1.25rem 0 0.5rem;
}

.cr-prose p,
.cr-prose li {
    line-height: 1.65;
}

.cr-prose ul {
    padding-left: 1.25rem;
    margin-bottom: 1rem;
}

.cr-prose li {
    margin-bottom: 0.375rem;
}

.cr-prose .cr-prose-lead {
    color: var(--cr-text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.cr-prose .cr-contact-box {
    background: var(--cr-neutral-soft);
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius-sm);
    padding: 1rem 1.125rem;
}

.cr-prose .cr-contact-box p {
    margin-bottom: 0.375rem;
}

.cr-prose .cr-contact-box p:last-child {
    margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 575.98px) {
    .cr-main {
        padding: 1rem 0.75rem 2.5rem;
    }

    .cr-prose {
        padding: 1.25rem 1.125rem 1.5rem;
    }

    .cr-page-header .btn {
        width: 100%;
    }

    .cr-row-actions {
        width: 100%;
    }

    .cr-row-actions .btn {
        flex: 1;
    }

    .cr-row-actions form {
        flex: 1;
        display: flex;
    }

    .cr-row-actions form .btn {
        flex: 1;
    }

    .cr-auth-card {
        padding: 1.5rem;
    }
}
