/**
 * DocuNest - UI refinement layer
 * Loaded last on staff, resident and public pages. It does not restyle the system; it fixes
 * what an audit of the rendered pages found:
 *   1. readability   nothing a person reads is smaller than 13px (theme minimum, --fs-xs)
 *   2. contrast      every text/background pair meets WCAG AA (4.5:1, 3:1 for large text)
 *   3. buttons       one solid main action per toolbar, the rest a clearly visible neutral
 *                    outline; equal heights; comfortable tap targets on phones
 *   4. consistency   no wrapped labels, tabs or names where a single line fits
 * Colours stay the navy and orange of the barangay identity.
 */

/* ── 1. Readability ─────────────────────────────────────────── */
body { text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Record numbers (RES-…, CR-…, HH-…): readable size and full contrast */
code, .table code {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-heading, #1E293B);
  letter-spacing: .01em;
  padding: 2px 7px;
}

/* Secondary lines inside tables and lists (purok under a name, dates, meta) */
.table td .text-muted, .table td small, .table td .small,
.detail-grid dt, .activity-content .activity-meta, .mini-timeline small,
.notice-meta, .notice-alert small, .stat-card .stat-label, .stat-card .stat-trend,
.quick-action-btn .qa-text small, .gis-legend, .announcement-card .ann-meta,
.rd-record dt, .rd-progress li, .rd-stats .pt-stat-lbl,
.type-desc, .type-fee, .ref-label, .track-steps .t-sub, .panel-footer, .vr-foot,
.form-card .section-title small, .login-footer, .feature-list small, .privacy-note {
  font-size: var(--fs-xs, .8125rem);
}
.form-text, .card-subtitle, .dataTables_info { font-size: var(--fs-xs, .8125rem); }
.notice-excerpt { font-size: .84rem; }

/* Placeholders: 4.8:1 on white (Bootstrap's default is fainter) */
.form-control::placeholder { color: #64748B; opacity: 1; }

/* ── 2. Contrast ────────────────────────────────────────────── */
/* Date on the dark navy dashboard banner: light orange keeps the accent at 7:1 */
html[data-theme="light"] .dash-hero-date { color: #FDBA74; }
/* Resident portal date chips: white on a deeper orange (5.2:1 instead of 2.8:1) */
.rd-date { background: #C2410C; font-size: .8rem; }
.rd-date b { font-size: 1.15rem; }
/* Bootstrap "subtle" badges: their default text colours fall under 4.5:1 */
.badge.bg-secondary-subtle, .badge.bg-light { color: #334155 !important; }
.badge.bg-info-subtle      { color: #055160 !important; }
.badge.bg-warning-subtle   { color: #664D03 !important; }
.badge.bg-success-subtle   { color: #0A3622 !important; }
.badge.bg-danger-subtle    { color: #58151C !important; }
.badge.bg-primary-subtle   { color: #1E3A8A !important; }
/* Warning and info badges with white text are unreadable: use dark text */
.badge.bg-warning, .badge.bg-info { color: #1E293B !important; }

/* ── 3. Buttons ─────────────────────────────────────────────── */
.btn { font-weight: 600; }
.btn-sm { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.btn-sm > i:first-child { margin-right: .35rem; }
.btn-sm > i.me-1:first-child, .btn-sm > i.me-2:first-child { margin-right: .35rem !important; }
.btn-sm.btn-icon > i:first-child, .row-actions .btn > i:first-child { margin-right: 0; }

/* The neutral outline used for every secondary action: visible border, solid surface */
.btn-outline-secondary {
  --bs-btn-color: #334155;
  --bs-btn-bg: #FFFFFF;
  --bs-btn-border-color: #94A3B8;
  --bs-btn-hover-color: #0F172A;
  --bs-btn-hover-bg: #F1F5F9;
  --bs-btn-hover-border-color: #64748B;
  --bs-btn-active-color: #0F172A;
  --bs-btn-active-bg: #E2E8F0;
  --bs-btn-active-border-color: #475569;
  background-color: var(--bs-btn-bg);
}
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }

/* Icon-only row actions: never smaller than 34px, always a visible border */
.row-actions .btn, .btn-icon { min-width: 34px; min-height: 34px; }

/* ── 4. Layout consistency ──────────────────────────────────── */
/* Page header toolbars wrap as a group, aligned right, with even spacing */
.page-head > .d-flex, .page-head > div:last-child:not(:first-child) { flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }

/* Report tabs: compact pills that fit one row on a laptop and wrap evenly on small screens */
.report-tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.report-tabs .btn { white-space: nowrap; padding: .3rem .7rem; font-size: .84rem; }

/* Section headings and card headers share one weight and colour */
.card-header { color: var(--text-heading, #1E293B); }
.form-label { color: var(--text-heading, #1E293B); }

/* ── 5. Phones ──────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .page-head { gap: .75rem; }
  .page-head > .d-flex, .page-head > div:last-child:not(:first-child) { justify-content: flex-start; }
  .page-head .btn, .form-actions .btn { min-height: 42px; }            /* thumb-sized */
  .row-actions .btn, .btn-icon { min-width: 40px; min-height: 40px; }
  .form-control, .form-select { font-size: 16px; }                    /* no zoom-in on focus (iOS) */
}

/* ── 6. Motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  code, .table code { background: none; padding: 0; }
}
