/* Beefree SDK Secure Authentication Example - React + TypeScript Styles */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 20px;
  background-color: #f5f5f5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  overflow: hidden;
}

/* Header Styles */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  text-align: center;
  position: relative;
}

.header h1 {
  margin: 0;
  font-size: 2.5em;
  font-weight: 300;
}

.header p {
  margin: 10px 0 0 0;
  opacity: 0.9;
}

.auth-status {
  position: absolute;
  top: 20px;
  right: 30px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.auth-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.status-indicator {
  font-size: 14px;
  font-weight: 500;
}

.uid-display {
  font-size: 12px;
  opacity: 0.8;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Controls/Form Styles */
.controls {
  padding: 30px;
  border-bottom: 1px solid #eee;
}

.auth-section h2 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 1.5em;
  font-weight: 500;
}

.auth-section > p {
  margin: 0 0 25px 0;
  color: #666;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #333;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.3s;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

.form-group input:disabled {
  background-color: #f8f9fa;
  cursor: not-allowed;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: #666;
  font-size: 14px;
}

/* Button Styles */
button[type="submit"], .btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button[type="submit"]:hover, .btn:hover {
  transform: translateY(-2px);
}

button[type="submit"]:disabled, .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error Message */
.error-message {
  margin-top: 15px;
  padding: 15px;
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  font-weight: 500;
}

/* Info Section */
.info-section {
  margin-top: 30px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #e9ecef;
}

.info-section h3 {
  margin: 0 0 15px 0;
  color: #495057;
  font-size: 1.1em;
}

.info-section ul {
  margin: 0;
  padding-left: 20px;
}

.info-section li {
  margin-bottom: 8px;
  color: #6c757d;
}

.info-section li strong {
  color: #495057;
}

/* Editor Container */
.editor-container {
  position: relative;
  width: 100%;
  padding: 0;
  margin: 0;
  max-width: 100%;
  overflow: hidden;
}

.builder-wrapper {
  height: 700px;
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

#bee-plugin-container {
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  font-size: 18px;
  color: #667eea;
}

/* Editor Info Panel */
.editor-info {
  padding: 20px 30px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
}

.info-panel {
  max-width: 600px;
}

.info-panel h3 {
  margin: 0 0 15px 0;
  color: #28a745;
  font-size: 1.2em;
}

.auth-details {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.detail-item strong {
  color: #495057;
}

.status-active {
  color: #28a745;
  font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  .header {
    padding: 20px;
    text-align: center;
  }
  
  .header h1 {
    font-size: 2em;
  }
  
  .auth-status {
    position: static;
    margin-top: 20px;
    justify-content: center;
  }
  
  .controls {
    padding: 20px;
  }
  
  .auth-details {
    flex-direction: column;
    gap: 10px;
  }
  
  .detail-item {
    justify-content: center;
  }
}

/* Main Layout */
.main-layout {
  display: flex;
  gap: 20px;
  min-height: calc(100vh - 200px);
  max-width: 100vw;
  overflow: hidden;
}

.content-area {
  flex: 1;
  min-width: 0;
  max-width: calc(100vw - 440px); /* Reserve space for API monitor + gap */
  overflow: hidden;
}

.api-monitor-area {
  width: 400px;
  flex-shrink: 0;
  max-height: calc(100vh - 120px);
}

/* API Monitor Panel */
.api-monitor-panel {
  background: #ffffff;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  height: calc(100vh + 70px); /* Further increased by 150px: from -80px to +70px */
  max-height: calc(100vh + 70px);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 20px;
}

.api-monitor-panel.collapsed .api-monitor-content {
  display: none;
}

.api-monitor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e1e5e9;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px 8px 0 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.api-monitor-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.call-count {
  background: rgba(255,255,255,0.2);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.header-controls {
  display: flex;
  gap: 8px;
}

.clear-btn, .collapse-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.clear-btn:hover, .collapse-btn:hover {
  background: rgba(255,255,255,0.3);
}

.clear-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.api-monitor-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1;
  overflow: hidden;
}

.api-calls-list {
  border-bottom: 1px solid #e1e5e9;
  flex: 0 0 50%; /* Fixed to exactly 50% of container height */
  overflow-y: auto;
  min-height: 200px;
}

.calls-header {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e1e5e9;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
}

.no-calls {
  padding: 30px 20px;
  text-align: center;
  color: #6c757d;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.no-calls-icon {
  font-size: 32px;
  opacity: 0.5;
}

.no-calls p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #495057;
}

.no-calls small {
  font-size: 12px;
  opacity: 0.8;
  margin: 0;
}

.no-calls-hint {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
  text-align: left;
  width: 100%;
  max-width: 280px;
}

.no-calls-hint strong {
  display: block;
  font-size: 12px;
  color: #495057;
  margin-bottom: 8px;
}

.no-calls-hint ul {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  line-height: 1.4;
}

.no-calls-hint li {
  margin-bottom: 2px;
  color: #6c757d;
}

.calls-list {
  height: 100%; /* Take full height of parent container */
  overflow-y: auto;
}

.call-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f3f4;
  cursor: pointer;
  transition: background 0.2s;
}

.call-item:hover {
  background: #f8f9fa;
}

.call-item.selected {
  background: #e3f2fd;
  border-left: 3px solid #2196f3;
}

.call-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.method-url {
  display: flex;
  align-items: center;
  gap: 8px;
}

.method-badge {
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  min-width: 45px;
  text-align: center;
}

.method-badge.inline {
  display: inline-block;
  margin-left: 8px;
}

.url {
  font-size: 12px;
  color: #495057;
  word-break: break-all;
  flex: 1;
}

.call-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
}

.status-badge {
  font-weight: 600;
}

.status-badge.inline {
  margin-left: 8px;
}

.duration {
  color: #6c757d;
}

.timestamp {
  color: #6c757d;
  margin-left: auto;
}

.call-details {
  flex: 0 0 50%; /* Fixed to exactly 50% of container height */
  overflow-y: auto;
  border-top: 1px solid #e1e5e9;
  min-height: 200px;
}

.details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e1e5e9;
  position: sticky;
  top: 0;
  z-index: 1;
}

.details-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
}

.close-details {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.close-details:hover {
  background: #e9ecef;
}

.details-content {
  padding: 16px;
  height: calc(100% - 50px); /* Take remaining height minus header (50px for header) */
  overflow-y: auto;
}

.section {
  margin-bottom: 24px;
}

.section h5 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
  padding-bottom: 8px;
  border-bottom: 1px solid #e1e5e9;
}

.detail-item {
  margin-bottom: 12px;
}

.detail-item strong {
  display: block;
  font-size: 12px;
  color: #6c757d;
  margin-bottom: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

.detail-item code {
  background: #f8f9fa;
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 11px;
  word-break: break-all;
}

.json-display {
  background: #f8f9fa;
  border: 1px solid #e1e5e9;
  border-radius: 4px;
  padding: 12px;
  font-size: 11px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  margin: 4px 0;
  line-height: 1.4;
}

.error-display {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 4px;
  padding: 12px;
  font-size: 11px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c53030;
  margin: 4px 0;
  line-height: 1.4;
}

/* API Monitor Responsive Design */
@media (max-width: 1400px) {
  .api-monitor-area {
    width: 350px;
  }
  
  .content-area {
    max-width: calc(100vw - 390px);
  }
}

@media (max-width: 1200px) {
  .main-layout {
    flex-direction: column;
    gap: 15px;
  }
  
  .content-area {
    max-width: 100%;
    order: 2;
  }
  
  .api-monitor-area {
    width: 100%;
    order: 1;
  }
  
  .api-monitor-panel {
    height: 400px;
    max-height: 400px;
    position: relative;
    top: 0;
  }
  
  .api-calls-list {
    flex: 0 0 150px;
    min-height: 120px;
  }
  
  .builder-wrapper {
    height: 600px;
  }
}
