/* ==============================================================================
   Parcel Block Walking Tool - Custom Styles
   ==============================================================================
   Mobile-first responsive design for community organization field work.
   ============================================================================== */

/* -----------------------------------------------------------------------------
   CSS Variables
   ----------------------------------------------------------------------------- */

:root {
  --cpal-teal: #2D9AAD;
  --cpal-orange: #E98816;
  --cpal-gray: #CCCCCC;
  --cpal-dark: #333333;

  --mobile-tab-bar-height: 60px;
  --sidebar-width: 350px;
  --cpal-deep-teal: #006878;
  --cpal-midnight: #004855;
  --stats-overlay-width: 200px;
}

/* -----------------------------------------------------------------------------
   Global Adjustments
   ----------------------------------------------------------------------------- */

html, body {
  height: 100%;
  overflow: hidden;
}

/* page_fillable body is a flex column - ensure it fills viewport */
body.bslib-page-fill {
  display: flex !important;
  flex-direction: column !important;
  height: 100vh !important;
  overflow: hidden;
}

/* -----------------------------------------------------------------------------
   Custom Navbar
   ----------------------------------------------------------------------------- */

.app-navbar {
  height: var(--navbar-height, 56px);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  background: var(--bs-body-bg, #ffffff);
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   App Body - CSS Grid Layout
   ----------------------------------------------------------------------------- */

.app-body {
  display: grid;
  grid-template-columns: 350px 1fr;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.sidebar-panel {
  overflow-y: auto;
  padding: 1rem;
  border-right: 1px solid #dee2e6;
  background: var(--bs-body-bg, #ffffff);
}

.main-content {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Flex chain for tab content to fill main-content on both desktop and mobile */
.main-content > .tabbable {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.main-content .tab-content {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.main-content .tab-pane.active {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* -----------------------------------------------------------------------------
   Header Styles
   ----------------------------------------------------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-header .logo {
  height: 32px;
  width: auto;
}

.app-header .app-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0;
  color: var(--cpal-teal);
}

.header-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.header-user-info .user-name {
  color: var(--cpal-dark);
}

.header-btn {
  border: 1px solid var(--cpal-deep-teal);
  background: transparent;
  color: var(--cpal-deep-teal);
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.header-btn:hover {
  color: #ffffff;
  background: var(--cpal-deep-teal);
  border-color: var(--cpal-deep-teal);
}

.header-title {
  font-weight: 400;
  font-size: 0.675rem;
  text-transform: uppercase;
  letter-spacing: 0.075px;
  width: 10rem;
  white-space: normal;
  word-wrap: break-word;
}

/* Dropdown styling for export menu */
.dropdown-item {
  font-size: 0.875rem;
}

.dropdown-item:active {
  background-color: var(--cpal-teal);
}

/* -----------------------------------------------------------------------------
   Sidebar Styles
   ----------------------------------------------------------------------------- */

.sidebar-section {
  margin-bottom: 0.5rem;
}

.sidebar-heading {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--cpal-dark);
}

.sidebar-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  display: block;
}

/* -----------------------------------------------------------------------------
   Toggle Button Group (Buffer)
   ----------------------------------------------------------------------------- */

.toggle-group {
  display: flex;
  gap: 0;
}

.toggle-group .toggle-btn {
  flex: 1;
  border-radius: 0;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-color: #dee2e6;
  color: #6c757d;
  background: white;
}

.toggle-group .toggle-btn:first-child {
  border-radius: 6px 0 0 6px;
}

.toggle-group .toggle-btn:last-child {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.toggle-group .toggle-btn:hover {
  background-color: #f8f9fa;
  color: var(--cpal-dark);
}

.toggle-group .toggle-btn.active {
  background-color: var(--cpal-teal);
  border-color: var(--cpal-teal);
  color: white;
}

.toggle-group .toggle-btn.active:hover {
  background-color: #268a9a;
}

/* -----------------------------------------------------------------------------
   Filter Pills
   ----------------------------------------------------------------------------- */

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-pill {
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #dee2e6;
  background: white;
  color: #6c757d;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  border-color: var(--cpal-teal);
  color: var(--cpal-teal);
  background: white;
}

.filter-pill.active {
  background-color: var(--cpal-teal);
  border-color: var(--cpal-teal);
  color: white;
}

.filter-pill.active:hover {
  background-color: #268a9a;
  border-color: #268a9a;
}

/* Input styling - prevent overflow */
.sidebar-panel .form-control {
  font-size: 0.9rem;
}

.sidebar-panel .shiny-input-container {
  width: 100% !important;
  max-width: 100% !important;
}

.sidebar-panel .shiny-input-container .form-control {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

/* Radio button styling */
.sidebar-panel .form-check {
  padding-left: 1.75rem;
  margin-bottom: 0.25rem;
}

.sidebar-panel .form-check-input:checked {
  background-color: var(--cpal-teal);
  border-color: var(--cpal-teal);
}

/* -----------------------------------------------------------------------------
   Legend Styles
   ----------------------------------------------------------------------------- */

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   Source Box
   ----------------------------------------------------------------------------- */

.source-box {
  background-color: #f8f9fa;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.8rem;
}

.source-box .source-label {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #6c757d;
}

.source-box p {
  margin: 0;
  color: var(--cpal-dark);
}

/* -----------------------------------------------------------------------------
   Map Container
   ----------------------------------------------------------------------------- */

.map-container {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
}

.map-container .mapboxgl-map {
  height: 100%;
  width: 100%;
}

/* -----------------------------------------------------------------------------
   Stats Overlay
   ----------------------------------------------------------------------------- */

.stats-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  min-width: var(--stats-overlay-width);
}

.stats-content {
  font-size: 0.85rem;
}

.stats-buffer {
  text-align: center;
}

.stats-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.25rem 0;
  border-bottom: 1px solid #eee;
}

.stats-item:last-child {
  border-bottom: none;
}

.stats-value {
  font-weight: 700;
  font-size: 1rem;
}

.stats-label {
  color: #6c757d;
  font-size: 0.75rem;
}

/* -----------------------------------------------------------------------------
   Legend (in stats overlay)
   ----------------------------------------------------------------------------- */

.map-legend-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-item-compact {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--cpal-dark);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   Parcel Details Card
   ----------------------------------------------------------------------------- */

.parcel-details-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 14px;
  border-left: 4px solid var(--cpal-teal);
  min-width: 0;
}

/* Every element in the card must shrink to fit, not overflow.
   The key is making each level of the DOM chain width-aware. */
.parcel-details-card *,
.parcel-details-card *::before,
.parcel-details-card *::after {
  box-sizing: border-box;
}

.parcel-details-card .sidebar-section,
.parcel-details-card .shiny-input-container,
.parcel-details-card .shiny-input-container > div,
.parcel-details-card .selectize-control,
.parcel-details-card .selectize-input,
.parcel-details-card .selectize-dropdown,
.parcel-details-card .form-control,
.parcel-details-card .form-select {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

.parcel-detail-address {
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 10px;
}

.detail-value-large {
  font-size: 1rem;
  font-weight: 600;
  color: var(--cpal-dark);
}

.detail-section {
  padding: 8px 0;
}

.detail-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  margin-bottom: 4px;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.detail-row .detail-value {
  font-weight: 500;
}

.savings-highlight {
  background: rgba(25, 135, 84, 0.1);
  border-radius: 6px;
  padding: 10px !important;
  text-align: center;
}

/* Badge colors */
.bg-cpal-orange {
  background-color: #E86A50 !important;
}

.bg-cpal-teal {
  background-color: #2D9AAD !important;
}

.text-cpal-orange {
  color: #E86A50 !important;
}

/* -----------------------------------------------------------------------------
   Main Tabs (Map/Table)
   ----------------------------------------------------------------------------- */

.nav-underline {
  border-bottom: 1px solid #dee2e6;
  padding: 0 1rem;
  background: var(--bs-body-bg, white);
}

.nav-underline .nav-link {
  color: #6c757d;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.nav-underline .nav-link:hover {
  color: var(--cpal-teal);
}

.nav-underline .nav-link.active {
  color: var(--cpal-teal);
  border-bottom-color: var(--cpal-teal);
}

/* Table view container */
.table-view-container {
  background: white;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

.table-view-container .dataTables_wrapper {
  font-size: 0.875rem;
}

.table-view-container .dataTables_filter input {
  border-radius: 4px;
  padding: 0.375rem 0.75rem;
}

/* -----------------------------------------------------------------------------
   Loading Indicator
   ----------------------------------------------------------------------------- */

.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 24px 32px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* -----------------------------------------------------------------------------
   Parcel List Styles
   ----------------------------------------------------------------------------- */

.list-container {
  height: 100%;
  overflow-y: auto;
  padding: 1rem;
}

.list-header {
  position: sticky;
  top: 0;
  background: var(--bs-body-bg, white);
  padding-bottom: 0.5rem;
  z-index: 5;
}

.parcel-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.parcel-list-item {
  transition: box-shadow 0.2s ease;
}

.parcel-list-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.parcel-address {
  font-size: 0.95rem;
  color: var(--cpal-dark);
}

.parcel-owner {
  font-size: 0.8rem;
}

/* -----------------------------------------------------------------------------
   Parcel Detail Modal
   ----------------------------------------------------------------------------- */

.parcel-detail .section-header {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--cpal-teal);
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.25rem 0;
}

.detail-label {
  font-size: 0.85rem;
}

.detail-value {
  font-size: 0.9rem;
  text-align: right;
}

/* -----------------------------------------------------------------------------
   Mobile Tab Bar
   ----------------------------------------------------------------------------- */

.mobile-tab-bar {
  display: none;  /* Hidden on desktop */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-tab-bar-height);
  background: white;
  border-top: 1px solid #dee2e6;
  z-index: 1000;
  justify-content: space-around;
  align-items: center;
  padding: 0 1rem;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: none !important;
  border: none !important;
  padding: 0.5rem 1rem;
  color: #9BA8AB;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.2s ease;
  box-shadow: none !important;
  outline: none;
}

.tab-bar-item:hover {
  color: var(--cpal-deep-teal);
  background: none !important;
}

.tab-bar-item .fa,
.tab-bar-item .fas,
.tab-bar-item .far {
  font-size: 1.25rem;
}

.tab-bar-item.active {
  color: var(--cpal-deep-teal);
}

.tab-bar-label {
  font-size: 0.7rem;
  font-weight: 500;
}

/* Mobile "View Map" button - hidden on desktop */
.mobile-confirm-btn {
  display: none;
}

/* -----------------------------------------------------------------------------
   Address Suggestions List
   ----------------------------------------------------------------------------- */

.suggestions-list {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  margin-top: -6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 220px;
  overflow-y: auto;
}

.suggestion-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.15s ease;
  display: flex;
  align-items: flex-start;
  line-height: 1.3;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background-color: #f8f9fa;
}

.suggestion-item:active {
  background-color: var(--cpal-teal);
  color: white;
}

.suggestion-item:active .text-muted {
  color: white !important;
}

/* -----------------------------------------------------------------------------
   Current Location Display
   ----------------------------------------------------------------------------- */

.current-location-card {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-left: 4px solid var(--cpal-teal);
  border-radius: 6px;
  padding: 12px 14px;
}

.current-location-card .current-address {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--cpal-dark);
  margin-top: 4px;
  line-height: 1.3;
}

.current-location {
  border-left: 3px solid var(--cpal-teal);
}

/* -----------------------------------------------------------------------------
   Help Modal
   ----------------------------------------------------------------------------- */

.help-content ol {
  padding-left: 1.25rem;
}

.help-content li {
  margin-bottom: 0.75rem;
}

.help-content .accordion-item {
  border-left: 0;
  border-right: 0;
  border-radius: 0 !important;
}

.help-content .accordion-item:first-child {
  border-top: 0;
}

.help-content .accordion-button {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--cpal-teal);
  padding: 0.75rem 0;
  background: transparent;
  box-shadow: none;
}

.help-content .accordion-button:not(.collapsed) {
  color: var(--cpal-teal);
  background: transparent;
}

.help-content .accordion-button::after {
  flex-shrink: 0;
}

.help-content .accordion-body {
  padding: 0 0 0.75rem 0;
  font-size: 0.9rem;
}

.help-content .accordion-body p,
.help-content .accordion-body li {
  line-height: 1.6;
}

.help-content .accordion-body dt {
  color: var(--cpal-teal);
  font-size: 0.9rem;
}

.help-content .accordion-body dd {
  margin-bottom: 0.5rem;
}

/* -----------------------------------------------------------------------------
   Responsive Styles - Mobile
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Show mobile tab bar */
  .mobile-tab-bar {
    display: flex;
  }

  /* Reserve space for fixed-position tab bar at bottom */
  body.bslib-page-fill {
    padding-bottom: var(--mobile-tab-bar-height) !important;
  }

  /* Override grid: stack panels with absolute positioning */
  .app-body {
    display: block !important;
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }

  /* Both panels fill the app-body, layered on top of each other.
     Use visibility + z-index instead of display:none so Mapbox GL
     always has a container with real dimensions to render into. */
  .sidebar-panel,
  .main-content {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    visibility: hidden;
    z-index: 0;
    pointer-events: none;
  }

  .sidebar-panel {
    overflow-y: auto;
    border-right: none;
    padding: 1rem 1.25rem;
  }

  .main-content {
    display: flex !important;
    flex-direction: column;
  }

  .sidebar-panel.mobile-active,
  .main-content.mobile-active {
    visibility: visible;
    z-index: 1;
    pointer-events: auto;
  }

  /* Hide desktop tab nav on mobile (bottom bar replaces it) */
  .nav-underline {
    display: none !important;
  }

  /* Full flex chain: .main-content → .tabbable → .tab-content → .tab-pane → content */
  .main-content > .tabbable {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .main-content .tab-content {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .main-content .tab-pane.active {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Map and table fill available space */
  .map-container {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
  }

  .table-view-container {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: auto !important;
  }

  /* Make touch targets larger on mobile */
  .sidebar-panel .form-control {
    font-size: 1rem;
    padding: 0.75rem;
  }

  .sidebar-panel .btn {
    padding: 0.625rem 1rem;
  }

  /* Stats overlay adjustments */
  .stats-overlay {
    top: 5px;
    left: 5px;
    right: 5px;
    min-width: auto;
    padding: 8px 12px;
  }

  .stats-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .stats-buffer {
    width: 100%;
    margin-bottom: 0.25rem;
  }

  .stats-item {
    flex: 1;
    min-width: 80px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: none;
    border-right: 1px solid #eee;
    padding: 0.25rem 0.5rem;
  }

  .stats-item:last-child {
    border-right: none;
  }

  /* Header adjustments */
  .header-title {
    font-size: 0.6rem;
    width: 7rem;
  }

  .header-user-info .user-name {
    display: none;
  }

  /* Controls fit full width */
  .toggle-group {
    width: 100%;
  }

  .filter-pills {
    width: 100%;
  }

  /* Show "View Map" button on mobile */
  .mobile-confirm-btn {
    display: block;
  }
}

/* -----------------------------------------------------------------------------
   Small Mobile (< 480px)
   ----------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .stats-item {
    min-width: 60px;
  }

  .stats-value {
    font-size: 0.9rem;
  }

  .stats-label {
    font-size: 0.65rem;
  }

  .tab-bar-item {
    padding: 0.5rem 0.75rem;
  }
}

/* -----------------------------------------------------------------------------
   Print Styles
   ----------------------------------------------------------------------------- */

@media print {
  .mobile-tab-bar,
  .stats-overlay,
  .map-loading {
    display: none !important;
  }

  .sidebar-panel {
    display: none !important;
  }
}

/* -----------------------------------------------------------------------------
   Utility Classes
   ----------------------------------------------------------------------------- */

.text-cpal-teal {
  color: var(--cpal-teal) !important;
}

.text-cpal-orange {
  color: var(--cpal-orange) !important;
}

.bg-cpal-teal {
  background-color: var(--cpal-teal) !important;
}

.bg-cpal-orange {
  background-color: var(--cpal-orange) !important;
}

/* -----------------------------------------------------------------------------
   Login Overlay (Full-screen, not a modal)
   ----------------------------------------------------------------------------- */

.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #F8FAFC 0%, #E8F4F6 100%);
}

.login-form-wrapper {
  width: 100%;
  max-width: 380px;
  background: white;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.login-overlay .shiny-input-container {
  width: 100% !important;
}

.login-overlay .shiny-input-container > label.control-label:empty {
  display: none;
}

.login-overlay .shiny-input-container .form-control {
  width: 100% !important;
}

/* -----------------------------------------------------------------------------
   Modal Fixes (input overflow)
   ----------------------------------------------------------------------------- */

.modal-body .form-group.shiny-input-container,
.modal-body .shiny-input-container {
  width: 100% !important;
  max-width: 100% !important;
  margin-bottom: 0;
}

.modal-body .shiny-input-container .form-control,
.modal-body .form-control {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

/* Hide the empty Shiny-generated label when we provide our own */
.modal-body .mb-3 > .shiny-input-container > label.control-label:empty {
  display: none;
}

/* Ensure modal body doesn't overflow */
.modal-body {
  overflow-x: hidden;
}

.modal-content {
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.modal-header {
  background: #004855;
  color: white;
  padding: 1rem 1.5rem;
}

.modal-header .btn-close {
  filter: invert(1);
}

/* -----------------------------------------------------------------------------
   Table View Improvements
   ----------------------------------------------------------------------------- */

.table-header {
  background: white;
  padding: 0.75rem 0;
  border-bottom: 2px solid #006878;
}

.table-header .table-count {
  font-size: 1rem;
  font-weight: 600;
}

.table-view-container .dataTables_wrapper,
.modal-content .dataTables_wrapper {
  font-size: 0.85rem;
  overflow: hidden;
}

.modal-content .dataTables_filter {
  float: left !important;
  text-align: left !important;
}

.table-view-container .dataTables_filter input,
.modal-content .dataTables_filter input {
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  border: 1px solid #CBD5E1;
}

/* Table header */
.table-view-container table.dataTable thead th,
.modal-content table.dataTable thead th {
  background: #004855;
  color: white;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.6rem 0.75rem;
  border-bottom: none;
  white-space: nowrap;
}

.table-view-container table.dataTable thead th:hover,
.modal-content table.dataTable thead th:hover {
  background: #006878;
}

.table-view-container table.dataTable thead .sorting::after,
.table-view-container table.dataTable thead .sorting_asc::after,
.table-view-container table.dataTable thead .sorting_desc::after,
.modal-content table.dataTable thead .sorting::after,
.modal-content table.dataTable thead .sorting_asc::after,
.modal-content table.dataTable thead .sorting_desc::after {
  filter: invert(1);
}

/* Table body */
.table-view-container table.dataTable tbody td,
.modal-content table.dataTable tbody td {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
  font-size: 0.825rem;
  border-bottom: 1px solid #f0f0f0;
}

.table-view-container table.dataTable tbody tr:nth-of-type(odd),
.modal-content table.dataTable tbody tr:nth-of-type(odd) {
  background-color: rgba(45, 154, 173, 0.04);
}

.table-view-container table.dataTable tbody tr:nth-of-type(even),
.modal-content table.dataTable tbody tr:nth-of-type(even) {
  background-color: white;
}

/* Selected row - very light teal (override DT defaults) */
.table-view-container table.dataTable tbody > tr.selected,
.table-view-container table.dataTable tbody > tr.selected > td,
.table-view-container table.dataTable tbody > tr > .selected,
table.dataTable tbody > tr.selected,
table.dataTable tbody > tr.selected > td,
table.dataTable tbody > tr > .selected {
  background-color: rgba(45, 154, 173, 0.1) !important;
  color: inherit !important;
  box-shadow: none !important;
  border-color: #f0f0f0 !important;
}

.table-view-container table.dataTable tbody > tr.selected > td:first-child {
  box-shadow: inset 3px 0 0 var(--cpal-teal) !important;
}

/* Hover */
.table-view-container table.dataTable tbody tr:hover,
.modal-content table.dataTable tbody tr:hover {
  background-color: rgba(0, 104, 120, 0.06) !important;
  cursor: pointer;
}

/* Pagination */
.table-view-container .dataTables_paginate .paginate_button,
.modal-content .dataTables_paginate .paginate_button {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.table-view-container .dataTables_paginate .paginate_button.current,
.modal-content .dataTables_paginate .paginate_button.current {
  background: #006878 !important;
  border-color: #006878 !important;
  color: white !important;
}

.table-view-container .dataTables_info,
.modal-content .dataTables_info {
  font-size: 0.8rem;
  color: #6c757d;
}

.dt-nowrap {
  white-space: nowrap;
}

/* Multi-account modal stat cards */
.multi-account-stat-card {
  flex: 1;
  background: rgba(0, 72, 85, 0.04);
  border-radius: 8px;
  padding: 12px 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.multi-account-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.multi-account-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.multi-account-stat-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

[data-bs-theme="dark"] .multi-account-stat-card {
  background: rgba(139, 203, 216, 0.06);
}

[data-bs-theme="dark"] .multi-account-stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .multi-account-stat-label {
  color: #9BA8AB;
}

.dt-right {
  text-align: right;
}

/* -----------------------------------------------------------------------------
   Mapbox Popup Styling
   ----------------------------------------------------------------------------- */

.mapboxgl-popup-content {
  background: #ffffff;
  color: #1A1A1A;
  border-radius: 8px;
  padding: 10px 12px;
  padding-right: 24px;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  max-width: 260px;
}

.mapboxgl-popup-close-button {
  color: #6c757d;
  font-size: 1rem;
  padding: 2px 6px;
  top: 2px;
  right: 2px;
}

.mapboxgl-popup-close-button:hover {
  color: #1A1A1A;
  background: transparent;
}

/* Shiny notification bars — prevent overlap with content */
.shiny-notification {
  max-width: 350px;
  font-size: 0.85rem;
  padding-right: 28px;
}

.shiny-notification .shiny-notification-close {
  top: 4px;
  right: 4px;
}

/* -----------------------------------------------------------------------------
   Dark Mode
   ----------------------------------------------------------------------------- */

[data-bs-theme="dark"] .login-overlay {
  background: linear-gradient(135deg, #1A1A1A 0%, #002D38 100%);
}

[data-bs-theme="dark"] .login-form-wrapper {
  background: #1e2a30;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .login-form-wrapper h4 {
  color: #e8e8e8;
}

[data-bs-theme="dark"] .login-overlay .form-control {
  background: #253540;
  border-color: #3a4a52;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .login-overlay .form-label {
  color: #9BA8AB;
}

/* Navbar */
[data-bs-theme="dark"] .app-navbar {
  background: var(--bs-body-bg);
  border-bottom-color: #3a4a52;
}

/* Header */
[data-bs-theme="dark"] .header-btn {
  color: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.4);
}

[data-bs-theme="dark"] .header-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.6);
}

[data-bs-theme="dark"] .header-title {
  color: #8BCBD8;
}

/* Sidebar */
[data-bs-theme="dark"] .sidebar-heading {
  color: #e8e8e8;
}

[data-bs-theme="dark"] .toggle-group .toggle-btn {
  background: #1e2a30;
  border-color: #3a4a52;
  color: #9BA8AB;
}

[data-bs-theme="dark"] .toggle-group .toggle-btn:hover {
  background: #2a3a42;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .toggle-group .toggle-btn.active {
  background-color: var(--cpal-teal);
  border-color: var(--cpal-teal);
  color: white;
}

[data-bs-theme="dark"] .filter-pill {
  background: #1e2a30;
  border-color: #3a4a52;
  color: #9BA8AB;
}

[data-bs-theme="dark"] .filter-pill:hover {
  border-color: var(--cpal-teal);
  color: var(--cpal-teal);
  background: #1e2a30;
}

[data-bs-theme="dark"] .filter-pill.active {
  background-color: var(--cpal-teal);
  border-color: var(--cpal-teal);
  color: white;
}

[data-bs-theme="dark"] .source-box {
  background-color: #1e2a30;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .source-box .source-label {
  color: #8BCBD8;
}

[data-bs-theme="dark"] .source-box p {
  color: #e8e8e8;
}

/* Change location button in dark mode */
[data-bs-theme="dark"] .current-location-card .btn-outline-secondary {
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

[data-bs-theme="dark"] .current-location-card .btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.6);
}

[data-bs-theme="dark"] .current-location-card {
  background: linear-gradient(135deg, #1e2a30 0%, #253540 100%);
  border-left-color: #8BCBD8;
}

[data-bs-theme="dark"] .current-location-card .current-address {
  color: #e8e8e8;
}

/* Parcel details in sidebar */
[data-bs-theme="dark"] .parcel-details-card {
  background: #1e2a30;
  border-left-color: #8BCBD8;
}

[data-bs-theme="dark"] .detail-value-large {
  color: #e8e8e8;
}

[data-bs-theme="dark"] .savings-highlight {
  background: rgba(90, 138, 111, 0.15);
}

[data-bs-theme="dark"] .parcel-detail-address {
  border-bottom-color: #3a4a52;
}

/* Map overlay */
[data-bs-theme="dark"] .stats-overlay {
  background: rgba(30, 42, 48, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .stats-value {
  color: #e8e8e8;
}

[data-bs-theme="dark"] .stats-item {
  border-bottom-color: #3a4a52;
}

[data-bs-theme="dark"] .legend-item-compact {
  color: #bbb;
}

/* Table view */
[data-bs-theme="dark"] .table-header {
  background: transparent;
  border-bottom-color: #3a4a52;
}

[data-bs-theme="dark"] .table-view-container {
  background: transparent !important;
}

[data-bs-theme="dark"] .table-view-container table.dataTable,
[data-bs-theme="dark"] .modal-content table.dataTable {
  border-collapse: collapse;
}

[data-bs-theme="dark"] .table-view-container table.dataTable thead th,
[data-bs-theme="dark"] .modal-content table.dataTable thead th {
  background: #002D38;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .table-view-container table.dataTable thead th:hover,
[data-bs-theme="dark"] .modal-content table.dataTable thead th:hover {
  background: #004855;
}

[data-bs-theme="dark"] .table-view-container table.dataTable tbody tr:nth-of-type(odd),
[data-bs-theme="dark"] .modal-content table.dataTable tbody tr:nth-of-type(odd) {
  background-color: rgba(139, 203, 216, 0.04);
}

[data-bs-theme="dark"] .table-view-container table.dataTable tbody tr:nth-of-type(even),
[data-bs-theme="dark"] .modal-content table.dataTable tbody tr:nth-of-type(even) {
  background-color: transparent;
}

[data-bs-theme="dark"] .table-view-container table.dataTable tbody td,
[data-bs-theme="dark"] .modal-content table.dataTable tbody td {
  color: #e8e8e8;
  border-bottom-color: #2a3a42;
}

/* Selected row in dark mode */
[data-bs-theme="dark"] .table-view-container table.dataTable tbody > tr.selected,
[data-bs-theme="dark"] .table-view-container table.dataTable tbody > tr.selected > td,
[data-bs-theme="dark"] .table-view-container table.dataTable tbody > tr > .selected,
[data-bs-theme="dark"] table.dataTable tbody > tr.selected,
[data-bs-theme="dark"] table.dataTable tbody > tr.selected > td,
[data-bs-theme="dark"] table.dataTable tbody > tr > .selected {
  background-color: rgba(139, 203, 216, 0.12) !important;
  color: #e8e8e8 !important;
  box-shadow: none !important;
  border-color: #2a3a42 !important;
}

[data-bs-theme="dark"] .table-view-container table.dataTable tbody > tr.selected > td:first-child {
  box-shadow: inset 3px 0 0 #8BCBD8 !important;
}

[data-bs-theme="dark"] .table-view-container table.dataTable tbody tr:hover,
[data-bs-theme="dark"] .modal-content table.dataTable tbody tr:hover {
  background-color: rgba(139, 203, 216, 0.08) !important;
}

[data-bs-theme="dark"] .table-view-container .dataTables_filter input,
[data-bs-theme="dark"] .modal-content .dataTables_filter input {
  background: #1e2a30;
  border-color: #3a4a52;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .dataTables_info,
[data-bs-theme="dark"] .dataTables_paginate .paginate_button {
  color: #9BA8AB !important;
}

[data-bs-theme="dark"] .dataTables_paginate .paginate_button.current {
  background: #006878 !important;
  border-color: #006878 !important;
  color: white !important;
}

[data-bs-theme="dark"] .dataTables_wrapper {
  background: transparent;
  color: #9BA8AB;
}

[data-bs-theme="dark"] .dataTables_length select,
[data-bs-theme="dark"] .dataTables_filter input {
  background: #1e2a30 !important;
  border-color: #3a4a52 !important;
  color: #e8e8e8 !important;
}

[data-bs-theme="dark"] .table-view-container .btn-outline-secondary {
  color: #9BA8AB;
  border-color: #3a4a52;
}

[data-bs-theme="dark"] .table-view-container .btn-outline-secondary:hover {
  color: #e8e8e8;
  background: #253540;
  border-color: #8BCBD8;
}

/* Modals */
[data-bs-theme="dark"] .modal-content {
  background: #1e2a30;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .modal-header {
  background: #002D38;
}

[data-bs-theme="dark"] .modal-body .form-control {
  background: #253540;
  border-color: #3a4a52;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .modal-body .form-label {
  color: #9BA8AB;
}

/* Sidebar inputs in dark mode */
[data-bs-theme="dark"] .sidebar-panel .form-control {
  background: #1e2a30;
  border-color: #3a4a52;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .sidebar-panel .form-control::placeholder {
  color: #6c757d;
}

[data-bs-theme="dark"] .sidebar-panel .sidebar-label {
  color: #9BA8AB;
}

[data-bs-theme="dark"] .sidebar-panel hr {
  border-color: #3a4a52;
}

/* Suggestions dropdown */
[data-bs-theme="dark"] .suggestions-list {
  background: #1e2a30;
  border-color: #3a4a52;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .suggestion-item {
  border-bottom-color: #2a3a42;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .suggestion-item:hover {
  background-color: #253540;
}

/* Nav tabs */
[data-bs-theme="dark"] .nav-underline {
  border-bottom-color: #3a4a52;
  background: transparent;
}

[data-bs-theme="dark"] .nav-underline .nav-link {
  color: #9BA8AB;
}

[data-bs-theme="dark"] .nav-underline .nav-link.active {
  color: #8BCBD8;
  border-bottom-color: #8BCBD8;
}

/* Remove gray borders on tab panels in dark mode */
[data-bs-theme="dark"] .tab-content,
[data-bs-theme="dark"] .tab-pane,
[data-bs-theme="dark"] .bslib-page-fill,
[data-bs-theme="dark"] .card {
  border-color: #3a4a52 !important;
}

[data-bs-theme="dark"] .sidebar-panel {
  border-right-color: #3a4a52;
  background: var(--bs-body-bg);
}

/* Loading indicator */
[data-bs-theme="dark"] .map-loading {
  background: rgba(30, 42, 48, 0.9);
  color: #e8e8e8;
}

/* Mobile tab bar */
[data-bs-theme="dark"] .mobile-tab-bar {
  background: #1e2a30;
  border-top-color: #3a4a52;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .tab-bar-item {
  color: #6c757d;
}

[data-bs-theme="dark"] .tab-bar-item:hover {
  color: #8BCBD8;
}

[data-bs-theme="dark"] .tab-bar-item.active {
  color: #8BCBD8;
}

/* Dark mode mobile stats overlay */
@media (max-width: 768px) {
  [data-bs-theme="dark"] .stats-item {
    border-right-color: #3a4a52;
  }
}

/* Mapbox popups in dark mode */
[data-bs-theme="dark"] .mapboxgl-popup-content {
  background: #1e2a30;
  color: #e8e8e8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .mapboxgl-popup-close-button {
  color: #9BA8AB;
}

[data-bs-theme="dark"] .mapboxgl-popup-close-button:hover {
  color: #e8e8e8;
}

[data-bs-theme="dark"] .mapboxgl-popup-tip {
  border-top-color: #1e2a30;
}

/* Tab pane background in dark mode - prevent blue/white bleed */
[data-bs-theme="dark"] .tab-pane {
  background: transparent !important;
}

/* ===== Admin Panel ===== */

.admin-table {
  font-size: 0.85rem;
}

.admin-table th {
  background: #004855;
  color: white;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.5rem 0.75rem;
}

.admin-table td {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
}

.admin-actions .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.template-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
}

.template-text {
  font-family: monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  background: white;
  padding: 1rem;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  margin-bottom: 0.75rem;
}

.activity-metric {
  text-align: center;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
}

.activity-metric .metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: #006878;
}

.activity-metric .metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
}

/* Dark mode admin panel */
[data-bs-theme="dark"] .admin-table th {
  background: #002D38;
}

[data-bs-theme="dark"] .template-card {
  background: #1e2a30;
}

[data-bs-theme="dark"] .template-text {
  background: #253540;
  border-color: #3a4a52;
  color: #e8e8e8;
}

[data-bs-theme="dark"] .activity-metric {
  background: #1e2a30;
}

[data-bs-theme="dark"] .activity-metric .metric-value {
  color: #8BCBD8;
}
