/* ==========================================
   電子地圖攝影機巡弋群組功能 (Camera Patrol Group)
   ========================================== */

.patrol-toggle-btn {
  background: rgba(14, 21, 46, 0.5) !important;
  border: 1px solid var(--border-glass) !important;
  padding: 4px 10px !important;
  border-radius: 4px !important;
  margin-left: 10px !important;
  color: rgba(255, 255, 255, 0.8) !important;
  font-size: 12px !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.patrol-toggle-btn:hover {
  border-color: rgba(0, 242, 254, 0.5) !important;
  color: #fff !important;
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

.patrol-toggle-btn.active {
  border-color: var(--primary) !important;
  background: rgba(0, 242, 254, 0.12) !important;
  color: var(--primary) !important;
  box-shadow: 0 0 10px var(--primary-glow);
}

.patrol-active-badge {
  background: #00ff88;
  color: #070b19;
  font-size: 9px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 3px;
  animation: pulse-green 1.5s infinite alternate;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 2px #00ff88; }
  100% { box-shadow: 0 0 8px #00ff88; }
}

/* Patrol Panel styling */
.patrol-panel {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 380px;
  max-height: calc(100% - 30px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: rgba(7, 11, 25, 0.9) !important;
  backdrop-filter: blur(12px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(12px) saturate(180%) !important;
  border: 1.5px solid rgba(0, 242, 254, 0.45) !important;
  border-radius: 12px;
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(0, 242, 254, 0.15),
    inset 0 0 10px rgba(0, 242, 254, 0.08) !important;
  overflow: hidden;
  color: #fff;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.patrol-panel-header {
  padding: 12px 16px;
  background: rgba(14, 21, 46, 0.4);
  border-bottom: 1px solid rgba(0, 242, 254, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.patrol-panel-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 6px var(--primary-glow);
  display: flex;
  align-items: center;
  gap: 8px;
}

.patrol-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.patrol-close-btn:hover {
  color: var(--primary);
}

.patrol-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.patrol-panel-content::-webkit-scrollbar {
  width: 6px;
}
.patrol-panel-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
.patrol-panel-content::-webkit-scrollbar-thumb {
  background: rgba(0, 242, 254, 0.2);
  border-radius: 3px;
}
.patrol-panel-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 242, 254, 0.4);
}

/* Group Action Bar */
.patrol-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.patrol-add-btn {
  background: rgba(0, 242, 254, 0.08);
  border: 1px dashed var(--primary);
  color: var(--primary);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: center;
  transition: all 0.2s;
}

.patrol-add-btn:hover {
  background: rgba(0, 242, 254, 0.15);
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.25);
}

/* Patrol Group Card */
.patrol-group-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.patrol-group-card:hover {
  border-color: rgba(0, 242, 254, 0.3);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.patrol-group-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.patrol-group-title {
  font-weight: 600;
  font-size: 13.5px;
  color: #fff;
}

.patrol-group-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.patrol-group-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.patrol-group-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.patrol-card-btn {
  flex: 1;
  padding: 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ddd;
}

.patrol-card-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.patrol-card-btn.btn-play {
  background: rgba(0, 255, 136, 0.12);
  border-color: rgba(0, 255, 136, 0.3);
  color: #00ff88;
}

.patrol-card-btn.btn-play:hover {
  background: rgba(0, 255, 136, 0.22);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.2);
}

.patrol-card-btn.btn-edit {
  background: rgba(0, 242, 254, 0.1);
  border-color: rgba(0, 242, 254, 0.3);
  color: #00f2fe;
}

.patrol-card-btn.btn-edit:hover {
  background: rgba(0, 242, 254, 0.2);
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

.patrol-card-btn.btn-delete {
  background: rgba(255, 118, 117, 0.1);
  border-color: rgba(255, 118, 117, 0.3);
  color: #ff7675;
}

.patrol-card-btn.btn-delete:hover {
  background: rgba(255, 118, 117, 0.2);
  box-shadow: 0 0 8px rgba(255, 118, 117, 0.2);
}

/* Edit form */
.patrol-edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
}

.patrol-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.patrol-form-group label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}

.patrol-form-group input[type="text"],
.patrol-form-group input[type="number"] {
  background: rgba(14, 21, 46, 0.6);
  border: 1px solid rgba(0, 242, 254, 0.25);
  border-radius: 4px;
  padding: 6px 10px;
  color: #fff;
  font-size: 12px;
  outline: none;
  transition: all 0.2s;
}

.patrol-form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 6px var(--primary-glow);
}

.patrol-search-container {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.patrol-search-results {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(10, 16, 28, 0.95);
  display: flex;
  flex-direction: column;
}

.patrol-search-item {
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.patrol-search-item:hover {
  background: rgba(0, 242, 254, 0.1);
  color: var(--primary);
}

.patrol-search-item.selected-in-group {
  background: rgba(255, 255, 255, 0.05);
  opacity: 0.5;
}

/* Selected cameras list (with reordering) */
.patrol-selected-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 4px;
}

.patrol-selected-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.15);
}

.patrol-selected-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
}

.patrol-item-drag {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow: hidden;
}

.patrol-order-badge {
  background: rgba(0, 242, 254, 0.15);
  color: var(--primary);
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: bold;
  font-size: 9px;
  min-width: 14px;
  text-align: center;
}

.patrol-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #eee;
}

.patrol-item-remove {
  background: transparent;
  border: none;
  color: rgba(255, 118, 117, 0.6);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  transition: color 0.15s;
}

.patrol-item-remove:hover {
  color: #ff7675;
}

.patrol-order-actions {
  display: flex;
  gap: 4px;
  margin-right: 6px;
}

.patrol-order-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 1px 4px;
  font-size: 9px;
  line-height: 1;
  border-radius: 2px;
}

.patrol-order-btn:hover:not(:disabled) {
  color: var(--primary);
  border-color: rgba(0, 242, 254, 0.3);
}

.patrol-order-btn:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

.patrol-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.patrol-form-btn {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.patrol-form-btn.btn-save {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #070b19;
}

.patrol-form-btn.btn-save:hover {
  box-shadow: 0 0 12px var(--primary-glow);
  filter: brightness(1.1);
}

.patrol-form-btn.btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
}

.patrol-form-btn.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Empty groups state */
.patrol-empty-state {
  text-align: center;
  padding: 30px 15px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

/* Patrol execution HUD */
.patrol-hud {
  position: absolute;
  top: 15px;
  left: calc(100% - 500px); /* 巡弋時靠右，與播放視窗完全同寬與對齊 (留 20px 右邊距) */
  z-index: 1001;
  background: rgba(7, 11, 25, 0.6) !important; /* 具備玻璃透明感 (0.6 透明度) */
  backdrop-filter: blur(10px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(10px) saturate(180%) !important;
  border: 1.5px solid rgba(0, 242, 254, 0.45) !important; /* 與播放視窗一致的發光邊框 */
  border-radius: 10px;
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(0, 242, 254, 0.25) !important;
  padding: 6px 12px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.patrol-hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.patrol-hud-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.patrol-hud-status-badge {
  background: rgba(0, 242, 254, 0.12);
  border: 1px solid rgba(0, 242, 254, 0.3);
  color: var(--primary);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: bold;
}

.patrol-hud-counter {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.patrol-hud-cam-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.patrol-hud-cam-name {
  font-weight: 500;
  color: #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.patrol-hud-countdown {
  font-weight: bold;
  color: #00ff88;
  background: rgba(0, 255, 136, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.patrol-hud-controls {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.patrol-hud-btn {
  flex: 1;
  padding: 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
}

.patrol-hud-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.patrol-hud-btn.btn-hud-pause {
  background: rgba(253, 203, 110, 0.12);
  border-color: rgba(253, 203, 110, 0.3);
  color: #fdcb6e;
}
.patrol-hud-btn.btn-hud-pause:hover {
  background: rgba(253, 203, 110, 0.22);
  box-shadow: 0 0 8px rgba(253, 203, 110, 0.2);
}

.patrol-hud-btn.btn-hud-stop {
  background: rgba(255, 118, 117, 0.12);
  border-color: rgba(255, 118, 117, 0.3);
  color: #ff7675;
}
.patrol-hud-btn.btn-hud-stop:hover {
  background: rgba(255, 118, 117, 0.22);
  box-shadow: 0 0 8px rgba(255, 118, 117, 0.2);
}

.patrol-hud-btn.btn-hud-skip {
  background: rgba(0, 242, 254, 0.12);
  border-color: rgba(0, 242, 254, 0.3);
  color: var(--primary);
}
.patrol-hud-btn.btn-hud-skip:hover {
  background: rgba(0, 242, 254, 0.22);
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

/* active patrolling pulse on marker */
.custom-marker-icon.patrolling-active {
  border-color: #00ff88 !important;
  filter: drop-shadow(0 0 10px rgba(0, 255, 136, 0.95)) !important;
}

.custom-marker-icon.patrolling-active .marker-pulse-ring {
  display: block !important;
  border: 3px solid #00ff88 !important;
  box-shadow: 0 0 12px #00ff88 !important;
  animation: marker-pulse-green 1.5s ease-out infinite !important;
}

/* Collapsed Patrol HUD styling */
.patrol-hud-collapsed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
}

.patrol-hud-collapsed-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #eee;
  flex: 1;
  overflow: hidden;
}

.patrol-hud-collapsed-title {
  font-weight: 700;
  color: var(--primary);
  font-family: monospace;
  flex-shrink: 0;
}

.patrol-hud-collapsed-cam {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
  color: #fff;
  opacity: 0.9;
}

.patrol-hud-collapsed-countdown {
  font-weight: bold;
  color: #00ff88;
  background: rgba(0, 255, 136, 0.1);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10.5px;
  flex-shrink: 0;
}

.patrol-hud-collapsed-status {
  font-size: 10px;
  background: rgba(0, 242, 254, 0.12);
  border: 1px solid rgba(0, 242, 254, 0.3);
  color: var(--primary);
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: bold;
  flex-shrink: 0;
}

.patrol-hud-collapsed-status.paused {
  background: rgba(253, 203, 110, 0.12);
  border-color: rgba(253, 203, 110, 0.3);
  color: #fdcb6e;
}

.patrol-hud-collapsed-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.patrol-hud-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #fff;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.15s;
  padding: 0;
}

.patrol-hud-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(0, 242, 254, 0.3);
  color: var(--primary);
  box-shadow: 0 0 6px rgba(0, 242, 254, 0.2);
}

.patrol-hud-icon-btn.stop {
  color: #ff7675;
  border-color: rgba(255, 118, 117, 0.2);
}

.patrol-hud-icon-btn.stop:hover {
  color: #ff7675;
  border-color: rgba(255, 118, 117, 0.4);
  background: rgba(255, 118, 117, 0.15);
  box-shadow: 0 0 6px rgba(255, 118, 117, 0.2);
}

/* Active Patrol Icon styling (Green & Rotating) */
.patrol-icon-active {
  color: #00ff88 !important; /* Vivid green */
  filter: drop-shadow(0 0 5px rgba(0, 255, 136, 0.75)) !important;
}

.patrol-icon-active .patrol-outer-ring {
  animation: spin-clockwise 8s linear infinite !important;
  transform-origin: center !important;
}

@keyframes spin-clockwise {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Integrated header styling */
.patrol-integrated-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

