/**
 * Planetary Computer Control Styles
 */

/* ============ Control Container ============ */
.pc-control {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

.pc-control-toggle {
  width: 29px;
  height: 29px;
  padding: 0;
  border: none;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.15s;
}

.pc-control-toggle:hover {
  background-color: #f0f0f0;
}

.pc-control-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pc-control-icon svg {
  stroke: #333;
}

/* ============ Panel ============ */
.pc-control-panel {
  position: absolute;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.pc-control-panel.expanded {
  display: flex;
}

/* ============ Header ============ */
.pc-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e5e5;
  background: #f8f9fa;
  border-radius: 8px 8px 0 0;
}

.pc-control-title {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a1a;
}

.pc-control-close {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
}

.pc-control-close:hover {
  background: #e5e5e5;
  color: #333;
}

/* ============ Navigation ============ */
.pc-control-nav {
  display: flex;
  padding: 8px 12px;
  gap: 8px;
  border-bottom: 1px solid #e5e5e5;
  background: #fafafa;
}

.pc-nav-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  transition: all 0.15s;
}

.pc-nav-btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.pc-nav-btn.active {
  background: #0078d4;
  border-color: #0078d4;
  color: #fff;
}

/* ============ Content Area ============ */
.pc-control-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.pc-control-content::-webkit-scrollbar {
  width: 6px;
}

.pc-control-content::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.pc-control-content::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.pc-control-content::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ============ Loading & Error States ============ */
.pc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #666;
  gap: 12px;
}

.pc-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e5e5;
  border-top-color: #0078d4;
  border-radius: 50%;
  animation: pc-spin 0.8s linear infinite;
}

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

.pc-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  color: #d13438;
  text-align: center;
}

/* ============ Collection Browser ============ */
.pc-collection-browser {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pc-search-box {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.pc-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.pc-search-input:focus {
  border-color: #0078d4;
}

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

.pc-collection-item {
  padding: 12px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.pc-collection-item:hover {
  border-color: #0078d4;
  background: #f8f9fa;
}

.pc-collection-title {
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.pc-collection-description {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.pc-collection-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pc-tag {
  display: inline-block;
  padding: 2px 8px;
  background: #e8f4fd;
  color: #0078d4;
  font-size: 11px;
  border-radius: 10px;
}

/* ============ Search Panel ============ */
.pc-search-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pc-btn-back {
  background: none;
  border: none;
  padding: 0;
  color: #0078d4;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}

.pc-btn-back:hover {
  text-decoration: underline;
}

.pc-selected-collection {
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
}

.pc-collection-name {
  display: block;
  font-weight: 600;
  margin-top: 4px;
}

.pc-open-collection-page {
  margin-top: 8px;
}

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

.pc-label {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

.pc-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.pc-input:focus {
  border-color: #0078d4;
}

.pc-bbox-display {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-radius: 4px;
}

.pc-bbox-text {
  font-size: 12px;
  color: #666;
  font-family: monospace;
  word-break: break-word;
}

.pc-bbox-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
  white-space: nowrap;
}

.pc-bbox-coordinates {
  min-width: 0;
}

.pc-date-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pc-date-inputs .pc-input {
  flex: 1;
}

.pc-date-separator {
  color: #999;
  font-size: 12px;
}

/* ============ Buttons ============ */
.pc-btn {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.pc-btn:hover {
  background: #f5f5f5;
}

.pc-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pc-btn:disabled:hover {
  background: #fff;
}

.pc-btn-primary {
  background: #0078d4;
  border-color: #0078d4;
  color: #fff;
}

.pc-btn-primary:hover {
  background: #006cbd;
}

.pc-search-btn {
  width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
}

.pc-search-btn-loading,
.pc-search-btn-loading:disabled,
.pc-search-btn-loading:disabled:hover {
  background: #005a9e;
  border-color: #005a9e;
  color: #fff;
  opacity: 1;
}

.pc-search-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pc-spin 0.8s linear infinite;
}

.pc-btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.pc-btn-active {
  background: #e8f4fd;
  border-color: #0078d4;
  color: #005a9e;
}

.pc-btn-active:hover {
  background: #d7ecfb;
}

/* ============ Bounding Box Drawing ============ */
.pc-bbox-drawing,
.pc-bbox-drawing canvas,
.pc-inspector-active,
.pc-inspector-active canvas {
  cursor: crosshair !important;
}

.pc-bbox-overlay {
  position: absolute;
  inset: 0;
  z-index: 999;
  pointer-events: none;
}

.pc-bbox-box {
  position: absolute;
  display: none;
  border: 2px solid #0078d4;
  background: rgba(0, 120, 212, 0.16);
  box-sizing: border-box;
}

.pc-bbox-instructions {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(26, 26, 26, 0.82);
  color: #fff;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
}

.pc-btn-icon {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #666;
  transition: all 0.15s;
}

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

.pc-inspect-active {
  background: #0078d4;
  color: #fff;
}

.pc-inspect-active:hover {
  background: #006cbd;
  color: #fff;
}

.pc-layer-controls-active {
  background: #e8f4fd;
  color: #005a9e;
}

.pc-layer-controls-active:hover {
  background: #d7ecfb;
  color: #005a9e;
}

/* ============ Results ============ */
.pc-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pc-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pc-results-count {
  font-size: 12px;
  color: #666;
}

.pc-results-toolbar {
  display: flex;
  gap: 8px;
}

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

.pc-results-empty {
  padding: 30px 20px;
  text-align: center;
  color: #666;
}

.pc-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.pc-result-item:hover {
  border-color: #0078d4;
  background: #f8f9fa;
}

.pc-result-selected {
  border-color: #ff8c00;
  background: #fff8e5;
  box-shadow: inset 3px 0 0 #ff8c00;
}

.pc-result-selected:hover {
  border-color: #ff8c00;
  background: #fff4d6;
}

.pc-result-thumbnail {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f5f5f5;
}

.pc-result-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pc-result-info {
  flex: 1;
  min-width: 0;
}

.pc-result-title {
  font-weight: 500;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.pc-result-date,
.pc-result-cloud {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

.pc-result-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ============ Item Details ============ */
.pc-item-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pc-details-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pc-details-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  word-break: break-all;
}

.pc-details-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
}

.pc-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pc-meta-item .pc-value {
  font-weight: 500;
  color: #1a1a1a;
}

.pc-details-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pc-section-title {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.pc-assets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.pc-asset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
}

.pc-asset-info {
  flex: 1;
  min-width: 0;
}

.pc-asset-name {
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-asset-type {
  font-size: 11px;
  color: #666;
}

.pc-details-actions {
  padding-top: 8px;
  border-top: 1px solid #e5e5e5;
}

.pc-details-actions .pc-btn {
  width: 100%;
}

/* ============ Data API Tools ============ */
.pc-tool-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pc-tool-output {
  min-height: 0;
}

.pc-tool-loading,
.pc-tool-success,
.pc-tool-error {
  padding: 8px;
  border-radius: 4px;
  font-size: 12px;
}

.pc-tool-loading {
  background: #f5f5f5;
  color: #666;
}

.pc-tool-success {
  margin-bottom: 8px;
  background: #edf7ed;
  color: #107c10;
}

.pc-tool-error {
  background: #fde7e9;
  color: #a4262c;
}

.pc-stats-card {
  padding: 10px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
}

.pc-stats-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
  color: #333;
}

.pc-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.pc-stats-grid > div,
.pc-point-values > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.pc-stats-grid > div > span,
.pc-point-values > div > span {
  color: #666;
}

.pc-stats-grid > div > strong,
.pc-point-values > div > strong {
  color: #1a1a1a;
  font-weight: 600;
}

.pc-histogram {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 42px;
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid #f0f0f0;
}

.pc-histogram span {
  flex: 1;
  min-width: 2px;
  background: #0078d4;
  border-radius: 1px 1px 0 0;
}

.pc-legend-card {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  background: #fff;
}

.pc-legend-title {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #333;
}

.pc-legend-ramp {
  width: 100%;
  height: 12px;
  border: 1px solid #ddd;
  border-radius: 2px;
}

.pc-legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 10px;
  color: #666;
}

.pc-tilejson-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
}

.pc-tilejson-card > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.pc-tilejson-card > div > span {
  flex-shrink: 0;
  color: #666;
}

.pc-tilejson-card > div > strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #1a1a1a;
  text-align: right;
}

/* ============ Layers ============ */
.pc-layers-empty {
  padding: 30px 20px;
  text-align: center;
  color: #666;
}

.pc-layers-empty p {
  margin: 0 0 8px;
}

.pc-layers-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pc-layer-item {
  padding: 8px;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
}

.pc-layer-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pc-layer-visibility {
  flex-shrink: 0;
}

.pc-layer-name {
  flex: 1;
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-layer-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #f0f0f0;
}

.pc-layer-controls-hidden {
  display: none;
}

.pc-inspector-panel {
  padding: 10px;
  border: 1px solid #cfe8ff;
  border-radius: 6px;
  background: #f3f9ff;
}

.pc-inspector-title {
  font-weight: 600;
  font-size: 12px;
  color: #1a1a1a;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-inspector-hint,
.pc-inspector-coords {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.pc-point-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pc-point-json {
  max-height: 120px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 11px;
}

.pc-opacity-label {
  display: block;
  font-size: 11px;
  color: #666;
  margin-bottom: 0;
  white-space: nowrap;
}

.pc-opacity-value {
  font-weight: 500;
  color: #333;
}

.pc-opacity-slider {
  width: 100%;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: #e5e5e5;
  border-radius: 2px;
  outline: none;
}

.pc-opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0078d4;
  cursor: pointer;
}

.pc-opacity-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0078d4;
  cursor: pointer;
  border: none;
}

/* ============ Cloud Cover Slider ============ */
.pc-cloud-cover-input {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pc-cloud-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #e5e5e5;
  border-radius: 2px;
  outline: none;
}

.pc-cloud-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0078d4;
  cursor: pointer;
}

.pc-cloud-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0078d4;
  cursor: pointer;
  border: none;
}

.pc-cloud-value {
  font-size: 12px;
  font-weight: 500;
  color: #333;
  min-width: 40px;
  text-align: right;
}

/* ============ Rescale Inputs ============ */
.pc-rescale-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pc-rescale-inputs .pc-input {
  flex: 1;
  min-width: 0;
}

.pc-rescale-separator {
  color: #999;
  font-size: 12px;
  flex-shrink: 0;
}

/* ============ Custom Visualization ============ */
.pc-custom-viz {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #e5e5e5;
}

.pc-advanced-render {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pc-advanced-render summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #333;
}

.pc-advanced-render[open] summary {
  margin-bottom: 10px;
}

.pc-advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pc-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pc-checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #333;
}

.pc-hint {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
  display: block;
}
