/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: #0b1120;
  color: #e2e8f0;
  min-height: 100vh;
}

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

/* SIDEBAR STYLING */
.app-sidebar {
  width: 260px;
  background: #0f172a;
  border-right: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #1e293b;
}

.brand-icon {
  font-size: 26px;
  background: #1e293b;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
}

.brand-text h2 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #f8fafc;
}

.brand-text small {
  font-size: 10px;
  color: #94a3b8;
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.8px;
  padding: 12px 10px 4px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: #1e293b;
  color: #f1f5f9;
}

.nav-item.active {
  background: #1e3a8a;
  color: #93c5fd;
  border: 1px solid #2563eb;
}

.nav-badge {
  margin-left: auto;
  background: #1e293b;
  color: #38bdf8;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

.nav-arrow {
  margin-left: auto;
  font-size: 11px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #1e293b;
  font-size: 11px;
}

.role-pill {
  display: inline-block;
  background: #1e3a8a;
  color: #93c5fd;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.sidebar-footer small {
  display: block;
  color: #64748b;
  line-height: 1.3;
}

.badge-internal-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #312e81;
  color: #c7d2fe;
  border: 1px solid #4338ca;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.content-header {
  background: #111827;
  border-bottom: 1px solid #1f2937;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-breadcrumb {
  font-size: 13px;
  color: #94a3b8;
}

.header-breadcrumb strong {
  color: #f8fafc;
}

/* View Panels */
.view-panel {
  display: none;
  padding: 24px;
}

.view-panel.active {
  display: block;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 14px;
}

.view-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: #f8fafc;
}

.view-header p {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary { background: #2563eb; color: #ffffff; }
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary { background: #334155; color: #e2e8f0; }
.btn-secondary:hover { background: #475569; }

.btn-outline { background: transparent; border: 1px solid #475569; color: #cbd5e1; }
.btn-outline:hover { background: #1e293b; border-color: #64748b; }

.btn-sm { padding: 4px 10px; font-size: 11px; }

/* SPLIT CONTAINER & RIGHTBAR */
.expeditions-split-container {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.expeditions-table-column {
  flex: 1;
  min-width: 0;
}

.data-table tr.is-active-row td {
  background: rgba(37, 99, 235, 0.14) !important;
}

.data-table tr.is-active-row td:first-child {
  border-left: 3px solid #38bdf8 !important;
}

.data-table tr {
  cursor: pointer;
}

/* APP RIGHTBAR */
.app-rightbar {
  width: 420px;
  flex-shrink: 0;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
}

.rightbar-header {
  padding: 14px 18px;
  background: #111827;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.rightbar-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rightbar-header-title .rb-icon {
  font-size: 20px;
  background: #1e293b;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #334155;
}

.rightbar-header-title h3 {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
}

.rightbar-header-title small {
  font-size: 10px;
  color: #38bdf8;
  font-family: monospace;
}

.rightbar-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rb-section {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rb-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 8px;
}

.rb-trip-card .rb-trip-id {
  display: inline-block;
  background: #1e3a8a;
  color: #93c5fd;
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.rb-trip-card .rb-trip-title {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 10px;
}

.rb-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 11px;
}

.rb-detail-item {
  background: #0b1120;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rb-detail-item .rb-label {
  color: #64748b;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.rb-detail-item strong {
  color: #e2e8f0;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rb-detail-item.full-width {
  grid-column: 1 / -1;
}

.rb-engine-display {
  display: flex;
  justify-content: center;
}

.rb-btn-power {
  width: 100%;
}

.rb-btn-reset {
  width: 100%;
  justify-content: center;
}

.rb-speed-box {
  margin-left: 0;
  width: 100%;
  justify-content: space-between;
}

.rb-fault-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 1200px) {
  .expeditions-split-container {
    flex-direction: column;
  }
  .app-rightbar {
    width: 100%;
    position: static;
    max-height: none;
  }
}

/* Active Running Trip Banner */
.active-trip-banner {
  background: #0d1527;
  border: 2px solid #2563eb;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.trip-banner-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.tag-live {
  display: inline-block;
  background: #1e3a8a;
  color: #60a5fa;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.trip-id-block h3 {
  font-size: 16px;
  color: #f8fafc;
  font-weight: 700;
  margin-bottom: 4px;
}

.trip-meta-sub {
  font-size: 12px;
  color: #94a3b8;
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
}

.engine-badge.engine-on {
  background: #064e3b;
  color: #34d399;
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.engine-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.engine-badge.engine-on .engine-dot {
  animation: pulse-dot 1.2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.lifecycle-action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 12px;
}

.btn-engine-power {
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.btn-start {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
}

.btn-start:hover { background: linear-gradient(135deg, #059669, #047857); }

.btn-stop {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
}

.btn-stop:hover { background: linear-gradient(135deg, #dc2626, #b91c1c); }

.power-icon { font-size: 20px; }

.btn-engine-power strong {
  display: block;
  font-size: 13px;
}

.btn-engine-power small {
  display: block;
  font-size: 10px;
  opacity: 0.9;
}

.speed-control-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #111827;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #1f2937;
  font-size: 11px;
}

.speed-btn-group {
  display: flex;
  gap: 4px;
}

.speed-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
}

.speed-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
  font-weight: 700;
}

.fault-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fault-strip-label {
  font-size: 11px;
  font-weight: 700;
  color: #fbbf24;
}

.fault-strip-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-fault-toggle {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-fault-toggle:hover {
  background: #334155;
}

.btn-fault-toggle.active-fault {
  background: #7f1d1d;
  color: #fecaca;
  border-color: #ef4444;
}

/* Card & Tables */
.card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 1px solid #1f2937;
  padding-bottom: 10px;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}

.table-filters {
  display: flex;
  gap: 6px;
}

.table-filter-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.table-filter-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.data-table th {
  background: #0f172a;
  color: #94a3b8;
  padding: 10px 14px;
  border-bottom: 1px solid #1e293b;
  font-weight: 600;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #1e293b;
  color: #cbd5e1;
}

.data-table tbody tr:hover {
  background: #162032;
}

/* Table Badges */
.status-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}

.status-pill.running { background: #064e3b; color: #34d399; border: 1px solid #10b981; }
.status-pill.ready { background: #1e3a8a; color: #93c5fd; border: 1px solid #3b82f6; }
.status-pill.completed { background: #334155; color: #94a3b8; }
.status-pill.active-truck { background: #064e3b; color: #34d399; }

/* Vendor Cards Grid */
.vendor-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 1100px) {
  .vendor-cards-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .vendor-cards-grid { grid-template-columns: 1fr; }
}

.vendor-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 14px;
}

.vendor-badge {
  display: inline-block;
  background: #1e293b;
  color: #38bdf8;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.vendor-card h4 {
  font-size: 13px;
  color: #f8fafc;
  margin-bottom: 6px;
}

.vendor-card p {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
  margin-bottom: 10px;
}

.vendor-meta {
  font-size: 10px;
  color: #34d399;
  font-weight: 600;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px 10px;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 12px;
  width: 90%;
  max-width: 740px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

.modal-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: 90vh;
  overflow: hidden;
}

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

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #1f2937;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: #111827;
}

.modal-header h3 { font-size: 15px; font-weight: 700; color: #f8fafc; }

.modal-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.modal-close-btn:hover {
  color: #ffffff;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
}

/* Custom Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: #0f172a;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #1f2937;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #0f172a;
  flex-shrink: 0;
}

/* Form Styles */
.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
}

.col-half { flex: 1; }
.col-3 { flex: 1; }
.full-width { width: 100%; }

.modal-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.5px;
  margin: 12px 0 10px 0;
  padding-bottom: 4px;
}

.sec-badge {
  background: #1e3a8a;
  color: #93c5fd;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid #3b82f6;
  flex-shrink: 0;
}

.rb-trip-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.rb-do-pill {
  display: inline-block;
  background: #064e3b;
  color: #34d399;
  border: 1px solid #059669;
  font-family: monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
}

.form-input, .form-select {
  background: #0f172a;
  border: 1px solid #334155;
  color: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.field-hint { font-size: 10px; color: #64748b; }

.form-divider {
  border: none;
  border-top: 1px solid #1f2937;
  margin: 14px 0;
}

/* Coordinate inputs in Form Modal */
.coord-inputs {
  display: flex;
  gap: 8px;
}

.coord-field {
  display: flex;
  align-items: center;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0 8px;
  flex: 1;
}

.coord-label {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  margin-right: 6px;
  font-family: monospace;
}

.coord-field .form-input {
  border: none;
  background: transparent;
  padding: 8px 0;
  color: #f8fafc;
  font-family: monospace;
  font-size: 12px;
  width: 100%;
}

.coord-field .form-input:focus {
  outline: none;
}

.time-picker-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.radio-cards {
  display: flex;
  gap: 8px;
}

.radio-card {
  flex: 1;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.segment-config-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #0f172a;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #1e293b;
}

.seg-config-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  padding: 4px 6px;
}

.form-select-sm {
  background: #1e293b;
  border: 1px solid #334155;
  color: #f8fafc;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.sensor-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #0f172a;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #1e293b;
  font-size: 11px;
  color: #94a3b8;
}
