/*
 * Accessibility and usability layer, loaded after app.css.
 * Keeps the Spire look (soft teal, light grey) but with accessible contrast,
 * visible focus, comfortable touch targets and responsive tables/forms.
 */

:root {
  --brand: #3A726C;          /* white text on it: 5.5:1 */
  --brand-dark: #2F6B65;     /* hover, 6.1:1 */
  --brand-soft: #81ADA8;     /* original brand teal, decorative only */
  --info: #1B7F9E;           /* 4.6:1 with white */
  --danger: #B02A37;         /* 6.5:1 with white */
  --success: #1E7A4C;        /* 5.3:1 with white */
  --text: #333;
  --text-muted: #555;        /* 6.8:1 on the page background */
  --focus: #0B5FFF;
  --target: 44px;
}

body { font-size: 14px; line-height: 1.5; color: var(--text); }

/* ---------- skip link + focus ---------- */
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 2000;
  background: #fff; color: var(--brand-dark); padding: 10px 16px; border-radius: 4px;
  font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.skip-link:focus { top: 8px; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--focus) !important;
  outline-offset: 2px !important;
  box-shadow: none;
}
#main:focus { outline: none; }

/* ---------- buttons ---------- */
.btn-primary, .btn-primary:link, .btn-primary:visited {
  background-color: var(--brand); border-color: var(--brand); color: #fff !important;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active {
  background-color: var(--brand-dark); border-color: var(--brand-dark);
}
.btn-info    { background-color: var(--info);    border-color: var(--info);    color: #fff; }
.btn-danger  { background-color: var(--danger);  border-color: var(--danger);  color: #fff; }
.btn-success { background-color: var(--success); border-color: var(--success); color: #fff; }
.btn-info:hover, .btn-info:focus       { background-color: #166a85; border-color: #166a85; color: #fff; }
.btn-danger:hover, .btn-danger:focus   { background-color: #8f212c; border-color: #8f212c; color: #fff; }
.btn-success:hover, .btn-success:focus { background-color: #186340; border-color: #186340; color: #fff; }

.btn { min-height: 36px; cursor: pointer; transition: background-color .15s ease, border-color .15s ease; }
.btn-sm, .btn-icon.btn-sm { min-height: 36px; min-width: 36px; }
@media (pointer: coarse) {
  .btn, .btn-sm, .btn-icon.btn-sm, .form-control { min-height: var(--target); }
  .btn-icon.btn-sm { min-width: var(--target); }
}

/* header bar: one flat, darker teal (the theme's diagonal gradient was lighter at one end and restarted in the brand block) */
.bg-primary, .bg-primary.header, header.bg-primary { background: var(--brand) !important; filter: none !important; }
.header .navbar-header, .header .navbar-header.dk { background: var(--brand-dark) !important; filter: none !important; }
.bg-primary .navbar-nav > li > a, .bg-primary a.navbar-brand { color: #fff; }
.header .btn-search, .navbar-form .btn-search { background-color: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }
.navbar-form .form-control { height: 34px; }

/* ---------- text + forms ---------- */
.text-muted, .text-xs.text-muted, .help-block { color: var(--text-muted); }
.control-label, label { color: var(--text); font-weight: 600; }
.form-control { color: var(--text); border-color: #b8bec6; height: 38px; }
.form-control::placeholder { color: #6b7280; opacity: 1; }
.form-control[readonly] { background-color: #f6f7f9; }
.form-group { margin-bottom: 14px; }
.panel-heading { font-size: 15px; color: var(--text); }
h1.h3, .page-title { margin: 0; line-height: 1.3; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-head .page-title { flex: 1 1 auto; }
.page-head .page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.checkbox-field { display: flex; align-items: center; gap: 10px; min-height: var(--target); }
.checkbox-field input[type=checkbox] { width: 20px; height: 20px; margin: 0; flex: none; }
.checkbox-field label { margin: 0; font-weight: 600; }
.field-link { display: inline-block; margin-top: 6px; color: var(--info); text-decoration: underline; }

.consultant-photo { max-width: 100%; border-radius: 4px; border: 1px solid #dde1e6; margin-bottom: 10px; }
.photo-placeholder {
  display: flex; align-items: center; justify-content: center; height: 140px; margin-bottom: 10px;
  border: 2px dashed #b8bec6; border-radius: 4px; color: var(--text-muted);
}

/* ---------- data tables ---------- */
.table > thead > tr > th { color: var(--text); font-weight: 600; white-space: nowrap; vertical-align: middle; }
.table > tbody > tr > td { vertical-align: middle; }
.table-actions { display: inline-flex; flex-wrap: nowrap; gap: 6px; }
.table-actions .btn { margin: 0; }
td .cons-image { max-height: 48px; width: auto; border-radius: 3px; }
.panel .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 0; }
.dataTables_wrapper { padding: 0 12px 12px; }
.dataTables_wrapper .dataTables_filter input { margin-left: 6px; }
.dataTables_wrapper .dataTables_length select { min-height: 34px; }

.speciality-xs { display: none; }
@media (max-width: 767px) { .speciality-xs { display: block; margin-top: 2px; } }

.status-yes, .status-no { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status-yes { color: var(--success); }
.status-no  { color: var(--danger); }

/* consultants toolbar: in the page flow instead of absolutely positioned over the table */
.table-toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 12px 0; }
#consultants_datatable_filter { position: static !important; }

/* ---------- login ---------- */
.login-form .field-label { display: block; margin: 12px 0 4px; font-weight: 600; text-align: left; }
.login-form .list-group-item { padding: 0; border: 0; background: transparent; }
.login-form .form-control { height: 44px; border: 1px solid #b8bec6 !important; border-radius: 4px; }
.login-form .btn-block { min-height: 46px; margin-top: 16px; }

/* ---------- phones: stack and scroll instead of overflowing ---------- */
@media (max-width: 767px) {
  .wrapper-lg { padding: 16px 12px; }
  .page-head .page-actions { width: 100%; }
  .page-head .page-actions .btn { flex: 1 1 auto; }
  .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { float: none; text-align: left; margin-bottom: 8px; }
  .dataTables_wrapper .dataTables_filter input { width: 100%; margin: 6px 0 0; display: block; }
  .dataTables_wrapper .dt-buttons { float: none; margin-bottom: 8px; }
  .table-toolbar { justify-content: stretch; }
  .table-toolbar .btn { flex: 1 1 auto; }
  .panel-body .form-group { width: 100% !important; float: none !important; }
}

.btn-default { color: var(--text); border-color: #8a929b; background-color: #fff; }
.btn-default:hover, .btn-default:focus { color: var(--text); background-color: #eef1f4; border-color: #6b7280; }

/* phones: the menu is closed until the hamburger toggles it */
@media (max-width: 767px) {
  #nav { display: none; }
  #nav.nav-off-screen { display: block; }
}

/* ================= layout polish ================= */

/* app shell: fluid up to a wide max, full viewport height (no half-height sidebar) */
body.container { width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; }
html, body { overflow-x: hidden; }
@media (min-width: 768px) {
  body.container > .vbox { min-height: 100vh; height: 100vh; }
  body.container > .vbox > section, body.container > .vbox > section > .hbox.stretch { height: 100%; }
  #content { background: #f2f4f8; }
  #content > .wrapper-lg { min-height: calc(100vh - 66px); }
}
.wrapper-lg { padding: 24px 30px 40px; }
@media (max-width: 991px) { .wrapper-lg { padding: 20px 18px 32px; } }

/* top bar */
.header .navbar-form { margin-top: 15px; margin-bottom: 0; padding-left: 0; }
.header .navbar-form .input-group { width: 330px; max-width: 100%; }
.header .navbar-form .form-control { height: 36px; width: 100%; }
.header .nav.homeback > li > a { padding: 0 14px; line-height: 66px; font-size: 20px; }
.header .nav.phonebook > li > a { font-size: 14px; line-height: 66px; padding: 0 20px; }
.header .nav.phonebook > li > a .fa { margin-right: 6px; font-size: 16px; }

/* page header: title left, actions right, same baseline */
.page-head { margin-bottom: 20px; min-height: 40px; }
h1.page-title, .page-title { font-size: 24px; display: flex; align-items: center; gap: 10px; }
h1.page-title .fa { margin: 0 !important; width: 28px; text-align: center; color: var(--text-muted); }
.page-actions .btn { min-width: 110px; }

/* panels */
.panel { margin-bottom: 20px; }
.panel-heading { padding: 14px 20px; }
.panel-body { padding: 20px; }

/* ---------- DataTables: one tidy control row, table, one footer row ---------- */
.dataTables_wrapper { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px 20px 20px; }
.dataTables_wrapper > .dataTables_length { order: 1; margin: 0; float: none; }
.dataTables_wrapper > .dt-buttons       { order: 2; margin: 0; float: none; display: flex; gap: 6px; }
.dataTables_wrapper > .dataTables_filter { order: 3; margin: 0 0 0 auto; float: none; }
.dataTables_wrapper > .dataTables_processing { order: 0; }
.dataTables_wrapper > table.dataTable { order: 4; flex: 0 0 100%; width: 100% !important; margin: 4px 0 0 !important; }
.dataTables_wrapper > .dataTables_info     { order: 5; margin: 0; padding: 0; flex: 1 1 auto; color: var(--text-muted); }
.dataTables_wrapper > .dataTables_paginate { order: 6; margin: 0; float: none; }
.dataTables_wrapper .dataTables_length label, .dataTables_wrapper .dataTables_filter label { margin: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dataTables_wrapper .dataTables_length select, .dataTables_wrapper .dataTables_filter input {
  height: 36px; min-height: 36px; margin: 0; padding: 4px 10px; border: 1px solid #b8bec6; border-radius: 4px; background: #fff; font-weight: 400;
}
.dataTables_wrapper .dataTables_filter input { width: 260px; max-width: 100%; }
.dataTables_wrapper .dt-buttons .btn, .dataTables_wrapper .dt-buttons .dt-button {
  margin: 0; height: 36px; padding: 0 14px; border-radius: 4px; background: #fff; color: var(--text); border: 1px solid #8a929b; font-weight: 600;
}
.dataTables_wrapper .dt-buttons .dt-button, .dataTables_wrapper .dt-buttons .dt-button span { color: var(--text) !important; }
.dataTables_wrapper .dt-buttons .dt-button:hover { background: #eef1f4; }
.dataTables_paginate .pagination { margin: 0; }
.dataTables_paginate .paginate_button { padding: 6px 12px; }
table.dataTable thead th { padding: 12px 14px; }
table.dataTable tbody td { padding: 10px 14px; }
table.dataTable thead .sorting, table.dataTable thead .sorting_asc, table.dataTable thead .sorting_desc { background-position: right 8px center; padding-right: 26px; }

/* consultants list columns */
@media (min-width: 768px) { #consultants_datatable td:nth-child(3), #consultants_datatable th:nth-child(3) { min-width: 200px; } }
#consultants_datatable td:last-child, #consultants_datatable th:last-child { width: 150px; white-space: nowrap; }
.table-actions { gap: 8px; }

/* ---------- consultant form: sections in a responsive field grid ---------- */
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.label-row label { margin: 0; }
.label-row .field-link { margin: 0; font-size: 13px; font-weight: 600; white-space: nowrap; }
@media (min-width: 992px) { .consultant-section .checkbox-field { grid-column: span 2; } }
.consultant-section .field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 24px; }
.consultant-section .field-grid .form-group { margin-bottom: 16px; }
.consultant-section .field-grid .field-wide { grid-column: 1 / -1; }
.consultant-section .checkbox-field { align-self: end; padding-bottom: 2px; }
.consultant-intro { display: flex; gap: 24px; align-items: flex-start; }
.consultant-intro .consultant-photo-col { flex: 0 0 200px; max-width: 200px; }
.consultant-intro .field-grid { flex: 1 1 auto; min-width: 0; }
@media (max-width: 767px) {
  .consultant-intro { flex-direction: column; align-items: stretch; gap: 8px; }
  .consultant-intro .field-grid { width: 100%; }
  .consultant-intro .consultant-photo-col { flex: none; max-width: 100%; width: 100%; }
  .consultant-section .field-grid { grid-template-columns: 1fr; }
}

/* ---------- simple horizontal forms (users, services, new consultants, phonebook) ---------- */
.form-horizontal { max-width: 900px; }
.form-horizontal .form-group { margin-left: 0; margin-right: 0; }
.form-horizontal .control-label { text-align: right; padding-top: 9px; }
@media (max-width: 991px) { .form-horizontal .control-label { text-align: left; padding-top: 0; } }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.upload-row input[type=file] { flex: 1 1 220px; min-width: 0; }
input[type=file] { font-size: 14px; }

/* ---------- phones: simple lists become compact cards (no sideways scrolling) ---------- */
@media (max-width: 767px) {
  table.mobile-cards, .mobile-cards tbody { display: block; width: 100% !important; }
  .mobile-cards thead { display: none; }
  .mobile-cards tbody tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; background: #fff !important; border: 1px solid #dde1e6; border-radius: 6px; margin-bottom: 10px; padding: 12px 14px; }
  .mobile-cards tbody td { display: block; grid-column: 1; width: auto !important; padding: 0 !important; border: 0 !important; background: transparent !important; text-align: left; overflow-wrap: anywhere; }
  .mobile-cards tbody td:empty, .mobile-cards td.hidden-xs { display: none; }
  .mobile-cards tbody td[data-label="Name"], .mobile-cards tbody td[data-label="Title"] { font-weight: 600; font-size: 15px; }
  .mobile-cards tbody td[data-label="Email"], .mobile-cards tbody td[data-label="Description"] { color: var(--text-muted); font-size: 13px; }
  .mobile-cards tbody td[data-label="Admin"]::before { content: "Admin: "; font-weight: 600; color: var(--text); }
  .mobile-cards tbody td[data-label="Actions"] { grid-column: 2; grid-row: 1 / span 4; justify-self: end; }
  .mobile-cards td.dataTables_empty { grid-column: 1 / -1; text-align: center; }
  .dataTables_wrapper { padding: 12px; gap: 8px 12px; }
  .dataTables_paginate .paginate_button { padding: 6px 9px; }
  #consultants_datatable td, #consultants_datatable th { padding: 10px 8px; }
}

/* ---------- icon centring ---------- */
.btn-icon, .table-actions .btn, .btn-search {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
}
.btn-icon, .table-actions .btn { padding: 0 !important; width: 36px; height: 36px; }
.btn-icon .fa, .table-actions .btn .fa, .btn-search .fa { line-height: 1; margin: 0; }
@media (pointer: coarse) { .btn-icon, .table-actions .btn { width: var(--target); height: var(--target); } }
.btn-search .btn-pad { margin-right: 6px; }
.header .nav.homeback > li > a { display: flex; align-items: center; justify-content: center; height: 66px; line-height: 1; padding: 0 14px; }
.header .nav.homeback > li > a .fa { line-height: 1; font-size: 20px; }
.header .nav.phonebook > li > a { display: flex; align-items: center; height: 66px; line-height: 1; }
.header .nav.phonebook > li > a .fa { line-height: 1; }
h1.page-title .fa { line-height: 1; }
.status-yes .fa, .status-no .fa { line-height: 1; }

/* DataTables blocks come with 15px padding from the stock stylesheet: the wrapper already pads and gaps them */
.dataTables_wrapper > .dataTables_length, .dataTables_wrapper > .dataTables_filter,
.dataTables_wrapper > .dataTables_info, .dataTables_wrapper > .dataTables_paginate, .dataTables_wrapper > .dt-buttons { padding: 0 !important; }
.dataTables_wrapper { row-gap: 10px; }
/* any button with an icon + text: centre both */
.btn:not(.btn-block):not(.dropdown-toggle) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn .fa { line-height: 1; }

/* ---------- phones: use the width (smaller page, card and table gutters) ---------- */
@media (max-width: 767px) {
  .wrapper-lg { padding: 14px 10px 28px; }
  .panel { margin-bottom: 14px; border-radius: 4px; }
  .panel-heading { padding: 12px 14px; }
  .panel-body { padding: 14px; }
  .dataTables_wrapper { padding: 10px; }
  .page-head { margin-bottom: 14px; }
  /* "Show entries" and "Search" share one row; Search takes the remaining width */
  .dataTables_wrapper { gap: 8px 10px; }
  .dataTables_wrapper > .dataTables_length { flex: 0 0 auto; margin: 0 !important; }
  .dataTables_wrapper > .dataTables_filter { flex: 1 1 150px; min-width: 0; margin: 0 !important; }
  .dataTables_wrapper .dataTables_filter label { width: 100%; }
  .dataTables_wrapper .dataTables_filter input { flex: 1 1 auto; width: auto; min-width: 0; }
  .dataTables_wrapper .dataTables_length label, .dataTables_wrapper .dataTables_filter label { gap: 6px; }
  .dataTables_wrapper > table.dataTable { margin-top: 0 !important; }
  .dataTables_wrapper > .dataTables_filter { order: 2; }
  .dataTables_wrapper > .dt-buttons { order: 3; flex: 1 1 100%; }
}

/* header search: input and button read as one control */
.header .navbar-form .input-group { display: flex; width: 330px; max-width: 100%; }
.header .navbar-form .input-group .form-control { flex: 1 1 auto; min-width: 0; height: 36px; border-radius: 4px 0 0 4px; border: 0; }
.header .navbar-form .input-group-btn { width: auto; display: block; font-size: 0; }
.header .navbar-form .btn-search {
  width: auto !important; height: 36px; padding: 0 16px !important; margin: 0 !important; gap: 8px;
  background: var(--brand-dark) !important; border: 1px solid #245853 !important; border-radius: 0 4px 4px 0 !important;
  color: #fff !important; font-size: 13px; font-weight: 600; line-height: 1;
}
.header .navbar-form .btn-search:hover, .header .navbar-form .btn-search:focus { background: #245853 !important; }
.header .navbar-form .btn-search .fa { margin: 0 !important; font-size: 13px; }

/* brand block as tall as the header bar (the theme made it 60px inside a 66px bar) */
@media (min-width: 768px) {
  .header .navbar-header, .header .navbar-header .navbar-brand { height: 66px; line-height: 66px; }
  .header .navbar-header .navbar-brand { display: flex; align-items: center; justify-content: center; padding-top: 0; padding-bottom: 0; }
  .header .navbar-header .navbar-brand img { max-height: 36px; width: auto; margin-top: 0; }
}

/* ---------- 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 {
  .skip-link { display: none; }
}
