/**
 * tt-bootstrap.css
 * Bridge theme for the CoreUI 5 / Bootstrap 5 modernization.
 *
 * Two jobs:
 *  1) Layout glue that the @coreui/coreui package leaves to the template
 *     (the .wrapper offset for the fixed sidebar).
 *  2) Make the legacy CakePHP views (raw <table>, .button, .paging, default
 *     FormHelper output, flash messages) render acceptably under Bootstrap 5
 *     WITHOUT touching each of the 78 un-converted templates.
 *
 * Anything already written with real Bootstrap classes (.table, .btn, .card,
 * .form-control ...) is intentionally NOT targeted here, so converted views
 * (e.g. Contacts) keep full control.
 */

/* ------------------------------------------------------------------ */
/* 1. Layout                                                          */
/* ------------------------------------------------------------------ */

/* Sidebar styling is intentionally left to the CoreUI theme defaults — no
   custom palette here (see git history for the previous dark override that
   hurt legibility of non-active items). */

/* The fixed sidebar publishes --cui-sidebar-occupy-start on its siblings
   (>=992px). The package CSS does not include the rule that consumes it, so
   we add it here. Below 992px the var is unset and this resolves to 0. */
.wrapper {
  width: 100%;
  padding-inline-start: var(--cui-sidebar-occupy-start, 0);
  transition: padding .15s;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  color: var(--cui-secondary-color);
  border-top: 1px solid var(--cui-border-color);
}

/* CakePHP renders tinyint(1) columns as checkboxes. If a form's inputDefaults
   applied .form-control to one, it would render as a full-width box and become
   unusable. Reset any checkbox/radio carrying .form-control back to a normal
   control so it stays clickable wherever a field was missed. */
.workarea input[type="checkbox"].form-control,
.workarea input[type="radio"].form-control {
  display: inline-block;
  width: auto;
  min-height: 0;
  padding: 0;
  box-shadow: none;
  vertical-align: middle;
}

/* Record detail sheet on view pages: label column hugs its content and
   never wraps; value column takes the rest. */
.tt-detail th {
  width: 1%;
  white-space: nowrap;
  font-weight: 600;
  color: var(--cui-secondary-color, #6c757d);
  padding-right: 1.5rem;
  vertical-align: top;
}
.tt-detail td {
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* 2. Legacy-view bridge (scoped to the content area)                 */
/* ------------------------------------------------------------------ */

.workarea > h1,
.workarea > div > h2,
.workarea h2 {
  font-size: 1.5rem;
  font-weight: 500;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--cui-border-color);
}

.workarea h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.25rem 0 .5rem;
}

/* Tables that have NOT been given a .table class get Bootstrap-ish styling. */
.workarea table:not(.table) {
  width: 100%;
  margin-bottom: 1rem;
  background-color: var(--cui-card-bg, #fff);
  border: 1px solid var(--cui-border-color, #dee2e6);
  border-collapse: collapse;
}
.workarea table:not(.table) th,
.workarea table:not(.table) td {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--cui-border-color, #dee2e6);
  text-align: left;
  vertical-align: middle;
}
.workarea table:not(.table) thead th,
.workarea table:not(.table) tr:first-child th {
  background-color: #f0f2f5;
  font-weight: 600;
  white-space: nowrap;
}
.workarea table:not(.table) tr.altrow,
.workarea table:not(.table) tr:nth-child(even) {
  background-color: rgba(0, 0, 0, .025);
}

/* Definition lists used by scaffolded "view" pages. */
.workarea dl {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--cui-border-color, #dee2e6);
  border-radius: .375rem;
  overflow: hidden;
}
.workarea dl dt {
  padding: .5rem .75rem;
  font-weight: 600;
  background-color: #f0f2f5;
  border-bottom: 1px solid var(--cui-border-color, #dee2e6);
}
.workarea dl dd {
  margin: 0;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--cui-border-color, #dee2e6);
}

/* Default CakePHP FormHelper output ( <div class="input"> ... ). */
.workarea .input {
  margin-bottom: 1rem;
}
.workarea .input label {
  display: inline-block;
  margin-bottom: .35rem;
  font-weight: 500;
}
.workarea .input input[type="text"],
.workarea .input input[type="email"],
.workarea .input input[type="password"],
.workarea .input input[type="number"],
.workarea .input input[type="date"],
.workarea .input input[type="datetime-local"],
.workarea .input select,
.workarea .input textarea {
  display: block;
  width: 100%;
  max-width: 32rem;
  padding: .375rem .75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--cui-body-color, #212529);
  background-color: #fff;
  border: 1px solid var(--cui-border-color, #ced4da);
  border-radius: .375rem;
}
.workarea .input.checkbox label {
  margin-left: .4rem;
  font-weight: 400;
}

/* Buttons and submit inputs (legacy ".button" + bare submit). */
.workarea .button,
.workarea button[type="submit"],
.workarea input[type="submit"] {
  display: inline-block;
  padding: .375rem .75rem;
  font-size: .95rem;
  font-weight: 400;
  line-height: 1.5;
  color: #fff !important;
  text-decoration: none;
  background-color: var(--cui-primary, #5856d6);
  border: 1px solid transparent;
  border-radius: .375rem;
  cursor: pointer;
}
.workarea .button:hover,
.workarea button[type="submit"]:hover,
.workarea input[type="submit"]:hover {
  filter: brightness(.93);
}

/* Inline row-action links in legacy list tables. */
.workarea td.cactions a,
.workarea .actions a {
  display: inline-block;
  margin-right: .4rem;
  font-size: .85rem;
}

/* Pagination produced by PaginatorHelper. */
.workarea .paging {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin: 1rem 0;
}
.workarea .paging a,
.workarea .paging span {
  padding: .375rem .75rem;
  border: 1px solid var(--cui-border-color, #dee2e6);
  border-radius: .375rem;
  text-decoration: none;
}
.workarea .paging span.current {
  background-color: var(--cui-primary, #5856d6);
  color: #fff;
  border-color: var(--cui-primary, #5856d6);
}
.workarea .paging .disabled {
  color: var(--cui-secondary-color, #6c757d);
}

/* "Actions" side blocks from scaffolded views. */
.workarea .cactions ul,
.workarea .related ul {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

/* ------------------------------------------------------------------ */
/* 3. Flash messages -> Bootstrap alerts                              */
/* ------------------------------------------------------------------ */
#flashMessage,
.workarea .message,
.workarea .error,
.workarea .success,
.workarea .notice,
.workarea .warning {
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: .375rem;
}
#flashMessage,
.workarea .message,
.workarea .notice,
.workarea .warning {
  color: #664d03;
  background-color: #fff3cd;
  border-color: #ffe69c;
}
.workarea .error {
  color: #842029;
  background-color: #f8d7da;
  border-color: #f5c2c7;
}
.workarea .success {
  color: #0f5132;
  background-color: #d1e7dd;
  border-color: #badbcc;
}

/* ------------------------------------------------------------------ */
/* 4. Pagination produced by CakePHP's PaginatorHelper                */
/*    Markup varies: <li><a>2</a></li> for links, <li class="active">  */
/*    <span>1</span></li> for the current page, and <li class=         */
/*    "disabled">«</li> (BARE TEXT, no inner element) for disabled     */
/*    prev/next. So the bordered "box" lives on the <li> itself — that */
/*    way disabled bare-text items get the same box as the rest.       */
/* ------------------------------------------------------------------ */
.pagination li {
  display: block;
  background-color: #fff;
  border: 1px solid var(--cui-border-color, #dee2e6);
}
.pagination li + li { margin-left: -1px; }
.pagination li:first-child { border-top-left-radius: .375rem; border-bottom-left-radius: .375rem; }
.pagination li:last-child  { border-top-right-radius: .375rem; border-bottom-right-radius: .375rem; }

/* The clickable / text area: an inner <a>/<span> when present, or the
   <li> itself for the disabled bare-text prev/next. */
.pagination li > a,
.pagination li > span,
.pagination li.disabled {
  display: block;
  padding: .375rem .75rem;
  line-height: 1.25;
  color: var(--cui-primary, #5856d6);
  text-decoration: none;
}
.pagination li.disabled,
.pagination li.disabled > a,
.pagination li.disabled > span {
  color: var(--cui-secondary-color, #6c757d);
  pointer-events: none;
}
.pagination li.active {
  background-color: var(--cui-primary, #5856d6);
  border-color: var(--cui-primary, #5856d6);
}
.pagination li.active > a,
.pagination li.active > span { color: #fff; }
