/**
 * Performance Page Styles
 *
 * Feature-specific styles for the Performance optimization page
 * Uses design tokens from core/_variables.css
 *
 * @since 3.0.0
 */

/* ============================================
   PERFORMANCE BETA TOGGLE CONTAINER
   ============================================ */

.prorank-beta-container {
  padding: var(--prorank-space-md);
  background: var(--prorank-bg-tertiary);
  border: 2px solid var(--prorank-border);
  border-radius: var(--prorank-radius-sm);
  margin-bottom: var(--prorank-space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--prorank-transition);
}

.prorank-beta-container.enabled {
  background: #fff3e0; /* Light orange background for enabled state */
  border-color: var(--prorank-warning);
}

.prorank-beta-info {
  display: flex;
  align-items: center;
  gap: var(--prorank-space-md);
}

.prorank-beta-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--prorank-text);
  display: flex;
  align-items: center;
  gap: var(--prorank-space-sm);
}

.prorank-beta-description {
  font-size: 14px;
  color: var(--prorank-text-secondary);
}

.prorank-beta-controls {
  display: flex;
  align-items: center;
  gap: var(--prorank-space-sm);
}

.prorank-beta-warning {
  font-size: 13px;
  color: var(--prorank-warning);
  font-weight: 600;
}

/* ============================================
   MODULE CONTROL HEADER
   ============================================ */

.prorank-module-control {
  background: var(--prorank-bg);
  border: 1px solid var(--prorank-border);
  border-radius: var(--prorank-radius);
  padding: var(--prorank-space-lg);
  margin-bottom: var(--prorank-space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prorank-module-left {
  display: flex;
  align-items: center;
  gap: var(--prorank-space-md);
}

.prorank-module-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--prorank-primary-light) 0%, var(--prorank-primary) 100%);
  border-radius: var(--prorank-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
}

.prorank-module-icon .dashicons {
  width: 24px;
  height: 24px;
  font-size: 24px;
}

.prorank-module-info h3 {
  margin: 0 0 var(--prorank-space-xs) 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--prorank-text);
}

.prorank-module-info p {
  margin: 0;
  font-size: 14px;
  color: var(--prorank-text-secondary);
}

.prorank-module-toggle {
  display: flex;
  align-items: center;
  gap: var(--prorank-space-sm);
}

/* ============================================
   MODULE LOCKED STATE
   ============================================ */

.prorank-module-locked {
  background: var(--prorank-bg-secondary);
  border: 2px dashed var(--prorank-border-dark);
  border-radius: var(--prorank-radius);
  padding: var(--prorank-space-2xl);
  text-align: center;
}

.prorank-module-locked h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--prorank-text);
  margin-bottom: var(--prorank-space-md);
}

.prorank-module-locked p {
  font-size: 14px;
  color: var(--prorank-text-secondary);
  margin-bottom: var(--prorank-space-lg);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   SETTINGS CONTENT WRAPPER
   ============================================ */

.prorank-settings-content {
  animation: fadeIn 0.3s ease;
}

.prorank-settings-placeholder {
  text-align: center;
  padding: var(--prorank-space-2xl);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   PERFORMANCE-SPECIFIC NOTICE
   ============================================ */

.prorank-performance-notice {
  background: var(--prorank-bg-secondary);
  border-left: 4px solid var(--prorank-warning);
  border-radius: var(--prorank-radius-sm);
  padding: var(--prorank-space-md);
  margin: var(--prorank-space-lg) 0;
  display: flex;
  align-items: center;
  gap: var(--prorank-space-sm);
}

.prorank-performance-notice .dashicons {
  color: var(--prorank-warning);
  font-size: 20px;
}

.prorank-performance-notice span {
  font-size: 14px;
  color: var(--prorank-text);
}

/* ============================================
   AI PERFORMANCE DOCTOR STYLES
   ============================================ */

.prorank-performance-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Performance Score Display */
.prorank-performance-score {
  text-align: center;
  padding: var(--prorank-space-xl);
}

.prorank-performance-score-value {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: var(--prorank-space-sm);
  line-height: 1;
}

.prorank-performance-score-label {
  color: var(--prorank-text-secondary);
  font-size: 14px;
}

/* Core Web Vitals header */
.prorank-core-web-vitals-enhanced .prorank-card-header {
  align-items: flex-start !important;
}

.prorank-core-web-vitals-enhanced .prorank-card-header > .prorank-cwv-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--prorank-space-lg);
  width: 100%;
}

.prorank-core-web-vitals-enhanced .prorank-cwv-header-main {
  flex: 1 1 320px;
  min-width: 0;
}

.prorank-core-web-vitals-enhanced .prorank-cwv-header-main h3 {
  margin: 0 0 var(--prorank-space-sm);
}

.prorank-core-web-vitals-enhanced .prorank-cwv-header-main p {
  margin: 0;
  max-width: 60ch;
}

.prorank-core-web-vitals-enhanced .prorank-cwv-actions {
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--prorank-space-md);
}

.prorank-core-web-vitals-enhanced .prorank-cwv-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--prorank-space-sm);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  white-space: nowrap;
}

.prorank-core-web-vitals-enhanced .prorank-cwv-toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--prorank-text);
}

.prorank-core-web-vitals-enhanced .prorank-cwv-toggle .prorank-toggle-row {
  display: inline-flex;
  align-items: center;
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  min-width: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.prorank-core-web-vitals-enhanced .prorank-cwv-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--prorank-space-sm);
}

.prorank-core-web-vitals-enhanced .prorank-cwv-export-options .prorank-flex {
  flex-wrap: wrap;
}

@media (max-width: 782px) {
  .prorank-core-web-vitals-enhanced .prorank-cwv-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .prorank-core-web-vitals-enhanced .prorank-cwv-buttons {
    width: 100%;
  }

  .prorank-core-web-vitals-enhanced .prorank-cwv-buttons > * {
    flex: 1 1 160px;
  }
}

/* CWV Metrics Grid */
.prorank-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--prorank-space-md);
  margin-top: var(--prorank-space-lg);
}

.prorank-stat-item {
  text-align: center;
  padding: var(--prorank-space-md);
  background: var(--prorank-bg-secondary);
  border-radius: var(--prorank-radius-sm);
}

.prorank-stat-label {
  display: block;
  font-size: 12px;
  color: var(--prorank-text-secondary);
  margin-bottom: var(--prorank-space-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prorank-stat-value {
  display: block;
  font-size: 20px;
  font-weight: 600;
  color: var(--prorank-text);
}

/* Issue Items */
.prorank-issue-item {
  padding: var(--prorank-space-md);
  margin-bottom: var(--prorank-space-md);
  background: var(--prorank-bg-secondary);
  border-radius: var(--prorank-radius-sm);
  border-left: 4px solid;
  transition: var(--prorank-transition);
}

.prorank-issue-item:hover {
  box-shadow: var(--prorank-shadow-sm);
}

.prorank-issue-header {
  display: flex;
  align-items: center;
  margin-bottom: var(--prorank-space-sm);
  gap: var(--prorank-space-sm);
}

/* Optimization Grid */
.prorank-optimization-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--prorank-space-sm);
}

.prorank-optimization-item {
  display: flex;
  align-items: center;
  padding: var(--prorank-space-sm);
  background: var(--prorank-bg-secondary);
  border-radius: var(--prorank-radius-sm);
  font-size: 14px;
}

.prorank-optimization-item .dashicons {
  margin-right: var(--prorank-space-sm);
  font-size: 18px;
  flex-shrink: 0;
}

/* Progress Bar for Analysis */
.prorank-progress-container {
  margin-top: var(--prorank-space-lg);
}

.prorank-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--prorank-bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.prorank-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--prorank-primary), var(--prorank-primary-light));
  transition: width 0.3s ease;
}

.prorank-progress-label {
  margin-top: var(--prorank-space-sm);
  font-size: 14px;
  color: var(--prorank-text-secondary);
}

/* AI Configuration Notice */
.prorank-ai-notice {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--prorank-radius-sm);
  padding: var(--prorank-space-md);
  margin-bottom: var(--prorank-space-lg);
  display: flex;
  align-items: center;
  gap: var(--prorank-space-sm);
}

.prorank-ai-notice .dashicons {
  color: #856404;
  font-size: 20px;
  flex-shrink: 0;
}

.prorank-ai-notice-content {
  flex: 1;
}

.prorank-ai-notice-content a {
  color: var(--prorank-primary);
  text-decoration: none;
  font-weight: 500;
}

.prorank-ai-notice-content a:hover {
  text-decoration: underline;
}

/* Actions Section */
.prorank-actions {
  display: flex;
  gap: var(--prorank-space-sm);
  margin-top: var(--prorank-space-lg);
  flex-wrap: wrap;
}

/* Unified Card Header Design */
.prorank-card-header {
  background-color: #f5f5f5 !important;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prorank-card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--prorank-text);
  display: flex;
  align-items: center;
  gap: var(--prorank-space-sm);
}

.prorank-card-header h3 .dashicons {
  font-size: 18px;
  width: 18px;
  height: 18px;
}

/* Ensure proper badge styling in headers */
.prorank-card-header .prorank-badge {
  font-size: 12px;
  padding: 4px 8px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
  .prorank-beta-container {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--prorank-space-md);
  }

  .prorank-beta-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .prorank-module-control {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--prorank-space-md);
  }

  .prorank-module-toggle {
    width: 100%;
    justify-content: flex-end;
  }

  .prorank-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .prorank-optimization-grid {
    grid-template-columns: 1fr;
  }

  .prorank-actions {
    flex-direction: column;
    width: 100%;
  }

  .prorank-actions button {
    width: 100%;
  }
}

/* ============================================
   DATABASE & SERVER SPECIFIC STYLES
   ============================================ */

.prorank-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  padding: 16px;
  background: #f9f9f9;
  border-radius: 8px;
  margin-top: 8px;
}

.prorank-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
}

.prorank-info-item strong {
  color: #4a5568;
  font-weight: 600;
  margin-right: 8px;
}

.prorank-info-item span {
  color: #2d3748;
  font-weight: 500;
}

.prorank-text-success {
  color: #10b981;
  font-weight: 600;
}

.prorank-text-warning {
  color: #f59e0b;
  font-weight: 600;
}

/* Control group spacing - let unified-settings handle boxing */
.prorank-performance-container .prorank-control-group {
  margin-top: 16px;
}

.prorank-control-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #4a5568;
}

/* Cleanup items section */
.prorank-toggle-row + h4 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 600;
  color: #2d3748;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 8px;
}

/* Actions for optimization button */
.prorank-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
}

.prorank-actions-center {
  justify-content: center;
}

.prorank-mt-32 {
  margin-top: 32px;
}

/* Tab content area */
.prorank-performance-page .prorank-tab-content {
  padding: 24px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
  animation: fadeIn 0.3s ease;
}

/* Module states - locked */
.prorank-performance-page .prorank-module-locked {
  padding: var(--prorank-space-2xl) !important;
  text-align: center !important;
  background: var(--prorank-bg-secondary) !important;
  border-radius: var(--prorank-radius) !important;
  border: 1px solid var(--prorank-border) !important;
}

.prorank-performance-page .prorank-locked-content {
  max-width: 400px !important;
  margin: 0 auto !important;
}

.prorank-performance-page .prorank-locked-content .dashicons {
  color: var(--prorank-text-tertiary) !important;
  margin-bottom: var(--prorank-space-md) !important;
}

/* Module states - disabled */
.prorank-performance-page .prorank-module-disabled {
  padding: var(--prorank-space-2xl) !important;
  text-align: center !important;
  background: var(--prorank-bg-secondary) !important;
  border-radius: var(--prorank-radius) !important;
  border: 1px solid var(--prorank-border) !important;
}

.prorank-performance-page .prorank-disabled-content {
  max-width: 400px !important;
  margin: 0 auto !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 16px !important;
}

.prorank-performance-page .prorank-disabled-content .dashicons {
  color: var(--prorank-text-tertiary);
  margin-bottom: 0 !important;
  line-height: 1;
  display: block;
}

.prorank-performance-page .prorank-disabled-content h3 {
  margin: 0 !important;
  line-height: 1.14;
}

.prorank-performance-page .prorank-disabled-content p {
  margin: 0 !important;
  line-height: 1.55;
}

/* Settings wrapper */
.prorank-performance-page .prorank-settings-wrapper {
  animation: fadeIn 0.3s ease;
}

/* Pro callout - matches Technical SEO exactly */
.prorank-performance-page .prorank-pro-callout {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
  border: 1px solid #fbbf24 !important;
  border-radius: 12px !important;
  padding: 24px !important;
  margin-top: 32px !important;
  position: relative !important;
  overflow: hidden !important;
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.15) !important;
}

.prorank-performance-page .prorank-pro-callout::before {
  content: '' !important;
  position: relative !important;
  display: block !important;
  margin-bottom: -3px !important;
  height: 3px !important;
  background: linear-gradient(90deg, #f59e0b, #fbbf24, #f59e0b) !important;
  animation: shimmer 3s infinite !important;
}

.prorank-performance-page .prorank-pro-content h4 {
  color: #92400e !important;
  font-size: 18px !important;
  font-weight: 600 !important;
  margin: 0 0 8px 0 !important;
}

.prorank-performance-page .prorank-pro-content p {
  color: #78350f !important;
  font-size: 14px !important;
  margin: 0 0 16px 0 !important;
  line-height: 1.6 !important;
}

.prorank-performance-page .prorank-pro-button {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  background: #ff6900 !important;
  color: white !important;
  padding: 10px 20px !important;
  border-radius: 8px !important;
  text-decoration: none !important;
  font-weight: 500 !important;
  font-size: 14px !important;
  transition: all 0.2s ease !important;
  border: none !important;
}

.prorank-performance-page .prorank-pro-button:hover {
  background: #e55a00 !important;
  color: white !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(255, 105, 0, 0.3) !important;
  text-decoration: none !important;
}

/* ============================================
   PERFORMANCE TOGGLE ROW FIXES
   Override conflicting _forms.css styles
   ============================================ */

/* Toggle container - flex layout for label + switch */
.prorank-performance-container .prorank-toggle,
.prorank-performance-page .prorank-toggle {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  padding: 16px 0 !important;
  border-bottom: 1px solid #f3f4f6 !important;
  width: 100% !important;
  height: auto !important;
  position: relative !important;
}

.prorank-performance-container .prorank-toggle:last-child,
.prorank-performance-page .prorank-toggle:last-child {
  border-bottom: none !important;
}

/* Toggle label - contains title and description */
/* Override absolute positioning from _tabs.css */
.prorank-performance-container .prorank-toggle-label,
.prorank-performance-page .prorank-toggle-label,
.prorank-performance-container .prorank-card-body .prorank-toggle-label,
.prorank-performance-page .prorank-card-body .prorank-toggle-label,
.prorank-performance-container .prorank-toggle .prorank-toggle-label,
.prorank-performance-page .prorank-toggle .prorank-toggle-label,
div.prorank-toggle-label {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  min-width: 0 !important;
  position: static !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  white-space: normal !important;
  font-size: inherit !important;
  color: inherit !important;
}

.prorank-performance-container .prorank-toggle-label strong,
.prorank-performance-page .prorank-toggle-label strong {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #1f2937 !important;
  display: block !important;
  line-height: 1.4 !important;
}

.prorank-performance-container .prorank-toggle-label span,
.prorank-performance-page .prorank-toggle-label span {
  font-size: 13px !important;
  color: #6b7280 !important;
  line-height: 1.5 !important;
  display: block !important;
}

/* Make sure toggle switch doesn't shrink */
.prorank-performance-container .prorank-toggle .prorank-toggle-slider,
.prorank-performance-page .prorank-toggle .prorank-toggle-slider,
.prorank-performance-container .prorank-toggle > div:last-child,
.prorank-performance-page .prorank-toggle > div:last-child {
  flex-shrink: 0 !important;
}
