/* App-level overrides layered on top of adminlte.css. Do not edit adminlte.css directly. */

:root {
    /* User-selectable brand color (Settings > Theme Color picker), drives buttons/
       active nav/links. Default matches the approved VMS mockup primary. */
    --app-primary: #2F54EB;
    --app-primary-rgb: 47, 84, 235;

    /* VMS design tokens (fixed, not user-selectable) — structure + status colors
       from the approved mockups. Mirrors fms_mobile/lib/core/theme/app_theme.dart's
       AppColors so the web admin and mobile app read as the same product. */
    --navy-900: #16224A;
    --navy-800: #1E2B5E;
    --success: #16A34A;
    --success-bg: #DCFCE7;
    --danger: #DC2626;
    --danger-bg: #FEE2E2;
    --warning: #F59E0B;
    --purple: #7C3AED;
    --vms-bg: #F4F6FA;
    --vms-border: #E5E7EB;
    --vms-text: #111827;
    --vms-text-muted: #6B7280;
    --r-card: 12px;
    --r-btn: 8px;
    --r-input: 8px;
    --r-pill: 999px;
}

/* Softer status colors for widgets/badges, used instead of AdminLTE's vivid defaults */
.small-box.text-bg-success, .small-box.bg-success { background-color: #4c8c6e !important; }
.small-box.text-bg-warning, .small-box.bg-warning { background-color: #c99a4b !important; color: #fff !important; }
.small-box.text-bg-danger, .small-box.bg-danger { background-color: #b95c5c !important; }
.small-box.text-bg-secondary, .small-box.bg-secondary { background-color: #6b7785 !important; }

body {
    font-family: var(--app-font, "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

/* Distinct page background so white cards visibly stand out instead of blending in */
.app-content {
    background-color: #eef1f6;
    min-height: calc(100vh - 120px);
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* -- Theme colors -- */
.btn-primary {
    background-color: var(--app-primary) !important;
    border-color: var(--app-primary) !important;
}

.btn-outline-primary {
    color: var(--app-primary) !important;
    border-color: var(--app-primary) !important;
}

.btn-outline-primary:hover {
    background-color: var(--app-primary) !important;
    color: #fff !important;
}

.text-bg-primary, .bg-primary {
    background-color: var(--app-primary) !important;
}

a, .small-box-footer {
    color: var(--app-primary);
}

.nav-sidebar > .nav-item > .nav-link.active {
    background-color: var(--app-primary) !important;
}

.badge.text-bg-primary {
    background-color: var(--app-primary) !important;
}

.card-primary.card-outline {
    border-top-color: var(--app-primary) !important;
}

/* -- Theme switcher swatches -- */
.theme-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-block;
    cursor: pointer;
    border: 2px solid transparent;
}

.theme-swatch.active {
    border-color: #212529;
}

/* -- App footer -- */
.app-footer {
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: #6c757d;
}

/* -- DataTables x AdminLTE spacing -- */
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length {
    margin-bottom: 0.5rem;
}

table.dataTable {
    width: 100% !important;
}

/* -- Modern colored modals: left accent banner + themed header, follows global theme color -- */
.modal-accent .modal-content {
    border: none;
    border-left: 6px solid var(--app-primary);
    border-radius: 0.5rem;
    overflow: hidden;
}

.modal-accent .modal-header {
    background-color: var(--app-primary);
    color: #fff;
    border-bottom: none;
}

.modal-accent .modal-header .modal-title,
.modal-accent .modal-header small {
    color: #fff;
}

.modal-accent .modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.modal-accent .modal-body {
    background-color: #f8f9fb;
}

.modal-accent .modal-footer {
    background-color: #f8f9fb;
    border-top: 1px solid #e9ecef;
}

/* -- Checklist item drag-to-reorder -- */
.checklist-row {
    cursor: grab;
    transition: box-shadow 0.15s ease;
}

.checklist-row.dragging {
    opacity: 0.5;
}

.checklist-row .drag-handle {
    cursor: grab;
    color: #adb5bd;
}

/* Export/CSV/Excel buttons: solid theme-colored fill so contrast never depends on
   inherited/dark-mode text-color variables (previous outline style could render
   as same-color-as-background in some contexts, making them invisible until :hover). */
.dt-buttons .dt-button,
.dt-buttons .dt-button.btn {
    color: #fff !important;
    background-color: var(--app-primary) !important;
    border: 1px solid var(--app-primary) !important;
    opacity: 1 !important;
    font-weight: 500;
}

/* -- Responsive button groups --
   Bootstrap's native .btn-group is a non-wrapping inline-flex row, which overflows
   off-screen on narrow phones once there are 3+ items. Use this class instead of
   (or alongside) .btn-group wherever a row of filter/toggle buttons needs to wrap
   onto multiple lines on small viewports instead of clipping. */
.btn-group-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-group-wrap > .btn,
.btn-group-wrap > a.btn {
    flex: 1 1 auto;
    border-radius: 6px !important;
    white-space: nowrap;
}

/* -- Segmented icon buttons (e.g. Visitor Type picker) --
   Filled background by default (not transparent outline) so it always reads as a
   clickable button, with a theme-colored fill only once selected. Text auto-shrinks
   via clamp() so longer labels (e.g. "Contractor") never wrap or spill outside. */
.segmented-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 10px 2px;
    border: 1px solid #d7dce2;
    border-radius: 8px;
    background-color: #f4f6f8;
    color: #445;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

.segmented-btn i {
    font-size: 1.3rem;
    line-height: 1;
}

.segmented-btn span {
    font-size: clamp(11px, 3vw, 14px);
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.segmented-btn:hover {
    background-color: #e9edf1;
    border-color: var(--app-primary);
}

.segmented-btn.active {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
    color: #fff;
}

.dt-buttons .dt-button:hover {
    filter: brightness(1.15);
}

.dt-buttons .dt-button i,
.dt-buttons .dt-button i.bi {
    color: #fff !important;
}

/* -- Colored header bar -- */
.app-header {
    background-color: var(--app-primary) !important;
    border-bottom: none !important;
}

.app-header .nav-link,
.app-header .nav-link i {
    color: rgba(255, 255, 255, 0.92) !important;
}

.app-header .nav-link:hover {
    color: #fff !important;
}

.app-header .text-muted {
    color: rgba(255, 255, 255, 0.85) !important;
}

.app-header .btn-outline-secondary {
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
}

.app-header .btn-outline-secondary:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
}

/* -- Modern card / row shading -- */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    border-radius: 0.5rem;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-weight: 600;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(0, 0, 0, 0.015);
}

.table > tbody > tr:hover > * {
    background-color: rgba(var(--app-primary-rgb), 0.06);
}

.app-content-header {
    background-color: transparent;
}

/* -- Subtle interaction polish -- */
.small-box {
    border-radius: 0.5rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.small-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

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

.card-title {
    display: flex;
    align-items: center;
}

.app-content-header h3 {
    font-weight: 700;
}

/* -- Standardized button shape/spacing across the whole app -- */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn i.bi {
    line-height: 1;
}

.badge {
    font-weight: 600;
    padding: 0.4em 0.75em;
    border-radius: var(--r-pill, 999px);
}

/* VMS status badges: pill, tinted background + matching text (not solid fill),
   matching the approved mockups' IN/ACTIVE (success) and OUT/EXPIRED (danger). */
.badge.text-bg-success {
    background-color: var(--success-bg) !important;
    color: var(--success) !important;
}

.badge.text-bg-danger {
    background-color: var(--danger-bg) !important;
    color: var(--danger) !important;
}

/* -- Banner: colored gradient accent so it reads as a distinct header block -- */
.page-banner {
    background: linear-gradient(135deg, var(--app-primary), rgba(var(--app-primary-rgb), 0.75));
    color: #fff;
    border-radius: 0.5rem;
}

.page-banner .text-muted {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* -- Filter card: tinted header to visually separate from the listing below -- */
.filter-card > .card-header {
    background-color: rgba(var(--app-primary-rgb), 0.06);
    border-bottom: 1px solid rgba(var(--app-primary-rgb), 0.12);
}

/* -- Modal headers: colored to match the app header/banner instead of default white,
   so every modal across the app reads as belonging to the same system -- */
.modal-header {
    background-color: var(--app-primary);
    color: #fff;
    border-bottom: none;
    border-top-left-radius: calc(0.5rem - 1px);
    border-top-right-radius: calc(0.5rem - 1px);
}

.modal-header .modal-title {
    color: #fff;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.85;
}

.modal-header .btn-close:hover {
    opacity: 1;
}

/* Shared lifecycle stepper (status_stepper() in helpers.php) — standardized across
   Visitors (Register -> Check In -> Check Out), Patrol (Route -> Patrolling ->
   Completed), and Cleaning (Scan-In -> Checklist -> Checked Out) list views.
   Sits directly under the status badge, or stands alone as the status column. */
.status-steps {
    display: flex;
    align-items: center;
    white-space: nowrap;
    margin-top: 6px;
}

.status-step {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    color: #adb5bd;
    line-height: 1;
}

.status-step i {
    font-size: 11px;
}

.status-step-label {
    display: inline-block;
}

.status-step.done {
    color: #198754;
}

.status-step.current {
    color: var(--app-primary);
}

.status-step.missed {
    color: #dc3545;
}

.status-step-line {
    width: 12px;
    height: 2px;
    background-color: #dee2e6;
    margin: 0 4px;
    flex-shrink: 0;
}

.status-step-line.done {
    background-color: #198754;
}

/* -- Standardized avatar sizes — replaces one-off inline style="width:Npx..." on
   visitor/visit photo thumbnails scattered across pages. Use instead of inline styles. -- */
.avatar-sm, .avatar-md, .avatar-lg {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--vms-bg, #F4F6FA);
}

.avatar-sm { width: 36px; height: 36px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 120px; height: 120px; font-size: 3rem; }

/* -- Standardized rectangular evidence/reference photo thumbnails (incident,
   cleaning issue, checklist-item, location photos) — replaces one-off inline
   style="width:Npx;height:Npx;object-fit:cover;border-radius:Npx" scattered
   across list tables. Rounded corners, not circular — see .avatar-* above for
   person photos. Pair with .cursor-zoom on lightbox-trigger thumbnails. -- */
.thumb-40, .thumb-48, .thumb-56 {
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}
.thumb-40 { width: 40px; height: 40px; }
.thumb-48 { width: 48px; height: 48px; }
.thumb-56 { width: 56px; height: 56px; border-radius: 6px; }
.cursor-zoom { cursor: zoom-in; }

/* -- Standardized icon-only action buttons (table row actions: view/check-out/more).
   Circular, subtle gray, consistent size — use instead of text-label btn-sm buttons
   in dense table Action columns. -- */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--vms-border, #E5E7EB);
    background-color: var(--vms-bg, #F4F6FA);
    color: var(--vms-text-muted, #6B7280);
}

.btn-icon:hover {
    background-color: rgba(var(--app-primary-rgb), 0.1);
    color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-icon.btn-icon-danger:hover {
    background-color: var(--danger-bg, #FEE2E2);
    color: var(--danger, #DC2626);
    border-color: var(--danger, #DC2626);
}

/* -- Flat toolbar card: search + filters + primary action in one row, no card-header/
   "Filters" label, no tinted background — the standardized replacement for the older
   .filter-card > .card-header tint pattern. See CLAUDE.md "Toolbar pattern". -- */
.toolbar-card .card-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}

.toolbar-card .toolbar-search {
    flex: 1 1 240px;
    min-width: 200px;
}

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

/* Pages that put a custom "Export" trigger button in the toolbar instead of using
   DataTables' auto-rendered CSV/Excel button row: hide the auto-rendered row (the
   table still has working Buttons extension underneath, just triggered manually). */
.dt-buttons-in-toolbar .dt-buttons {
    display: none;
}

/* -- Rich "info cell": circular avatar + 2-3 stacked lines of detail, replacing a
   row of separate Name/Type/Phone/Company/Vehicle columns with one denser, more
   scannable cell. Used in checkin/index.php and visitors/index.php table rows. -- */
.cell-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cell-info .avatar-sm i.bi {
    font-size: 16px;
}

.cell-info-lines {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cell-info-name {
    font-weight: 600;
    color: var(--vms-text, #111827);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cell-info-line {
    font-size: 12px;
    color: var(--vms-text-muted, #6B7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* -- Comfortable (taller) table rows for the richer info-cell rows above. -- */
.table-comfortable > :not(caption) > * > td {
    padding-top: 12px;
    padding-bottom: 12px;
    vertical-align: middle;
}

/* -- Login screen brand header: centered icon tile + title/subtitle, mirrors
   the mobile app's login/splash screens (fms_mobile's icon3_launcher.png,
   navy rounded-square tile) so both platforms read as the same product. -- */
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 1.5rem;
}

.login-brand-icon {
    width: 96px;
    height: 96px;
    border-radius: 22px;
    box-shadow: 0 12px 28px rgba(22, 34, 74, 0.22);
    object-fit: cover;
    margin-bottom: 12px;
}

.login-brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--vms-text, #111827);
    text-align: center;
}

.login-brand-subtitle {
    font-size: 0.8rem;
    color: var(--vms-text-muted, #6B7280);
    text-align: center;
}

/* -- Chat (Phase 6) — adapted from AdminLTE-master/dist/pages/chat.html's static
   demo, ported into app.css per the "no inline styles" convention. Uses Bootstrap
   CSS vars (--bs-*) like the rest of this app's plugin-skinning does. -- */
.chat-app {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: calc(100vh - 220px);
    min-height: 28rem;
    border-radius: var(--r-card, 12px);
    overflow: hidden;
    background: var(--bs-body-bg);
    border: 1px solid var(--vms-border, #E5E7EB);
}
@media (max-width: 768px) {
    .chat-app { grid-template-columns: 1fr; }
    .chat-app.chat-mobile-showing-conversation .chat-contacts { display: none; }
    .chat-app:not(.chat-mobile-showing-conversation) .chat-conversation { display: none; }
}
.chat-contacts {
    background: var(--bs-tertiary-bg);
    border-right: 1px solid var(--vms-border, #E5E7EB);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-contact {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border: none;
    width: 100%;
    background: none;
    border-bottom: 1px solid var(--vms-border, #E5E7EB);
    text-decoration: none;
    color: inherit;
    text-align: left;
}
.chat-contact:hover { background: var(--bs-body-bg); }
.chat-contact.active {
    background: var(--bs-body-bg);
    border-left: 3px solid var(--app-primary, #2F54EB);
    padding-left: calc(1rem - 3px);
}
.chat-avatar {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    background: var(--app-primary, #2F54EB);
    color: #fff;
}
.chat-conversation {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--vms-border, #E5E7EB);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bs-tertiary-bg);
}
.chat-message {
    display: flex;
    margin-bottom: 0.75rem;
}
.chat-message.me { justify-content: flex-end; }
.chat-bubble {
    max-width: 70%;
    padding: 0.5rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
}
.chat-message.them .chat-bubble {
    background: var(--bs-body-bg);
    border: 1px solid var(--vms-border, #E5E7EB);
    border-bottom-left-radius: 0.25rem;
}
.chat-message.me .chat-bubble {
    background: var(--app-primary, #2F54EB);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}
.chat-time {
    font-size: 0.7rem;
    opacity: 0.7;
    display: block;
    margin-top: 0.15rem;
}
.chat-composer {
    padding: 0.75rem;
    border-top: 1px solid var(--vms-border, #E5E7EB);
}

/* ---- Public pages (landing, login, visitor register, get-started) ----
   Shared corporate chrome: a slim brand nav + muted footer wrapped around
   every public-facing page (see partials/public_nav.php and public_footer.php),
   plus an elevated card treatment so forms read as premium/on-brand rather
   than AdminLTE's default flat login-box styling. */
.public-page-body {
    background: var(--vms-bg);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.public-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1120px;
    width: 100%;
    margin: 0 auto;
    padding: 22px 24px;
}
.public-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--navy-900);
    text-decoration: none;
}
.public-nav-brand img {
    max-height: 34px;
    width: auto;
}
.public-nav-brand img.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
}
.public-nav-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--vms-text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.public-nav-link:hover {
    color: var(--app-primary);
}
.public-main {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
}
.public-footer {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 24px 40px;
    color: var(--vms-text-muted);
    font-size: 12px;
    text-align: center;
    width: 100%;
}

/* Elevated card treatment for forms on public pages — a thin navy accent
   bar on top, softer shadow, more generous padding than AdminLTE's default
   .card, so /login, /register, /get-started read as one polished product
   rather than a bare admin form. */
.public-page-body .card,
.login-page .card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(16, 24, 52, .04), 0 12px 32px -12px rgba(16, 34, 74, .18);
    overflow: hidden;
}
.public-page-body .card::before,
.login-page .card::before {
    content: "";
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--navy-900), var(--app-primary));
}
.public-page-body .card .card-header {
    background: #fff;
    border-bottom: 1px solid var(--vms-border);
    padding: 20px 28px;
}
.public-page-body .card .card-header .card-title {
    font-weight: 700;
    color: var(--vms-text);
}
.public-page-body .card .card-body {
    padding: 28px;
}
.login-page.public-page-body .login-card-body {
    padding: 32px 28px;
}
.login-page .login-box-msg {
    color: var(--vms-text-muted);
    font-size: 13.5px;
}
