/* =====================================================================
   TI PROP FLEET MANAGEMENT SYSTEM - Corporate theme (Bootstrap 5.3)

   Primary: Dark Red. Secondary: Black / Charcoal.
   Supporting: White, light grey, neutrals.  (SRS 8.2, CLAUDE.md 8.1)

   The exact hex values below are provisional until the official
   TI Properties brand colours are supplied; change them here only.
   ===================================================================== */

:root {
  --tp-red: #8b1a1f;
  --tp-red-rgb: 139, 26, 31;
  --tp-red-hover: #741519;
  --tp-red-active: #5e1014;
  --tp-red-subtle: #f6e8e9;
  --tp-red-border-subtle: #e2b8bb;
  --tp-charcoal: #22262a;
  --tp-sidebar-text: #c9ced3;
  --tp-page-bg: #f4f5f7;
  --tp-border: #e3e5e8;
  --tp-sidebar-width: 264px;
  --tp-header-height: 64px;

  /* Map the corporate red onto Bootstrap's "primary" colour. */
  --bs-primary: var(--tp-red);
  --bs-primary-rgb: var(--tp-red-rgb);
  --bs-primary-text-emphasis: #4a0d10;
  --bs-primary-bg-subtle: var(--tp-red-subtle);
  --bs-primary-border-subtle: var(--tp-red-border-subtle);
  --bs-link-color: var(--tp-red);
  --bs-link-color-rgb: var(--tp-red-rgb);
  --bs-link-hover-color: var(--tp-red-hover);
  --bs-link-hover-color-rgb: 116, 21, 25;
  --bs-focus-ring-color: rgba(var(--tp-red-rgb), 0.25);
}

/* ---------------------------------------------------------------------
   Bootstrap components recoloured to the corporate red
   --------------------------------------------------------------------- */
.btn-primary {
  --bs-btn-bg: var(--tp-red);
  --bs-btn-border-color: var(--tp-red);
  --bs-btn-hover-bg: var(--tp-red-hover);
  --bs-btn-hover-border-color: var(--tp-red-hover);
  --bs-btn-active-bg: var(--tp-red-active);
  --bs-btn-active-border-color: var(--tp-red-active);
  --bs-btn-disabled-bg: var(--tp-red);
  --bs-btn-disabled-border-color: var(--tp-red);
  --bs-btn-focus-shadow-rgb: var(--tp-red-rgb);
}

.btn-outline-primary {
  --bs-btn-color: var(--tp-red);
  --bs-btn-border-color: var(--tp-red);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--tp-red);
  --bs-btn-hover-border-color: var(--tp-red);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--tp-red-active);
  --bs-btn-active-border-color: var(--tp-red-active);
  --bs-btn-disabled-color: var(--tp-red);
  --bs-btn-disabled-border-color: var(--tp-red);
  --bs-btn-focus-shadow-rgb: var(--tp-red-rgb);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: #c98a8e;
  box-shadow: 0 0 0 0.25rem rgba(var(--tp-red-rgb), 0.2);
}

.form-check-input:checked {
  background-color: var(--tp-red);
  border-color: var(--tp-red);
}

.dropdown-menu {
  --bs-dropdown-link-active-bg: var(--tp-red);
}

.pagination {
  --bs-pagination-color: var(--tp-red);
  --bs-pagination-hover-color: var(--tp-red-hover);
  --bs-pagination-focus-color: var(--tp-red-hover);
  --bs-pagination-focus-box-shadow: 0 0 0 0.25rem rgba(var(--tp-red-rgb), 0.2);
  --bs-pagination-active-bg: var(--tp-red);
  --bs-pagination-active-border-color: var(--tp-red);
}

.nav-pills {
  --bs-nav-pills-link-active-bg: var(--tp-red);
}

.list-group {
  --bs-list-group-active-bg: var(--tp-red);
  --bs-list-group-active-border-color: var(--tp-red);
}

.progress,
.progress-stacked {
  --bs-progress-bar-bg: var(--tp-red);
}

.card {
  --bs-card-border-color: var(--tp-border);
  --bs-card-border-radius: 0.75rem;
  --bs-card-inner-border-radius: calc(0.75rem - 1px);
}

.card-accent {
  border-top: 3px solid var(--tp-red);
}

/* ---------------------------------------------------------------------
   Application layout: sidebar + header + content  (SRS UI-013 to UI-017)
   --------------------------------------------------------------------- */
.app-body {
  background-color: var(--tp-page-bg);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-content {
  flex: 1 0 auto;
  padding: 1.5rem;
}

/* Sidebar: a slide-in drawer on small screens, fixed column on desktop. */
.app-sidebar-panel {
  --bs-offcanvas-width: 280px;
  --bs-offcanvas-bg: var(--tp-charcoal);
  --bs-offcanvas-color: var(--tp-sidebar-text);
}

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

.app-sidebar .offcanvas-body {
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
}

@media (min-width: 992px) {
  .app-sidebar {
    flex: 0 0 var(--tp-sidebar-width);
    width: var(--tp-sidebar-width);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--tp-charcoal);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background-color: var(--tp-red);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-name {
  font-weight: 700;
  line-height: 1.15;
  color: #fff;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--tp-sidebar-text);
}

/* Official logo (decision D-054). */
.brand-logo {
  height: 42px;
  width: auto;
  flex-shrink: 0;
}

.brand-sub-logo {
  line-height: 1.2;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  padding-left: 0.75rem;
}

.brand-on-light .brand-sub-logo {
  border-left-color: var(--tp-border);
}

/* Brand shown on a light background (e.g. the sign-in card). */
.brand-on-light .brand-name {
  color: var(--tp-charcoal);
}

.brand-on-light .brand-sub {
  color: #6c757d;
}

.sidebar-section {
  padding: 1.25rem 0.85rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #868e96;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  font-weight: 500;
  color: var(--tp-sidebar-text);
}

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

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus-visible {
  background-color: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background-color: var(--tp-red);
  color: #fff;
}

/* Top header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--tp-header-height);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  background-color: #fff;
  border-bottom: 1px solid var(--tp-border);
}

.app-header .page-title {
  flex-grow: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tp-charcoal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  font-size: 1.5rem;
  color: var(--tp-charcoal);
}

.header-icon-btn:hover {
  background-color: #f1f2f4;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.25rem 0.5rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--tp-charcoal);
}

.user-menu-toggle:hover {
  background-color: #f1f2f4;
}

.avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--tp-charcoal);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------------------------------------------------------------------
   Vehicle images
   --------------------------------------------------------------------- */
.thumb-cell {
  width: 76px;
}

.vehicle-thumb {
  width: 64px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  border-radius: 0.375rem;
  background-color: #eef0f2;
  color: #adb5bd;
}

.vehicle-thumb-empty {
  font-size: 1.25rem;
}

.vehicle-hero {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 0.5rem;
  background-color: #eef0f2;
}

.vehicle-hero-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #adb5bd;
}

.vehicle-gallery-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid var(--tp-border);
}

/* ---------------------------------------------------------------------
   Booking calendar  (SRS FR-BOOK-017, UI-044, UI-049)
   --------------------------------------------------------------------- */
.cal-grid th,
.cal-grid td {
  min-width: 150px;
  vertical-align: top;
}

.cal-grid .cal-vehicle-col {
  min-width: 140px;
  background-color: #fafbfc;
}

.cal-month td {
  width: 14.28%;
  min-width: 110px;
  height: 110px;
  vertical-align: top;
}

.cal-outside {
  background-color: #f6f7f8;
  color: #adb5bd;
}

.cal-today {
  background-color: var(--tp-red-subtle) !important;
}

.cal-day-number {
  display: inline-block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

.cal-free {
  font-size: 0.8rem;
  color: #198754;
}

.booking-chip {
  display: block;
  margin-bottom: 0.25rem;
  padding: 0.25rem 0.4rem;
  border-left: 3px solid var(--tp-red);
  border-radius: 0.25rem;
  background-color: #f8eeef;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--tp-charcoal);
  text-decoration: none;
}

.booking-chip:hover {
  background-color: #f1dfe1;
  color: var(--tp-charcoal);
}

.booking-chip-time {
  display: block;
  font-weight: 600;
}

.booking-chip-owner {
  display: block;
  color: #555b61;
}

.booking-chip-cancelled {
  border-left-color: #adb5bd;
  background-color: #f1f3f5;
  color: #868e96;
  text-decoration: line-through;
}

/* ---------------------------------------------------------------------
   Small screens: touch-friendly sizes  (SRS UI-018, UI-023)
   --------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .btn:not(.btn-sm):not(.btn-close),
  .form-control:not(.form-control-sm),
  .form-select:not(.form-select-sm) {
    min-height: 44px;
  }
}

@media (max-width: 575.98px) {
  .app-content {
    padding: 1rem;
  }

  .app-header {
    padding: 0 0.75rem;
  }
}

/* ---------------------------------------------------------------------
   Sign-in page
   --------------------------------------------------------------------- */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--tp-charcoal) 0%, #1a1d20 60%, var(--tp-red-active) 140%);
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  border: 0;
  border-top: 4px solid var(--tp-red);
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.35);
}

.auth-footer {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

/* ---------------------------------------------------------------------
   Notification bell (SRS 5.14)
   --------------------------------------------------------------------- */
.notification-count {
  font-size: 0.65rem;
  margin-top: 0.55rem;
  margin-left: -0.6rem;
}

/* ---------------------------------------------------------------------
   QR code page and printable poster (SRS 5.15)
   --------------------------------------------------------------------- */
.qr-preview {
  width: 100%;
  max-width: 280px;
}

.qr-poster-body {
  background-color: #fff;
}

.qr-poster {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.qr-poster-title {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--tp-charcoal);
}

.qr-poster-lead {
  font-size: 1.15rem;
  color: #555;
}

.qr-poster-code {
  width: 90mm;
  max-width: 100%;
  margin: 1rem auto;
  display: block;
}

.qr-poster-url {
  font-size: 1rem;
  font-weight: 600;
  word-break: break-all;
}

.qr-poster-note {
  color: #555;
}

@media print {
  @page {
    size: A4;
    margin: 15mm;
  }
  .qr-poster {
    padding: 0;
  }
}

/* ---------------------------------------------------------------------
   Dashboard (SRS 5.2)
   --------------------------------------------------------------------- */
.kpi-card .card-body {
  padding: 1rem 1.1rem;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #6c757d;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0.25rem;
  color: var(--tp-charcoal);
  word-break: break-word;
}

.kpi-note {
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 0.15rem;
}

.chart-box {
  position: relative;
  height: 260px;
}

.alert-tile {
  min-width: 110px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--tp-border);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  color: var(--tp-charcoal);
}

.alert-tile:hover {
  background-color: #f8f9fa;
}

.alert-tile-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.alert-tile-label {
  font-size: 0.85rem;
  color: #6c757d;
}

/* ---------------------------------------------------------------------
   Printing any page: only the content, never the menu or header.
   --------------------------------------------------------------------- */
@media print {
  .app-sidebar,
  .app-header,
  .app-content > .alert {
    display: none !important;
  }
  body,
  .app-content {
    background: #fff !important;
    padding: 0 !important;
  }
}

/* ---------------------------------------------------------------------
   Installable app messages: offline, connection restored, update (D-055)
   --------------------------------------------------------------------- */
.pwa-banner {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 1090;
  width: min(640px, calc(100% - 1.5rem));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background-color: var(--tp-charcoal);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25);
}

.pwa-banner[hidden] {
  display: none;
}

.pwa-banner-warning {
  background-color: var(--tp-red);
}

@media print {
  .pwa-banner {
    display: none !important;
  }
}
