/* NIP Provincial Subsidy Office — theme (colours taken from the New Ireland Government crest) */
:root {
  --nip-navy: #1d2f6f;
  --nip-navy-2: #2b4192;
  --nip-blue: #5b6aae;
  --nip-yellow: #f2d82f;
  --nip-yellow-soft: #fdf6c9;
  --nip-ink: #1d2433;
  --nip-muted: #5d6576;
  --nip-bg: #f4f6fb;
  --bs-primary: #2b4192;
  --bs-primary-rgb: 43, 65, 146;
  --bs-link-color: #2b4192;
  --bs-link-color-rgb: 43, 65, 146;
  --bs-link-hover-color: #1d2f6f;
  --bs-body-color: #1d2433;
  --bs-body-bg: #f4f6fb;
}

body { background: var(--nip-bg); color: var(--nip-ink); }

.btn-primary {
  --bs-btn-bg: var(--nip-navy-2); --bs-btn-border-color: var(--nip-navy-2);
  --bs-btn-hover-bg: var(--nip-navy); --bs-btn-hover-border-color: var(--nip-navy);
  --bs-btn-active-bg: var(--nip-navy); --bs-btn-active-border-color: var(--nip-navy);
  --bs-btn-disabled-bg: var(--nip-blue); --bs-btn-disabled-border-color: var(--nip-blue);
}
.btn-outline-primary {
  --bs-btn-color: var(--nip-navy-2); --bs-btn-border-color: var(--nip-navy-2);
  --bs-btn-hover-bg: var(--nip-navy-2); --bs-btn-hover-border-color: var(--nip-navy-2);
  --bs-btn-active-bg: var(--nip-navy); --bs-btn-active-border-color: var(--nip-navy);
}
.text-bg-primary { background-color: var(--nip-navy-2) !important; }

/* Header / footer */
.nip-header { background: linear-gradient(90deg, var(--nip-navy) 0%, var(--nip-navy-2) 100%); border-bottom: 4px solid var(--nip-yellow); }
.nip-header .navbar-brand img { filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.nip-header .brand-sub { color: var(--nip-yellow); font-size: .75rem; letter-spacing: .02em; }
.nip-header .nav-link { color: rgba(255,255,255,.85); }
.nip-header .nav-link:hover, .nip-header .nav-link.active { color: #fff; }
.nip-header .nav-link.active { box-shadow: inset 0 -3px 0 var(--nip-yellow); }
.nip-footer { background: var(--nip-navy); color: rgba(255,255,255,.75); }

/* Cards & headings */
.card { border: 1px solid #e1e5ef; border-radius: .75rem; box-shadow: 0 1px 2px rgba(29,47,111,.04); }
.card-header { background: #fff; border-bottom: 1px solid #e9ecf3; font-weight: 600; border-radius: .75rem .75rem 0 0 !important; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; font-weight: 700; color: var(--nip-navy); }
.page-head .sub { color: var(--nip-muted); margin: .15rem 0 0; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--nip-muted); font-weight: 700; margin-bottom: .5rem; }

/* Hero (home page) */
.hero { background: linear-gradient(135deg, var(--nip-navy) 0%, var(--nip-navy-2) 60%, var(--nip-blue) 100%); color: #fff; border-radius: 1rem; padding: 2.5rem 2rem; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(242,216,47,.12); }
.hero h1 { font-weight: 800; font-size: clamp(1.6rem, 3vw, 2.3rem); }
.hero .lead { color: rgba(255,255,255,.85); }
.hero .crest { width: 120px; height: auto; }
.date-chip { background: var(--nip-yellow-soft); border: 1px solid #efe08b; border-radius: .6rem; padding: .75rem 1rem; }

/* Stat tiles */
.stat { background: #fff; border: 1px solid #e1e5ef; border-radius: .75rem; padding: 1rem 1.1rem; height: 100%; }
.stat .num { font-size: 1.6rem; font-weight: 700; color: var(--nip-navy); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--nip-muted); font-size: .85rem; }
.stat.accent { border-left: 4px solid var(--nip-yellow); }
a.stat { text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--nip-blue); }

/* Form wizard */
.wizard-steps { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.wizard-steps a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border-radius: 2rem; border: 1px solid #d6dbe8; background: #fff; text-decoration: none; color: var(--nip-ink); font-size: .9rem; }
.wizard-steps a .n { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: #e7eaf3; font-size: .75rem; font-weight: 700; }
.wizard-steps a.active { background: var(--nip-navy-2); border-color: var(--nip-navy-2); color: #fff; }
.wizard-steps a.active .n { background: var(--nip-yellow); color: var(--nip-navy); }
.wizard-steps a.done .n { background: #198754; color: #fff; }

.q-row { border-bottom: 1px solid #eef0f6; padding: .9rem 0; }
.q-row:last-child { border-bottom: 0; }
.q-num { font-weight: 700; color: var(--nip-navy-2); margin-right: .25rem; }
.q-help { color: var(--nip-muted); font-size: .85rem; }
.btn-check + .btn { min-width: 4.2rem; }
.form-label { font-weight: 500; }
.req::after { content: " *"; color: #b02a37; }

/* Eligibility checks */
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { display: flex; gap: .65rem; padding: .6rem 0; border-bottom: 1px solid #eef0f6; }
.check-list li:last-child { border-bottom: 0; }
.check-list .ic { font-size: 1.15rem; line-height: 1.2; flex: 0 0 auto; }
.check-list .pass .ic { color: #198754; }
.check-list .review .ic { color: #c98a00; }
.check-list .fail .ic { color: #b02a37; }
.check-list .ref { font-size: .75rem; color: var(--nip-muted); }

/* Timeline */
.timeline { list-style: none; padding: 0 0 0 1.25rem; margin: 0; border-left: 2px solid #dfe3ee; }
.timeline li { position: relative; padding: 0 0 1rem .75rem; }
.timeline li::before { content: ""; position: absolute; left: -1.62rem; top: .3rem; width: .8rem; height: .8rem; border-radius: 50%; background: var(--nip-blue); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--nip-blue); }
.timeline .when { font-size: .8rem; color: var(--nip-muted); }

/* Progress tracker */
.tracker { display: flex; gap: .25rem; margin: .5rem 0 1rem; }
.tracker .step { flex: 1; text-align: center; font-size: .72rem; color: var(--nip-muted); }
.tracker .bar { height: .4rem; border-radius: 1rem; background: #dfe3ee; margin-bottom: .3rem; }
.tracker .step.done .bar { background: #198754; }
.tracker .step.current .bar { background: var(--nip-yellow); }
.tracker .step.current { color: var(--nip-ink); font-weight: 600; }

/* Tables */
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--nip-muted); font-weight: 600; background: #f8f9fc; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-hover tbody tr { cursor: default; }
.dl-grid { display: grid; grid-template-columns: minmax(140px, 38%) 1fr; gap: .35rem 1rem; margin: 0; }
.dl-grid dt { color: var(--nip-muted); font-weight: 500; }
.dl-grid dd { margin: 0; word-break: break-word; }

.doc-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid #eef0f6; flex-wrap: wrap; }
.doc-row:last-child { border-bottom: 0; }

.bar-h { height: .55rem; background: #e7eaf3; border-radius: 1rem; overflow: hidden; }
.bar-h > span { display: block; height: 100%; background: var(--nip-navy-2); border-radius: 1rem; }

.badge { font-weight: 600; }
.nowrap { white-space: nowrap; }

@media (max-width: 575.98px) {
  .dl-grid { grid-template-columns: 1fr; }
  .dl-grid dt { margin-top: .4rem; }
  .hero { padding: 1.75rem 1.25rem; }
}

/* Print */
@media print {
  .nip-header, .nip-footer, .no-print, .btn, .alert-dismissible .btn-close { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #999; }
}

/* Small-screen fixes */
.badge.rounded-pill { white-space: normal; text-align: left; line-height: 1.25; }
.tracker .step { min-width: 0; overflow-wrap: anywhere; }
.hero .crest { background: #fff; border-radius: 50%; padding: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); width: 150px; }
@media (max-width: 575.98px) {
  .tracker .step { font-size: 0; }
  .tracker .step.current { font-size: .72rem; flex: 2.5; }
  .page-head h1 { font-size: 1.3rem; }
}

/* ===================== Responsive: phones, tablets, desktops ===================== */
.stat .num { font-size: clamp(1.15rem, 4.2vw, 1.6rem); overflow-wrap: anywhere; }
main .container-xl { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
img, svg { max-width: 100%; height: auto; }
.text-break-any { overflow-wrap: anywhere; }

/* Collapsed navbar (below 1200px): roomy, readable menu */
@media (max-width: 1199.98px) {
  .nip-header .navbar-collapse { padding: .5rem 0 .75rem; }
  .nip-header .nav-link { padding: .65rem .25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
  .nip-header .nav-link.active { box-shadow: inset 3px 0 0 var(--nip-yellow); padding-left: .75rem; }
  .nip-header .dropdown-menu { background: rgba(255,255,255,.06); border: 0; }
  .nip-header .dropdown-item, .nip-header .dropdown-item-text { color: rgba(255,255,255,.85) !important; }
  .nip-header .dropdown-item:hover { background: rgba(255,255,255,.1); }
  .nip-header .btn-warning { margin-top: .5rem; }
}

/* Wizard steps: one swipeable row on phones instead of four wrapped lines */
@media (max-width: 767.98px) {
  .wizard-steps { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: .4rem; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .wizard-steps li { flex: 0 0 auto; scroll-snap-align: start; }
}

/* Tables become cards on phones (labels filled in by app.js from the header row) */
@media (max-width: 767.98px) {
  .table-stack thead, .table-stack tfoot { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { border: 1px solid #e1e5ef; border-radius: .6rem; margin: .6rem 0; padding: .35rem .25rem; background: #fff; }
  .table-stack > :not(caption) > * > * { border-bottom-width: 0; box-shadow: none; }
  .table-stack td { display: flow-root; text-align: right !important; padding: .3rem .6rem !important; white-space: normal !important; overflow-wrap: anywhere; }
  .table-stack td::before { content: attr(data-label); float: left; width: 36%; margin-right: .75rem; text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--nip-muted); font-weight: 600; padding-top: .15rem; }
  .table-stack td[data-label=""]::before, .table-stack td:not([data-label])::before { display: none; }
  .table-stack td > form { display: inline-flex; justify-content: flex-end; }
  .table-stack td .bar-h { margin-left: calc(36% + .75rem); margin-top: .5rem; }
  .table-stack td .form-select { display: inline-block; width: auto; max-width: 60%; }
  .table-responsive:has(> .table-stack) { overflow-x: visible; }
  .card > .table-responsive > .table-stack, .card .table-stack { padding: 0 .5rem; }
  .table-stack tr:hover > * { --bs-table-bg-state: transparent; }
}

/* Touch devices: comfortable tap targets */
@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  .form-control, .form-select { min-height: 44px; font-size: 16px; } /* 16px stops iOS zooming into fields */
  .form-check-input { width: 1.3em; height: 1.3em; }
  .form-check { padding-left: 2em; min-height: 1.8rem; }
  .form-check .form-check-input { margin-left: -2em; }
  .page-link { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  details > summary { padding: .45rem 0; }
}

/* Small phones */
@media (max-width: 575.98px) {
  .card-body { padding: .9rem; }
  .page-head { margin-bottom: 1rem; }
  .page-head > div:last-child:not(:first-child) { width: 100%; }
  .page-head > .d-flex .btn { flex: 1 1 auto; }
  .q-row .btn-group { display: flex; width: 100%; }
  .q-row .btn-group > .btn { flex: 1; }
  .nip-header .navbar-brand .lh-sm span:first-child { font-size: .95rem; }
}

/* Tablets in portrait: give long forms more room */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .container-xl { max-width: 100%; }
}
