* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: #2c3e50;
  color: white;
  z-index: 100;
}

.toolbar-group {
  display: flex;
  gap: 0.5rem;
}

.toolbar-info {
  margin-left: auto;
  font-size: 0.9rem;
  color: #bdc3c7;
}

#toolbar button {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 1rem;
  height: 36px;
  border: none;
  border-radius: 4px;
  background: #34495e;
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

#toolbar button:hover:not(:disabled) {
  background: #4a6785;
}

#toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#toolbar button .icon {
  font-size: 1rem;
}

/* Map */
#map {
  flex: 1;
  position: relative;
}

/* Panel */
.panel {
  position: absolute;
  right: 1rem;
  top: 5rem;
  width: 300px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 50;
}

.panel.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
}

.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.panel-content {
  padding: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.panel-actions button {
  flex: 1;
}

.panel-divider {
  height: 1px;
  background: #ddd;
  margin: 1rem 0;
}

/* Buttons */
button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-adhoc {
  background: #9b59b6;
  color: white;
}

.btn-adhoc:hover {
  background: #8e44ad;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #666;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.btn-icon:hover {
  color: #333;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-body {
  padding: 1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid #eee;
}

/* Drawing Overlay */
#drawing-overlay {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
}

#drawing-overlay.hidden {
  display: none;
}

.drawing-hint {
  background: rgba(44, 62, 80, 0.9);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Vehicle Markers */
.vehicle-marker-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.vehicle-icon-wrapper {
  position: relative;
  width: 32px;
  height: 32px;
}

.vehicle-marker {
  width: 32px;
  height: 32px;
  transition: transform 0.1s;
}

.vehicle-marker:hover {
  transform: scale(1.1);
}

.vehicle-marker.selected {
  filter: drop-shadow(0 0 4px #3498db);
}

.vehicle-pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  font-size: 14px;
  color: white;
  pointer-events: none;
}

.vehicle-marker-label {
  background: rgba(44, 62, 80, 0.9);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  margin-top: 2px;
  pointer-events: none;
}

.vehicle-label-name {
  font-weight: 600;
  line-height: 1.3;
}

.vehicle-label-speed {
  font-size: 10px;
  color: #bdc3c7;
  line-height: 1.2;
}

.vehicle-label-street {
  font-size: 9px;
  color: #95a5a6;
  line-height: 1.2;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Vehicle Table Overlay */
.vehicle-table-overlay {
  position: absolute;
  left: 1rem;
  top: 5rem;
  width: 480px;
  max-height: calc(100vh - 7rem);
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.vehicle-table-overlay.minimized .vehicle-table-content {
  display: none;
}

.vehicle-table-overlay.minimized {
  width: auto;
}

.vehicle-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  background: #2c3e50;
  color: white;
  border-radius: 8px 8px 0 0;
}

.vehicle-table-overlay.minimized .vehicle-table-header {
  border-radius: 8px;
  border-bottom: none;
}

.vehicle-table-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.vehicle-table-header .btn-icon {
  color: white;
  font-size: 1.2rem;
}

.vehicle-table-header .btn-icon:hover {
  color: #bdc3c7;
}

.vehicle-table-content {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 12rem);
}

#vehicle-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

#vehicle-table thead {
  background: #f8f9fa;
  position: sticky;
  top: 0;
}

#vehicle-table th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #eee;
}

/* Column widths for fixed table layout */
#vehicle-table th:nth-child(1),
#vehicle-table td:nth-child(1) {
  width: 36px;
  padding: 0.3rem;
  text-align: center;
}

#vehicle-table th:nth-child(2),
#vehicle-table td:nth-child(2) {
  width: 100px;
}

#vehicle-table th:nth-child(3),
#vehicle-table td:nth-child(3) {
  width: 50px;
  text-align: center;
}

#vehicle-table th:nth-child(4),
#vehicle-table td:nth-child(4) {
  width: 85px;
}

/* Street column - takes remaining space, truncate with ellipsis */
#vehicle-table th:nth-child(5),
#vehicle-table td:nth-child(5) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#vehicle-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

#vehicle-table tbody tr:hover {
  background: #f8f9fa;
  cursor: pointer;
}

#vehicle-table tbody tr.selected {
  background: #e3f2fd;
}

.vehicle-table-empty {
  padding: 2rem;
  text-align: center;
  color: #999;
  font-style: italic;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 0.9rem;
}

.status-badge.clickable {
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.status-badge.clickable:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.status-badge.clickable:active {
  transform: scale(0.95);
}

.status-badge.moving {
  background: #d4edda;
  color: #28a745;
}

.status-badge.paused {
  background: #fff3cd;
  color: #d69e00;
}

.status-badge.idle {
  background: #e2e3e5;
  color: #6c757d;
}

/* Edit Button in Table */
.btn-edit-vehicle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.btn-edit-vehicle:hover {
  opacity: 1;
}

/* Waypoint Markers */
.waypoint-marker {
  width: 16px;
  height: 16px;
  background: #e74c3c;
  border: 2px solid white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Context Menu */
.context-menu {
  position: absolute;
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 150;
  min-width: 150px;
}

.context-menu-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.context-menu-item:hover {
  background: #f0f0f0;
}

.context-menu-item:first-child {
  border-radius: 4px 4px 0 0;
}

.context-menu-item:last-child {
  border-radius: 0 0 4px 4px;
}

/* Popup */
.maplibregl-popup-content {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.vehicle-popup {
  font-weight: 500;
}

.vehicle-popup .speed {
  color: #666;
  font-weight: normal;
}

/* Tenant Selector */
.tenant-selector {
  align-items: center;
}

.tenant-selector label {
  font-size: 0.85rem;
  color: #bdc3c7;
}

.tenant-selector select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #4a6785;
  border-radius: 4px;
  background: #34495e;
  color: white;
  font-size: 0.9rem;
  min-width: 180px;
}

.tenant-selector select:focus {
  outline: none;
  border-color: #3498db;
}

#btn-manage-tenants {
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
}

/* Tenant List */
.tenant-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 1rem;
  border: 1px solid #eee;
  border-radius: 4px;
}

.tenant-list:empty::after {
  content: 'Keine Mandanten vorhanden';
  display: block;
  padding: 1rem;
  color: #999;
  text-align: center;
  font-style: italic;
}

.tenant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #eee;
}

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

.tenant-item-info {
  flex: 1;
}

.tenant-item-name {
  font-weight: 500;
}

.tenant-item-id {
  font-size: 0.75rem;
  color: #999;
  font-family: monospace;
}

.tenant-item-actions {
  display: flex;
  gap: 0.25rem;
}

.tenant-item-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Input with Button */
.input-with-button {
  display: flex;
  gap: 0.5rem;
}

.input-with-button input {
  flex: 1;
}

.input-with-button button {
  flex-shrink: 0;
}

/* Help Button */
#btn-help {
  width: 36px;
  font-weight: bold;
  font-size: 1.1rem;
}

/* Help Modal */
.modal-content-large {
  width: 600px;
  max-width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-content-large .modal-body {
  overflow-y: auto;
  flex: 1;
}

.help-content {
  font-size: 0.9rem;
  line-height: 1.5;
}

.help-section {
  margin-bottom: 1.25rem;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: #2c3e50;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.25rem;
}

.help-section p {
  margin: 0;
  color: #555;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.help-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.help-table td:first-child {
  width: 120px;
  color: #333;
}

.help-table td:last-child {
  color: #555;
}

.help-table kbd {
  background: #f4f4f4;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  font-family: monospace;
}
