/* Digital Operasional Titik theme. Bootstrap 5 utilities first; custom CSS only for the brand look.

   Design tokens (change here, everything follows):
   - Colors   : originally taken from the Titik Service logo (kept after the D.O.T rebrand). --titik-blue / --titik-navy (brand blue: sidebar, headings, actions),
                --titik-orange (accent: active menu, highlights), --titik-sky / --titik-peach (soft fills)
   - Surfaces : page = --page-bg (light grey), cards/inputs = white (Bootstrap --bs-body-bg)
   - Radius   : --bs-border-radius (0.65rem), cards use --bs-border-radius-lg
   - Breakpoints (Bootstrap): sm 576, md 768, lg 992 (sidebar becomes a drawer below lg), xl 1200
   - Letter size: <html data-text-size="normal|large|xlarge"> scales the root font (16/18/20px); everything is rem-based
   - Touch comfort: buttons, inputs and tabs are at least 3rem high (spec 2026-10-30-simple-ui-and-job-tabs)
   Reusable pieces: .page-title, .detail-label/.detail-value, .badge-soft-*, .avatar, .quick-card, .hero-card,
                    .tab-bar (tabs of the job and visit pages), .home-action (big buttons of the field home)
*/

:root {
  --titik-navy: #061f55;
  --titik-navy-2: #0b3a9e;
  --titik-blue: #0b3a9e;
  --titik-blue-dark: #082d7c;
  --titik-sky: #e6edfb;
  --titik-orange: #ff6a00;
  --titik-orange-dark: #e05a00;
  --titik-peach: #fff0e3;
  --titik-sidebar-width: 17rem;

  --bs-primary: var(--titik-blue);
  --bs-primary-rgb: 11, 58, 158;
  --bs-link-color: var(--titik-blue-dark);
  --bs-link-color-rgb: 8, 45, 124;
  --bs-link-hover-color: var(--titik-navy-2);
  --page-bg: #f4f6fb;
  --bs-body-bg: #fff;
  --bs-border-radius: 0.65rem;
  --bs-border-radius-lg: 0.9rem;
  --bs-secondary-color: #4a5568;
  --titik-control-height: 3rem;
}

/* ---------- Letter size and touch comfort (elderly users) ---------- */
html { font-size: 100%; }
html[data-text-size="large"] { font-size: 112.5%; }
html[data-text-size="xlarge"] { font-size: 125%; }

body { line-height: 1.6; }
small, .small { font-size: 0.9rem; }

.btn {
  --bs-btn-padding-y: 0.6rem;
  --bs-btn-padding-x: 1.1rem;
  min-height: var(--titik-control-height);
}

.btn-sm {
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-padding-x: 0.9rem;
  --bs-btn-font-size: 1rem;
}

.form-control,
.form-select {
  min-height: var(--titik-control-height);
  font-size: 1rem;
}

.form-label { font-weight: 500; }
.form-check { min-height: 2rem; }
.form-check-input { width: 1.4em; height: 1.4em; margin-top: 0.15em; }
.form-check-label { padding-left: 0.25rem; }

.badge { font-size: 0.85rem; padding: 0.4em 0.65em; }

.dropdown-item { display: flex; align-items: center; min-height: var(--titik-control-height); }
[data-text-size-choice] .bi-check-lg { visibility: hidden; }
[data-text-size-choice].active .bi-check-lg { visibility: visible; }

body {
  background-color: var(--page-bg);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

.page-container {
  max-width: 90rem;
  margin-inline: auto;
}

:focus-visible {
  outline: 3px solid var(--titik-blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

.btn-primary {
  --bs-btn-bg: var(--titik-blue);
  --bs-btn-border-color: var(--titik-blue);
  --bs-btn-hover-bg: var(--titik-blue-dark);
  --bs-btn-hover-border-color: var(--titik-blue-dark);
  --bs-btn-active-bg: var(--titik-navy-2);
  --bs-btn-active-border-color: var(--titik-navy-2);
  --bs-btn-disabled-bg: var(--titik-blue);
  --bs-btn-disabled-border-color: var(--titik-blue);
}

.btn-outline-primary {
  --bs-btn-color: var(--titik-blue-dark);
  --bs-btn-border-color: var(--titik-blue);
  --bs-btn-hover-bg: var(--titik-blue);
  --bs-btn-hover-border-color: var(--titik-blue);
  --bs-btn-active-bg: var(--titik-blue-dark);
  --bs-btn-active-border-color: var(--titik-blue-dark);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--titik-blue);
  box-shadow: 0 0 0 0.2rem rgba(11, 58, 158, 0.2);
}

/* ---------- App shell ---------- */
.app-sidebar {
  width: var(--titik-sidebar-width);
  background: linear-gradient(180deg, var(--titik-navy) 0%, var(--titik-navy-2) 100%);
  color: #cdd8f3;
}

@media (min-width: 992px) {
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
  }

  .app-main {
    margin-left: var(--titik-sidebar-width);
  }
}

.app-sidebar .offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo-card {
  display: block;
  margin: 1rem 1rem 0.25rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.9rem;
  background: #fff;
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.25);
}

.sidebar-logo {
  display: block;
  width: 100%;
  height: auto;
}

.topbar-mark {
  height: 2.25rem;
  width: auto;
}

.nav-section {
  padding: 0.25rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a9b8e0;
}

.app-sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.1rem 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.65rem;
  color: #dbe4fa;
  font-size: 1.05rem;
  font-weight: 500;
}

.app-sidebar .nav-link .bi {
  font-size: 1.1rem;
  opacity: 0.85;
}

.app-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.app-sidebar .nav-link.active {
  background: var(--titik-orange);
  color: #fff;
  box-shadow: 0 0.35rem 0.9rem rgba(255, 106, 0, 0.35);
}

.app-topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--titik-sky);
  color: var(--titik-blue-dark);
  font-weight: 700;
  text-transform: uppercase;
}

.avatar-lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.4rem;
  border-radius: 1rem;
}

/* ---------- Cards, tables ---------- */
.card {
  border: 1px solid #e5eaf5;
  box-shadow: 0 0.15rem 0.6rem rgba(10, 31, 77, 0.05);
}

.card-header {
  background: #fff;
  font-weight: 600;
}

.page-title {
  font-weight: 700;
  color: var(--titik-navy);
}

.table > :not(caption) > * > * {
  padding: 0.8rem 1rem;
}

.table thead th {
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a5878;
  background: #f8faff;
  border-bottom: 1px solid #e5eaf5;
  white-space: nowrap;
}

.table-hover > tbody > tr:hover > * {
  --bs-table-hover-bg: #f1f6ff;
}

.badge-soft-primary {
  background: var(--titik-sky);
  color: var(--titik-blue-dark);
}

.badge-soft-accent {
  background: var(--titik-peach);
  color: var(--titik-orange-dark);
}

.badge-soft-secondary {
  background: #eef1f7;
  color: #4a5878;
}

.badge-soft-success {
  background: #e3f6ec;
  color: #14703f;
}

.badge-soft-warning {
  background: #fff3d6;
  color: #8a5a00;
}

.badge-soft-danger {
  background: #fde8e8;
  color: #a12626;
}

.badge-soft-info {
  background: #e0f2fb;
  color: #0a5a82;
}

.detail-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #4a5878;
  margin-bottom: 0.1rem;
}

.detail-value {
  margin-bottom: 1rem;
  word-break: break-word;
}

.hero-card {
  background: radial-gradient(28rem 14rem at 100% 0%, rgba(255, 106, 0, 0.55), transparent 70%),
    linear-gradient(120deg, var(--titik-navy) 0%, var(--titik-navy-2) 100%);
  color: #fff;
  border: 0;
}

.quick-card {
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.quick-card:hover {
  box-shadow: 0 0.6rem 1.4rem rgba(10, 31, 77, 0.12);
}

.quick-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.9rem;
  background: var(--titik-peach);
  color: var(--titik-orange-dark);
  font-size: 1.4rem;
}

/* ---------- Small helpers ---------- */
.sidebar-foot { color: #a9b8e0; }
.text-xs { font-size: 0.85rem; }
.section-label { letter-spacing: 0.08em; }

/* ---------- Login ---------- */
.auth-wrap { max-width: 26rem; }
.auth-foot { color: #8fb3ff; }
.auth-logo { display: block; width: 78%; max-width: 17rem; height: auto; margin: 0 auto 1.25rem; }

.auth-page {
  min-height: 100vh;
  background:
    radial-gradient(50rem 26rem at 90% -10%, rgba(255, 106, 0, 0.45), transparent 60%),
    linear-gradient(160deg, var(--titik-navy) 0%, var(--titik-navy-2) 100%);
}

.auth-card {
  border: 0;
  border-radius: 1.1rem;
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.3);
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 150ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Dispatch board (apps/scheduling): lanes down, days across; a wide table scrolls inside its card */
.board-table th.board-lane { min-width: 8rem; }
.board-table td { min-width: 9.5rem; }
.visit-card { background-color: var(--bs-body-bg); }

/* Calendar (5b): FullCalendar events take the colour of the job status, like the badges */
#calendar { --fc-border-color: var(--bs-border-color); --fc-today-bg-color: var(--titik-sky); --fc-button-bg-color: var(--titik-blue); --fc-button-border-color: var(--titik-blue); --fc-button-hover-bg-color: var(--titik-blue-dark); --fc-button-hover-border-color: var(--titik-blue-dark); --fc-button-active-bg-color: var(--titik-blue-dark); --fc-button-active-border-color: var(--titik-blue-dark); }
#calendar .fc-event { cursor: default; }
#calendar .fc-event.fc-event-draggable { cursor: grab; }
#calendar .fc-event { --fc-event-bg-color: #eef1f7; --fc-event-border-color: #4a5878; --fc-event-text-color: #4a5878; }
#calendar .fc-event.visit-status-primary { --fc-event-bg-color: var(--titik-sky); --fc-event-border-color: var(--titik-blue); --fc-event-text-color: var(--titik-blue-dark); }
#calendar .fc-event.visit-status-accent { --fc-event-bg-color: var(--titik-peach); --fc-event-border-color: var(--titik-orange); --fc-event-text-color: var(--titik-orange-dark); }
#calendar .fc-event.visit-status-secondary { --fc-event-bg-color: #eef1f7; --fc-event-border-color: #4a5878; --fc-event-text-color: #4a5878; }
#calendar .fc-event.visit-status-success { --fc-event-bg-color: #e3f6ec; --fc-event-border-color: #14703f; --fc-event-text-color: #14703f; }
#calendar .fc-event.visit-status-warning { --fc-event-bg-color: #fff3d6; --fc-event-border-color: #8a5a00; --fc-event-text-color: #8a5a00; }
#calendar .fc-event.visit-status-danger { --fc-event-bg-color: #fde8e8; --fc-event-border-color: #a12626; --fc-event-text-color: #a12626; }
#calendar .fc-event.visit-status-info { --fc-event-bg-color: #e0f2fb; --fc-event-border-color: #0a5a82; --fc-event-text-color: #0a5a82; }
#calendar .fc-event.visit-done { opacity: 0.6; }
#calendar .fc-event.visit-on-site { border-left-width: 5px; }
#calendar .fc-toolbar-title { font-size: 1.1rem; }
@media (max-width: 767.98px) {
  #calendar .fc-toolbar { flex-direction: column; gap: 0.5rem; }
}

/* Photos of a job (6b): a square thumbnail, the full picture opens in a new tab */
.photo-item { width: 96px; }
.photo-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 0.5rem; border: 1px solid var(--bs-border-color); background-color: var(--bs-tertiary-bg); }

/* The work order (7): a plain A4 sheet; everything meant for the screen is hidden on paper */
.work-order { max-width: 800px; page: work-order; }
.work-order-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--bs-secondary-color); }
.work-order-line { border-bottom: 1px solid var(--bs-body-color); height: 4.5rem; margin-bottom: 0.25rem; }
@media print {
  @page work-order { size: A4; margin: 15mm; }
  .work-order-body { background: #fff; }
  .work-order { max-width: none; padding: 0; }
}

/* Customer ratings (W3): the spread of stars as thin bars */
.rating-label { width: 4.5rem; }
.rating-count { width: 2.5rem; }
.rating-bar { height: 0.6rem; accent-color: var(--bs-warning); }

/* Stock pages (#10): form widths and the column where a counted quantity is typed */
.stock-form-narrow { max-width: 30rem; }
.stock-form-wide { max-width: 36rem; }
.stock-count-col { width: 9rem; }

/* Tabs of the job and visit pages: Bootstrap 5.3 nav-underline inside a card. A flat strip of big labelled tabs;
   the open tab is bold with a thick orange line that sits on the card's divider. Tabs wrap onto the next row
   on a narrow screen, they never scroll sideways. */
.tabs-card {
  margin-bottom: 1.5rem;
  border: 1px solid #e5eaf5;
  border-radius: var(--bs-border-radius-lg);
  background: #fff;
  box-shadow: 0 0.15rem 0.6rem rgba(10, 31, 77, 0.05);
  overflow: hidden;
}
.tab-bar {
  --bs-nav-underline-gap: 0.25rem 1.75rem;
  --bs-nav-underline-border-width: 0.25rem;
  --bs-nav-underline-link-color: #4a5878;
  --bs-nav-underline-link-hover-color: var(--titik-blue);
  --bs-nav-underline-link-active-color: var(--titik-blue-dark);
  padding: 0 1.25rem;
  background: #f8faff;
  border-bottom: 1px solid #e5eaf5;
}
.tab-bar .nav-item { flex: 1 1 40%; }
.tab-bar .nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--titik-control-height);
  margin-bottom: -1px;
  font-weight: 600;
}
.tab-bar .nav-link.active { border-bottom-color: var(--titik-orange); }
.tab-body { padding: 1.25rem; }
.tab-body .card { box-shadow: none; }
@media (min-width: 768px) {
  .tab-bar .nav-item { flex: 0 0 auto; }
}

/* The customer's place on a map (job page, online request page) */
.location-map { height: 16rem; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); background: var(--bs-tertiary-bg); }
@media (min-width: 768px) { .location-map { height: 20rem; } }
.location-map--down { height: auto; padding: 1rem; color: var(--bs-secondary-color); }

/* Home of technicians and partners: a few very big buttons, one per row */
.home-actions { max-width: 32rem; }
.home-action {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 5rem;
  padding: 1rem 1.25rem;
  font-size: 1.3rem;
  font-weight: 600;
  text-align: left;
}
.home-action .bi { font-size: 2rem; }
