/* ===== Panel Filters (Search, Direction Chips, Summary) ===== */
.panel-filters {
  padding: 0 20px 8px;
  flex-shrink: 0;
}
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--color-foreground);
  background: var(--color-card);
  transition: border-color 150ms ease;
}

.search-total {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-foreground);
  white-space: nowrap;
}
.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
}
.search-input::placeholder {
  color: var(--color-muted-foreground);
}
.filter-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-bottom: 6px;
  align-items: center;
}
.filter-chip {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  white-space: nowrap;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-muted-foreground);
  cursor: pointer;
  transition: all 120ms ease;
}
.filter-chip:hover {
  border-color: var(--color-foreground);
  color: var(--color-foreground);
}
.filter-chip.active {
  background: var(--color-foreground);
  color: var(--color-card);
  border-color: var(--color-foreground);
}
.orders-summary {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--color-muted-foreground);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 2px;
}
.orders-summary .summary-val {
  font-weight: 600;
  color: var(--color-foreground);
}
.order-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.order-card-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.order-card-direction {
  font-size: 10px;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

/* ===== Panel Tabs (Routes / History) ===== */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-sidebar);
  flex-shrink: 0;
  padding: 0 16px;
  align-items: center;
}

.panel-collapse-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--color-muted-foreground);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color 150ms ease, background 150ms ease;
}

.panel-collapse-btn:hover {
  color: var(--color-primary);
  background: rgba(224, 122, 95, 0.08);
}

.panel-collapse-btn svg {
  transition: transform 200ms ease;
}
.panel-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted-foreground);
  cursor: pointer;
  transition: all 150ms ease;
  display: flex;
  align-items: center;
}
.panel-tab:hover {
  color: var(--color-foreground);
}
.panel-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.panel-tab-content {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.panel-tab-content.active {
  display: flex;
}

/* ===== History Filters ===== */
.history-filters {
  padding: 10px 14px;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-border);
}
.history-filter-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.input-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-family: var(--font-body);
  color: var(--color-foreground);
  background: var(--color-card);
  flex: 1;
  min-width: 0;
  transition: border-color 150ms ease;
}
.input-sm:focus {
  outline: none;
  border-color: var(--color-primary);
}
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238B8178' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ===== History Cards ===== */
.history-card {
  background: var(--color-card);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 6px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: box-shadow 200ms ease;
}

.history-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.history-card.expanded {
  border: 1.5px solid var(--color-primary);
  background: #FFFAF8;
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.history-card-vehicle {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
}

.history-card-date {
  font-size: 11px;
  color: var(--color-muted-foreground);
  margin-bottom: 4px;
}

.history-card-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--color-muted-foreground);
}

.history-card-meta span {
  font-weight: 500;
}

.history-detail-panel {
  margin-bottom: 6px;
}

/* ===== History Status Badges (modifiers only) ===== */
.badge-draft {
  background: rgba(139, 129, 120, 0.1);
  color: var(--color-muted-foreground);
}
.badge-approved {
  background: rgba(91, 154, 139, 0.1);
  color: var(--color-success);
}
.badge-archived {
  background: rgba(124, 111, 171, 0.1);
  color: var(--color-info);
}

/* ===== History Detail (expanded row) ===== */
.history-detail {
  padding: 12px 16px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
}
.history-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}
.history-detail-header span {
  font-size: 12px;
  color: var(--color-muted-foreground);
}
.history-detail-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-outline-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}
.btn-outline-sm:hover {
  background: rgba(224, 122, 95, 0.08);
}
.route-batch-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.history-stops {
  list-style: none;
  padding: 0;
  margin: 0;
}
.history-stop {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}
.history-stop-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.history-stop-tw {
  margin-left: auto;
  font-size: 10px;
  color: var(--color-muted-foreground);
  flex-shrink: 0;
  white-space: nowrap;
}

.history-stop-eta {
  font-size: 10px;
  color: var(--color-primary);
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: 4px;
}

/* ===== Approve Button ===== */
#approve-btn-container {
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.btn-approve {
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--color-primary-foreground);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-approve:hover {
  opacity: 0.9;
}

/* ===== Load More Button ===== */
.btn-load-more {
  width: 100%;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--color-muted-foreground);
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 150ms ease;
  margin: 8px 16px;
}
.btn-load-more:hover {
  color: var(--color-foreground);
  border-color: var(--color-foreground);
}

/* ===== Reassign Modal ===== */
.modal-reassign select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--color-foreground);
  background: var(--color-card);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238B8178' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ===== Mobile Tab Bar ===== */
.mobile-tabs {
  display: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
  .top-bar {
    padding: 8px 12px;
  }
  .top-bar-logo span {
    font-size: 14px;
  }
  .top-bar-info {
    font-size: 12px;
    gap: 8px;
  }
  #top-date {
    display: none;
  }

  .main-content {
    flex-direction: column;
    position: relative;
  }

  .panel {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: none;
  }

  .panel.mobile-active {
    display: flex;
  }

  .map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
  }

  .map-container.mobile-active {
    display: block;
  }

  /* Show map by default on first load */
  .panel-left.mobile-active,
  .panel-right.mobile-active,
  .map-container.mobile-active {
    display: flex;
  }
  .map-container.mobile-active {
    display: block;
  }

  .map-overlay-btn {
    bottom: 74px;
    left: auto;
    right: 16px;
    width: 48px;
    height: 48px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(224, 122, 95, 0.4);
  }

  .map-overlay-btn svg {
    width: 22px;
    height: 22px;
  }

  /* Mobile Tab Bar */
  .mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    z-index: 1000;
    padding: 4px 0;
    padding-bottom: env(safe-area-inset-bottom, 4px);
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    background: none;
    border: none;
    color: var(--color-muted-foreground);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 150ms;
  }

  .mobile-tab.active {
    color: var(--color-primary);
  }

  .mobile-tab svg {
    width: 22px;
    height: 22px;
  }

  /* Adjust app layout for bottom tabs */
  .app-layout {
    padding-bottom: 64px;
  }

  .panel-footer {
    padding-bottom: 8px;
  }

  /* Order cards tighter on mobile */
  .order-card {
    padding: 12px 14px;
  }

  .panel-header {
    padding: 12px 16px 8px;
  }

  .panel-body {
    padding: 0 16px 16px;
  }

  .panel-footer {
    padding: 10px 16px;
  }

  .toast {
    bottom: 80px;
    left: 16px;
    right: 16px;
  }

  .mobile-tab {
    font-size: 10px;
  }

  .panel-tabs {
    padding: 0 8px;
  }

  .panel-tab {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* Mobile help modal */
@media (max-width: 768px) {
  .help-modal-container {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }

  .help-modal-body {
    flex-direction: column;
  }

  .help-nav {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: 0;
    flex-shrink: 0;
  }

  .help-nav-item {
    white-space: nowrap;
    padding: 10px 16px;
    border-left: none;
    border-bottom: 3px solid transparent;
    font-size: 12px;
  }

  .help-nav-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--color-primary);
  }

  .help-content {
    padding: 20px 16px;
  }
}

/* Frozen filter chip */
.filter-chip-frozen {
  border-color: #29b6f6 !important;
}
.filter-chip-frozen.active {
  background: #e1f5fe;
  color: #0277bd;
  border-color: #29b6f6;
}

.filter-chip-tander {
  border-color: #66bb6a !important;
}
.filter-chip-tander.active {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #66bb6a;
}

/* Filter chip separator */
.filter-chip-separator {
  width: 1px;
  background: #ddd;
  margin: 0 4px;
  align-self: stretch;
}

/* ===== Expandable Orders Panel ===== */
.panel-left {
  transition: width 300ms ease;
}

.panel-expand-btn {
  background: none;
  border: none;
  color: var(--color-muted-foreground);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color 150ms ease, background 150ms ease;
  display: flex;
  align-items: center;
  margin-left: auto;
}

.panel-expand-btn:hover {
  color: var(--color-primary);
  background: rgba(224, 122, 95, 0.08);
}

.panel-left.expanded {
  width: 60vw;
}

.panel-left.expanded .orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 300px);
  gap: 6px;
}

.panel-left.expanded .orders-grid .order-card {
  margin-bottom: 0;
  max-width: 300px;
}

/* ===== Direction Toggle ===== */
.direction-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-muted-foreground);
  cursor: pointer;
  transition: all 120ms ease;
  user-select: none;
  white-space: nowrap;
}

.direction-toggle:hover {
  border-color: var(--color-foreground);
  color: var(--color-foreground);
}

.direction-toggle.has-active {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.direction-toggle-arrow {
  transition: transform 200ms ease;
  display: inline-block;
  vertical-align: -1px;
  opacity: 0.5;
}

.direction-toggle:hover .direction-toggle-arrow {
  opacity: 0.8;
}

.direction-toggle.open .direction-toggle-arrow {
  transform: rotate(90deg);
  opacity: 0.8;
}

.direction-chips-collapsible {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.direction-chips-collapsible.open {
  display: flex;
}
