/* Engineer Portal V2 - responsive shell switching */

.tp-v2-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.tp-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tp-topbar-h);
  background: var(--tp-card);
  border-bottom: 1px solid var(--tp-border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 1030;
  gap: 1rem;
}

.tp-topbar-brand {
  font-weight: 700;
  color: var(--tp-primary-dark);
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-topbar-breadcrumb {
  display: none;
  font-size: 0.875rem;
  color: var(--tp-text-muted);
}

.tp-topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tp-topbar-user {
  display: none;
  font-size: 0.875rem;
  color: var(--tp-text);
}

/* Sidebar - overlay on mobile, fixed on tablet+ */
.tp-sidebar {
  display: none;
  position: fixed;
  top: var(--tp-topbar-h);
  left: 0;
  bottom: 0;
  width: var(--tp-sidebar-w-tablet);
  background: var(--tp-primary-dark);
  color: #fff;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1040;
  transition: width 0.2s ease, transform 0.25s ease;
}

.tp-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1035;
}

.tp-sidebar-backdrop.is-visible {
  display: block;
}

.tp-sidebar.collapsed {
  width: var(--tp-sidebar-w-collapsed);
}

.tp-sidebar.collapsed .tp-sidebar-profile .name,
.tp-sidebar.collapsed .tp-sidebar-nav a span {
  display: none;
}

.tp-sidebar.collapsed .tp-sidebar-profile {
  padding: 0.85rem 0.35rem;
}

.tp-sidebar.collapsed .tp-sidebar-profile img {
  width: 44px;
  height: 44px;
  margin-bottom: 0;
}

.tp-sidebar.collapsed .tp-sidebar-nav a {
  justify-content: center;
  padding: 0.75rem 0.5rem;
  gap: 0;
}

.tp-sidebar.collapsed .tp-sidebar-nav a.active {
  border-left: none;
  border-right: 3px solid var(--tp-primary-light);
}

.tp-sidebar.collapsed .tp-sidebar-footer {
  padding: 0.75rem 0.35rem;
}

.tp-sidebar.collapsed .tp-sidebar-footer .tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem;
  font-size: 0;
  line-height: 1;
}

.tp-sidebar.collapsed .tp-sidebar-footer .tp-btn i {
  font-size: 1.1rem;
  margin: 0;
}

.tp-sidebar-profile {
  padding: 1.25rem 1rem;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.tp-sidebar-profile img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.5rem;
}

.tp-sidebar-profile .name {
  font-weight: 600;
  font-size: 0.875rem;
}

.tp-sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0.75rem 0;
}

.tp-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.85);
  font-size: 0.9375rem;
  min-height: 44px;
  transition: background 0.15s;
}

.tp-sidebar-nav a:hover,
.tp-sidebar-nav a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.tp-sidebar-nav a.active {
  border-left: 3px solid var(--tp-primary-light);
}

.tp-sidebar-nav .badge {
  margin-left: auto;
  background: var(--tp-accent);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
}

.tp-sidebar-footer {
  padding: 1rem;
  margin-top: auto;
}

.tp-sidebar-footer .tp-btn {
  width: 100%;
  background: var(--tp-accent);
  color: #fff;
}

/* Main content */
.tp-main {
  flex: 1;
    margin-top: var(--tp-topbar-h);
    margin-left: 0;
    padding: 0.75rem;
    padding-bottom: calc(var(--tp-bottom-nav-offset) + 0.5rem + env(safe-area-inset-bottom, 0px));
  transition: margin-left 0.2s ease, padding-bottom 0.22s ease;
}

/* Bottom nav - compact icon bar (mobile only) */
.tp-bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tp-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 0.25rem env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--tp-border);
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1030;
  transform: translateY(0);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

body.tp-v2.tp-bottom-nav-hidden {
  --tp-bottom-nav-offset: 0px;
}

body.tp-v2.tp-bottom-nav-hidden .tp-bottom-nav {
  transform: translateY(100%);
  box-shadow: none;
}

/* View Appointment (and similar): permanently hide bottom Appointments/Timeline nav for space */
body.tp-v2.tp-hide-bottom-nav {
  --tp-bottom-nav-offset: 0px;
}

body.tp-v2.tp-hide-bottom-nav .tp-bottom-nav {
  display: none !important;
}

.tp-bottom-nav a {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  margin: 0.2rem 0.1rem;
  min-height: 0;
  padding: 0.25rem 0.15rem 0.2rem;
  height: calc(var(--tp-bottom-nav-h) - 0.4rem);
  color: var(--tp-text-muted);
  text-decoration: none;
  border-radius: 10px;
  transition: color 0.15s ease, background 0.15s ease;
  min-width: 0;
}

.tp-bottom-nav a.active {
  color: var(--tp-primary);
  background: rgba(13, 148, 136, 0.1);
}

.tp-bottom-nav a svg,
.tp-bottom-nav a i {
  font-size: 1.1875rem;
  line-height: 1;
  flex-shrink: 0;
}

.tp-bottom-nav-label {
  display: block;
  font-size: 0.5625rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}

/* Split pane */
.tp-split-pane {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tp-split-pane-list {
  flex: 1;
}

.tp-split-pane-detail {
  display: none;
  flex: 1;
}

/* GridView - fill viewport so only the list scrolls */
body.tp-v2.tp-grid-body {
  overflow: hidden;
  height: var(--tp-viewport-h);
}

body.tp-v2.tp-grid-body .tp-v2-app {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.tp-v2.tp-grid-body .tp-main,
.tp-main:has(.tp-page-grid) {
  display: flex;
  flex-direction: column;
  height: calc(var(--tp-viewport-h) - var(--tp-topbar-h) - var(--tp-bottom-nav-offset) - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  box-sizing: border-box;
  padding-bottom: 0.5rem;
}

body.tp-v2.tp-grid-body .tp-page-grid,
.tp-main:has(.tp-page-grid) .tp-page-grid {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body.tp-v2.tp-grid-body .tp-page-header,
.tp-main:has(.tp-page-grid) .tp-page-header {
  flex-shrink: 0;
  margin-bottom: 0.75rem;
}

body.tp-v2.tp-grid-body .tp-split-pane,
.tp-main:has(.tp-page-grid) .tp-split-pane {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  height: 100%;
}

body.tp-v2.tp-grid-body .tp-split-pane-list,
.tp-main:has(.tp-page-grid) .tp-split-pane-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

@media (max-width: 767px) {
  body.tp-v2.tp-grid-body {
    height: var(--tp-viewport-h-min);
    min-height: -webkit-fill-available;
  }

  body.tp-v2.tp-grid-body .tp-main,
  .tp-main:has(.tp-page-grid) {
    padding-bottom: 0;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    height: calc(var(--tp-viewport-h-min) - var(--tp-bottom-nav-offset) - env(safe-area-inset-bottom, 0px));
    max-height: calc(var(--tp-viewport-h-min) - var(--tp-bottom-nav-offset) - env(safe-area-inset-bottom, 0px));
    transition: height 0.22s ease, max-height 0.22s ease;
    overflow-x: hidden;
  }
}

/* Tablet breakpoint */
@media (min-width: 768px) {
  .tp-bottom-nav {
    display: none;
  }

  .tp-main {
    padding-bottom: 1rem;
    margin-left: var(--tp-sidebar-w-tablet);
  }

  .tp-sidebar.collapsed ~ .tp-main {
    margin-left: var(--tp-sidebar-w-collapsed);
  }

  .tp-sidebar {
    display: flex;
    flex-direction: column;
    transform: none;
  }

  .tp-sidebar-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: var(--tp-primary-dark);
    text-decoration: none;
  }

  .tp-topbar-breadcrumb {
    display: block;
  }

  .tp-login-brand {
    display: flex;
    flex: 1;
  }

  .tp-login-form-area {
    flex: 1;
  }

  .tp-login-mobile-header {
    display: none;
  }

  body.tp-v2.tp-grid-body .tp-main,
  .tp-main:has(.tp-page-grid) {
    height: calc(100vh - var(--tp-topbar-h));
    padding-bottom: 0.5rem;
  }

  .tp-split-pane {
    flex-direction: row;
    min-height: 0;
    height: 100%;
  }

  .tp-split-pane-list {
    flex: 0 0 72%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    height: 100%;
    max-height: none;
  }

  .tp-split-pane-detail {
    display: block;
    flex: 0 0 28%;
    overflow-y: auto;
    min-height: 0;
    max-height: none;
    height: 100%;
  }

  .tp-topbar-user {
    display: block;
  }
}

/* Desktop breakpoint */
@media (min-width: 1200px) {
  .tp-sidebar {
    width: var(--tp-sidebar-w-desktop);
  }

  .tp-main {
    margin-left: var(--tp-sidebar-w-desktop);
    padding: 1rem 1.5rem;
  }

  .tp-sidebar.collapsed ~ .tp-main {
    margin-left: var(--tp-sidebar-w-collapsed);
  }

  .tp-split-pane-list {
    flex: 0 0 78%;
  }

  .tp-split-pane-detail {
    flex: 0 0 22%;
  }

  .tp-page-title {
    font-size: 1.75rem;
  }
}

/* Mobile - hide top bar (bottom nav + More menu); sidebar full-height overlay */
@media (max-width: 767px) {
  .tp-topbar {
    display: none !important;
  }

  .tp-main {
    margin-top: 0;
    padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
  }

  .tp-sidebar {
    display: flex;
    flex-direction: column;
    top: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }

  .tp-sidebar.is-open {
    transform: translateX(0);
  }

  .tp-sidebar-toggle {
    display: none !important;
  }

  body.sidebar-mobile-open {
    overflow: hidden;
  }

  .tp-login-split {
    flex-direction: column;
  }

  .tp-login-form-area {
    flex: 1;
    align-items: flex-start;
    padding-top: 0;
  }

  .tp-login-card {
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    margin-top: -1rem;
    min-height: 60vh;
  }
}

/* Form factor data attributes */
body[data-form-factor="mobile"] .tp-split-pane-detail {
  display: none !important;
}

body[data-form-factor="desktop"] .tp-sidebar-toggle {
  display: none;
}

/* iOS Safari auto-zooms focused text inputs below 16px — keep those at 16px on mobile */
@media (max-width: 767.98px) {
  body.tp-v2 input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
  body.tp-v2 textarea,
  body.tp-v2 input.form-control,
  body.tp-v2 textarea.form-control,
  body.tp-v2 .tp-form-control:not(select),
  body.tp-v2 .dx-texteditor-input {
    font-size: 16px !important;
  }

  /* Native selects — compact size to match labels (no iOS focus zoom on select) */
  body.tp-v2 select,
  body.tp-v2 select.form-control {
    font-size: var(--tp-font-size-sm, 0.875rem) !important;
    line-height: 1.25;
  }
}
