/* Panel Toggle Bar */
.panel-toggle-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #f8f9fa;
  border-bottom: 2px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.panel-toggle-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.panel-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: white;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  user-select: none;
}

.panel-toggle-btn:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  transform: translateY(-1px);
}

.panel-toggle-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.panel-toggle-btn .panel-icon {
  font-size: 16px;
  line-height: 1;
}

.panel-toggle-btn .panel-label {
  font-size: 14px;
}

.panel-toggle-btn .panel-indicator {
  font-weight: bold;
  font-size: 14px;
  margin-left: 2px;
}

.panel-toggle-actions {
  display: flex;
  gap: 8px;
}

.btn-reset-layout {
  padding: 8px 16px;
  background: white;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
  transition: all 0.2s ease;
}

.btn-reset-layout:hover {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #d97706;
}

/* Panels Container */
#panels-container {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Panel Wrapper */
.panel-wrapper {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.panel-wrapper:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.panel-wrapper.collapsed {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* Panel Header */
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  border-bottom: 1px solid #e5e7eb;
  user-select: none;
}

.panel-wrapper.collapsed .panel-header {
  border-bottom: none;
}

.panel-drag-handle {
  cursor: grab;
  padding: 4px 8px;
  color: #9ca3af;
  transition: all 0.2s;
  border-radius: 4px;
}

.panel-drag-handle:hover {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.panel-drag-handle:active {
  cursor: grabbing;
  color: #2563eb;
}

.drag-icon {
  font-size: 18px;
  line-height: 1;
  user-select: none;
  font-weight: bold;
  letter-spacing: -2px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.panel-title .panel-icon {
  font-size: 22px;
  line-height: 1;
}

.panel-title .panel-name {
  font-size: 16px;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  gap: 6px;
}

.panel-btn-collapse,
.panel-btn-close {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: #6b7280;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.panel-btn-collapse:hover {
  background: #eff6ff;
  color: #3b82f6;
  border-color: #3b82f6;
  transform: translateY(-1px);
}

.panel-btn-close:hover {
  background: #fef2f2;
  color: #ef4444;
  border-color: #ef4444;
  transform: translateY(-1px);
}

/* Panel Content */
.panel-content {
  padding: 20px;
  transition: all 0.3s ease;
  max-height: none;
  opacity: 1;
  overflow: visible;
}

.panel-wrapper.collapsed .panel-content {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

/* Sortable Drag States */
.panel-ghost {
  opacity: 0.4;
  background: #eff6ff;
  border: 2px dashed #3b82f6;
}

.panel-dragging {
  opacity: 0.9;
  transform: rotate(1deg) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  cursor: grabbing;
  z-index: 1000;
}

/* Drag Active State */
.sortable-drag {
  cursor: grabbing !important;
}

.sortable-drag * {
  cursor: grabbing !important;
}

/* Animations */
@keyframes slideDown {
  from {
    max-height: 0;
    opacity: 0;
  }
  to {
    max-height: 2000px;
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    max-height: 2000px;
    opacity: 1;
  }
  to {
    max-height: 0;
    opacity: 0;
  }
}

.panel-content.expanding {
  animation: slideDown 0.3s ease;
}

.panel-content.collapsing {
  animation: slideUp 0.3s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
  .panel-toggle-bar {
    padding: 10px 15px;
  }

  .panel-toggle-btn .panel-label {
    display: none;
  }

  .panel-toggle-btn {
    padding: 8px 12px;
    font-size: 18px;
  }

  .panel-toggle-btn .panel-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
  }

  #panels-container {
    padding: 15px;
    gap: 15px;
  }

  .panel-header {
    padding: 12px 15px;
  }

  .panel-content {
    padding: 15px;
  }

  .panel-title .panel-name {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .btn-reset-layout .panel-label {
    display: none;
  }

  .panel-drag-handle {
    padding: 4px;
  }

  .drag-icon {
    font-size: 16px;
  }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
  .panel-toggle-bar {
    background: #1f2937;
    border-bottom-color: #374151;
  }

  .panel-toggle-btn {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
  }

  .panel-toggle-btn:hover {
    background: #1e3a8a;
    border-color: #3b82f6;
  }

  .panel-wrapper {
    background: #1f2937;
    border-color: #374151;
  }

  .panel-header {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    border-bottom-color: #4b5563;
  }

  .panel-title {
    color: #e5e7eb;
  }

  .panel-btn-collapse,
  .panel-btn-close {
    background: #374151;
    border-color: #4b5563;
    color: #9ca3af;
  }

  .panel-content {
    background: #1f2937;
    color: #e5e7eb;
  }
}

/* Print Styles */
@media print {
  .panel-toggle-bar,
  .panel-drag-handle,
  .panel-actions {
    display: none !important;
  }

  .panel-wrapper {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .panel-wrapper.collapsed .panel-content {
    max-height: none;
    opacity: 1;
    padding: 20px;
    overflow: visible;
  }
}
