/* ============================================================================
   ZONE DETAIL PANEL
   ============================================================================
   Right-side overlay panel showing zone details and management.
   Supports both list and detail views.
   Hidden on mobile devices.
   ============================================================================ */

/* Panel Container */
.zone-detail-panel {
  position: fixed;
  top: calc(var(--header-height) + var(--navbar-height) + 20px);
  right: 20px;
  bottom: 20px;
  width: 380px;
  max-width: 25vw;
  min-width: 320px;
  background: var(--background);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.zone-detail-panel.hidden {
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
}

/* Hide on mobile */
@media (max-width: 1024px) {
  .zone-detail-panel {
    display: none !important;
  }
}

/* Panel Header */
.zone-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: white;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.zone-panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-panel-header h3 i {
  font-size: 16px;
  opacity: 0.9;
  flex-shrink: 0;
}

.zone-panel-back {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.zone-panel-back:hover {
  background: rgba(255, 255, 255, 0.15);
}

.zone-panel-back.hidden {
  display: none;
}

.zone-panel-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.zone-panel-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Panel Content (Scrollable) */
.zone-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Loading State */
.zone-panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
  color: var(--muted-foreground);
}

.zone-panel-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.zone-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 16px;
  color: var(--muted-foreground);
  text-align: center;
}

.zone-panel-empty i {
  font-size: 48px;
  opacity: 0.3;
}

.zone-panel-empty p {
  margin: 0;
  font-size: 14px;
}

/* Error State */
.zone-panel-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 16px;
  color: var(--destructive);
  text-align: center;
}

.zone-panel-error i {
  font-size: 48px;
  opacity: 0.5;
}

/* ============================================================================
   LIST VIEW
   ============================================================================ */

.zone-list-actions {
  margin-bottom: 12px;
}

.zone-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Zone Card */
.zone-card {
  padding: 12px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.zone-card:hover {
  background: var(--accent);
  border-color: var(--primary);
  transform: translateX(-2px);
}

.zone-card.uncovered {
  border-color: var(--muted-foreground);
  opacity: 0.7;
}

.zone-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.zone-card-color {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px dashed var(--border);
  flex-shrink: 0;
}

.zone-card-info {
  flex: 1;
  min-width: 0;
}

.zone-card-info h4 {
  margin: 0 0 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-cluster-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
}

.zone-uncovered-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
}

.zone-visibility-toggle {
  background: none;
  border: none;
  color: var(--foreground);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.zone-visibility-toggle:hover {
  background: var(--muted);
}

/* ============================================================================
   DETAIL VIEW
   ============================================================================ */

.zone-detail {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Zone Info Section */
.zone-detail-info {
  text-align: center;
}

.zone-detail-color {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  border-radius: 8px;
}

.zone-detail-info h2 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground);
}

.zone-description {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.zone-detail-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Section Headers */
.zone-assignment-section h3,
.zone-assign-section h3,
.zone-history-section h3 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  display: flex;
  align-items: center;
  gap: 8px;
}

.zone-assignment-section h3 i,
.zone-assign-section h3 i,
.zone-history-section h3 i {
  font-size: 14px;
  opacity: 0.7;
}

/* Current Assignment */
.zone-uncovered-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--muted);
  border-radius: 6px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.zone-uncovered-message i {
  font-size: 18px;
  opacity: 0.5;
}

.zone-current-assignment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--accent);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.assigned-cluster-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assigned-cluster-info .cluster-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

.assigned-cluster-info .assigned-time {
  font-size: 11px;
  color: var(--muted-foreground);
}

/* Cluster Assignment Section */
#cluster-assignment-container {
  min-height: 60px;
}

.cluster-assignment-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 8px;
  color: var(--muted-foreground);
}

.cluster-assignment-loading .spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.no-clusters-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--muted);
  border-radius: 6px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.cluster-assignment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Cluster Group */
.cluster-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.cluster-group-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cluster-group-header.recommended {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.cluster-group-header.in-zone-unavailable {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
}

.cluster-group-header.other {
  background: var(--muted);
  color: var(--muted-foreground);
}

/* Cluster Option */
.cluster-option {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.cluster-option:last-child {
  border-bottom: none;
}

.cluster-option:hover {
  background: var(--accent);
}

.cluster-option.recommended {
  background: rgba(34, 197, 94, 0.05);
}

.cluster-option.unavailable {
  opacity: 0.6;
}

.cluster-option-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.cluster-option-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster-badge {
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  white-space: nowrap;
}

.cluster-badge.in-zone {
  background: var(--primary);
  color: white;
}

.cluster-status {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
  white-space: nowrap;
}

.cluster-status.available {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.cluster-status.busy {
  background: rgba(251, 191, 36, 0.15);
  color: #d97706;
}

/* ============================================================================
   ASSIGNMENT HISTORY
   ============================================================================ */

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  color: var(--muted-foreground);
  text-align: center;
}

.history-empty i {
  font-size: 32px;
  opacity: 0.3;
}

.history-empty p {
  margin: 0;
  font-size: 13px;
}

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.history-entry {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 16px;
}

.history-entry:last-child {
  padding-bottom: 0;
}

.history-entry:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.history-entry-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--background);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}

.history-entry-content {
  flex: 1;
  min-width: 0;
}

.history-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.history-cluster-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-duration {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.history-entry-time {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-bottom: 2px;
}

.history-entry-by {
  font-size: 11px;
  color: var(--muted-foreground);
  font-style: italic;
}

/* ============================================================================
   SCROLLBAR STYLING
   ============================================================================ */

.zone-panel-content::-webkit-scrollbar {
  width: 6px;
}

.zone-panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.zone-panel-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.zone-panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}
