/**
 * Global Layout CSS
 * Ensures consistent layout with navigation ribbon across all pages
 */

/* Apply to body when global navigation is present */
body.has-global-nav {
  margin-left: 80px; /* Space for navigation ribbon */
  transition: margin-left 0.3s ease;
}

/* Adjust main content areas when panel is open */
body.has-global-nav .main-content.panel-open,
body.has-global-nav #app-container.panel-open {
  margin-right: 400px;
  transition: margin-right 0.3s ease;
}

/* Assay Panel Styles (Global) - Adjacent to Navigation Ribbon */
.assay-panel {
  position: fixed;
  left: 80px; /* Starts where nav ribbon ends */
  top: 0;
  bottom: 0;
  width: 400px;
  min-width: 250px;
  max-width: 50vw;
  background: #ffffff;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transform: translateX(-100%); /* Hidden by default - slides from left */
  transition: transform 0.3s ease, width 0.1s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.assay-panel.open {
  transform: translateX(0); /* Slide in to be visible */
}

/* Panel Resizer - On right side of panel */
.panel-resizer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  background: linear-gradient(90deg, transparent 0%, #e0e0e0 50%, transparent 100%);
  transition: background 0.2s ease;
  z-index: 10;
}

.panel-resizer:hover {
  background: linear-gradient(90deg, transparent 0%, #667eea 50%, transparent 100%);
}

/* Panel Header */
.panel-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.panel-header h3 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

/* Panel Content */
.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Search Section */
.search-section {
  flex: 1;
  margin-bottom: 20px;
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  outline: none;
}

.search-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Assay List */
.assay-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Assay Item */
.assay-item {
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.assay-item:hover {
  background: #e9ecef;
  border-color: #667eea;
  transform: translateX(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Selected/highlighted assay item */
.assay-item.selected {
  background: #e3f2fd;
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.assay-item.selected .assay-title {
  color: #000;
}

.assay-title {
  font-weight: 500;
  color: #333;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* Visual feedback when title itself is focused/active */
.assay-title:focus,
.assay-title:active {
  outline: none;
  background: #e3f2fd;
  border-radius: 4px;
}

.assay-meta {
  font-size: 0.8rem;
  color: #666;
  margin-top: 4px;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #666;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

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

/* Error State */
.error-state {
  text-align: center;
  padding: 40px 20px;
  color: #d32f2f;
}

.error-state button {
  margin-top: 16px;
  padding: 10px 20px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

.error-state button:hover {
  background: #764ba2;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 1024px) {
  body.has-global-nav {
    margin-left: 60px;
  }

  .assay-panel {
    left: 60px; /* Match nav ribbon width */
    width: 350px;
  }

  body.has-global-nav .main-content.panel-open,
  body.has-global-nav #app-container.panel-open {
    margin-right: 350px;
  }
}

@media (max-width: 768px) {
  body.has-global-nav {
    /* Adjust based on nav-ribbon's mobile width */
    margin-left: 60px; 
  }

  .assay-panel {
    left: 60px; /* Now starts after the nav-ribbon (60px) */
    width: 320px;
    max-width: 85vw; /* Ensure it's not too wide on small screens */
    transform: translateX(-100%);
    box-shadow: 4px 0 15px rgba(0,0,0,0.2);
    z-index: 1002; /* Above backdrop */
  }

  body.has-global-nav.panel-open .main-content,
  body.has-global-nav.panel-open #app-container {
    /* Content is not pushed, it's overlaid */
    margin-right: 0;
  }

  .assay-panel.open {
    transform: translateX(0);
  }

  /* Backdrop for modal effect */
  .panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1001; /* Below panel, above content */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
  }

  .panel-backdrop.open {
    opacity: 1;
    visibility: visible;
  }
}

@media (max-width: 480px) {
    body.has-global-nav {
        margin-left: 60px;
    }
}

