/**
 * Redirect Manager Styles
 * Ensures consistent design and fixes visual issues
 */

/* Redirect Manager Container */
.prorank-redirects-settings-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header Section */
.prorank-redirects-header {
  margin-bottom: 24px;
}

.prorank-redirects-header h3 {
  font-size: 24px;
  font-weight: 600;
  color: var(--prorank-text-primary);
  margin: 0 0 8px 0;
}

.prorank-redirects-header p {
  color: var(--prorank-text-muted);
  margin: 0;
}

/* Tab content wrapper */
.prorank-redirects-tab-content {
  margin-top: 24px;
}

/* Card Styling - Enforce grey headers */
.prorank-redirects-settings-wrapper .prorank-card {
  margin-bottom: 20px;
  border: 1px solid var(--prorank-border);
  border-radius: 8px;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.prorank-redirects-settings-wrapper .prorank-card-header {
  background-color: #f5f5f5 !important;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  border-radius: 8px 8px 0 0;
}

.prorank-redirects-settings-wrapper .prorank-card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--prorank-text-primary);
}

.prorank-redirects-settings-wrapper .prorank-card-body {
  padding: 20px;
}

/* Tools Bar */
.prorank-redirects-tools .prorank-card-body {
  padding: 16px 20px;
  background: #fafafa;
}

/* Filters */
.prorank-redirects-filters {
  margin-bottom: 20px;
}

.prorank-redirects-filters label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 13px;
  color: var(--prorank-text-secondary);
}

.prorank-redirects-filters input[type="text"],
.prorank-redirects-filters select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--prorank-border);
  border-radius: 6px;
  font-size: 14px;
}

/* Table Styling */
.prorank-redirects-table {
  width: 100%;
  border-collapse: collapse;
}

.prorank-redirects-table thead {
  background: #f9f9f9;
  border-bottom: 2px solid var(--prorank-border);
}

.prorank-redirects-table th {
  text-align: left;
  padding: 12px;
  font-weight: 500;
  font-size: 13px;
  color: var(--prorank-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prorank-redirects-table td {
  padding: 12px;
  border-bottom: 1px solid var(--prorank-border-light);
  font-size: 14px;
}

.prorank-redirects-table tbody tr:hover {
  background: #f9f9f9;
}

.prorank-redirects-table code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
}

.prorank-check-column {
  width: 40px;
}

/* Status Badge */
.prorank-status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prorank-status-active {
  background: #d4edda;
  color: #155724;
}

.prorank-status-inactive {
  background: #f8d7da;
  color: #721c24;
}

/* Regex Badge */
.prorank-regex-badge {
  margin-left: 8px;
  padding: 2px 6px;
  background: linear-gradient(135deg, #fb923c, #f97316);
  color: white;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

/* Pagination */
.prorank-redirects-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--prorank-border);
}

/* Empty State */
.prorank-redirects-empty {
  text-align: center;
  padding: 60px 20px;
}

.prorank-redirects-empty p {
  margin-bottom: 20px;
  color: var(--prorank-text-muted);
  font-size: 16px;
}

/* Settings Tab Specific */
.prorank-redirect-settings h4 {
  font-size: 18px;
  font-weight: 600;
  color: var(--prorank-text-primary);
  margin: 32px 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--prorank-border-light);
}

.prorank-redirect-settings h4:first-child {
  margin-top: 0;
}

.prorank-redirect-settings p {
  color: var(--prorank-text-muted);
  margin-bottom: 20px;
}

/* Toggle Row Fixes - CRITICAL */
.prorank-redirect-settings .prorank-toggle-wrapper {
  margin-bottom: 20px;
}

.prorank-redirect-settings .prorank-toggle-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.prorank-redirect-settings .prorank-toggle {
  flex-shrink: 0;
  margin-top: 2px;
}

.prorank-redirect-settings .prorank-toggle-label-text {
  flex: 1;
}

.prorank-redirect-settings .prorank-toggle-label-text strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--prorank-text-primary);
  margin-bottom: 4px;
}

.prorank-redirect-settings .prorank-toggle-label-text span {
  display: block;
  font-size: 13px;
  color: var(--prorank-text-muted);
  line-height: 1.5;
}

/* Input Controls in Settings */
.prorank-redirect-settings .components-text-control__input[type="number"] {
  width: 100px !important;
  height: 36px;
}

.prorank-redirect-settings .components-select-control__input {
  width: auto;
  min-width: 200px;
  height: 36px;
}

/* Loading State */
.prorank-redirects-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 16px;
}

.prorank-redirects-loading p {
  color: var(--prorank-text-muted);
  font-size: 14px;
}

/* Redirect Edit Modal - Force visibility */
body .components-modal__screen-overlay.prorank-redirect-edit-overlay,
.prorank-redirect-edit-overlay.components-modal__screen-overlay,
.prorank-redirect-edit-overlay {
  z-index: 999999 !important;
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.6) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

body .components-modal__frame.prorank-redirect-edit-modal,
.prorank-redirect-edit-modal.components-modal__frame,
.prorank-redirect-edit-modal {
  max-width: 600px !important;
  width: 90vw !important;
  max-height: 90vh !important;
  position: relative !important;
  z-index: 1000000 !important;
  background: #fff !important;
  border-radius: 8px !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3) !important;
  display: flex !important;
  flex-direction: column !important;
  visibility: visible !important;
  opacity: 1 !important;
  overflow: auto !important;
}

.prorank-redirect-edit-modal .components-modal__content {
  padding: 20px;
}

.prorank-redirect-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.prorank-redirect-form .components-base-control {
  margin-bottom: 0;
}

.prorank-redirect-form .prorank-field-error {
  color: #d63638;
  font-size: 12px;
  margin-top: -16px;
  display: block;
}

.prorank-redirect-form .has-error input {
  border-color: #d63638;
}

.prorank-redirect-form .prorank-form-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
}

.prorank-redirect-form .prorank-pro-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  background: linear-gradient(135deg, #fb923c, #f97316);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  text-transform: uppercase;
}

/* Import/Export Modal */
.prorank-import-modal {
  max-width: 500px;
}

.prorank-import-dropzone {
  border: 2px dashed var(--prorank-border);
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.3s ease;
}

.prorank-import-dropzone:hover {
  border-color: var(--prorank-primary);
  background: #f5f5f5;
}

.prorank-import-dropzone.dragging {
  border-color: var(--prorank-primary);
  background: #fff3e0;
}

/* Fix overlapping issues */
.prorank-redirects-settings-wrapper label {
  position: relative !important;
  display: block;
}

/* Ensure buttons have consistent height */
.prorank-redirects-settings-wrapper .prorank-button {
  height: 36px !important;
  padding: 0 16px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
}

/* Remove any absolute positioning that causes issues */
.prorank-redirects-settings-wrapper [style*="position: absolute"] {
  position: relative !important;
}

/* Settings Groups */
.prorank-settings-group {
  margin-top: 20px;
  margin-bottom: 30px;
}

.prorank-settings-group .prorank-toggle-row {
  margin-bottom: 16px;
}

.prorank-settings-group .prorank-toggle-row:last-child {
  margin-bottom: 12px;
}

/* Settings Actions */
.prorank-settings-actions {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

/* Responsive Table Wrapper */
.prorank-redirects-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--prorank-border, #d4d4d8) transparent;
}

.prorank-redirects-table-wrap::-webkit-scrollbar {
  height: 6px;
}

.prorank-redirects-table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.prorank-redirects-table-wrap::-webkit-scrollbar-thumb {
  background-color: var(--prorank-border, #d4d4d8);
  border-radius: 3px;
}

/* URL Code Display - prevent overflow */
.prorank-redirects-table code {
  word-break: break-all;
  max-width: 280px;
  display: inline-block;
  vertical-align: middle;
}

/* Mobile-first responsive table improvements */
@media (width <= 1200px) {
  .prorank-redirects-table {
    min-width: 900px;
  }
}

@media (width <= 1024px) {
  .prorank-redirects-table code {
    max-width: 200px;
    font-size: 12px;
  }

  .prorank-redirects-table th,
  .prorank-redirects-table td {
    padding: 10px 8px;
  }
}

@media (width <= 768px) {
  .prorank-redirects-table {
    min-width: 800px;
  }

  .prorank-redirects-table code {
    max-width: 160px;
  }
}

@media (width <= 480px) {
  .prorank-redirects-table {
    min-width: 720px;
  }

  .prorank-redirects-table code {
    max-width: 120px;
    font-size: 11px;
  }

  .prorank-redirects-table th,
  .prorank-redirects-table td {
    padding: 8px 6px;
    font-size: 13px;
  }
}

/* Regex Tester Component */
.prorank-regex-tester {
  margin-top: 16px;
  padding: 16px;
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.prorank-regex-tester__header {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.prorank-regex-tester__urls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.prorank-regex-tester__url-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.prorank-regex-tester__url-row .components-base-control {
  flex: 1;
  margin-bottom: 0;
}

.prorank-regex-tester__url-row .components-text-control__input {
  font-family: monospace;
  font-size: 13px;
}

.prorank-regex-tester__remove {
  flex-shrink: 0;
  padding: 4px 8px !important;
  min-width: auto !important;
}

.prorank-regex-tester__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.prorank-regex-tester__results {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.prorank-regex-tester__result {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  background: white;
  border: 1px solid #e5e7eb;
}

.prorank-regex-tester__result--match {
  border-color: #10b981;
  background: #ecfdf5;
}

.prorank-regex-tester__result--no-match {
  border-color: #ef4444;
  background: #fef2f2;
}

.prorank-regex-tester__result-header {
  display: flex;
  align-items: center;
}

.prorank-regex-tester__captures,
.prorank-regex-tester__resolved {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.prorank-regex-tester__capture {
  font-size: 11px;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

.prorank-regex-tester__capture code {
  background: none;
  padding: 0;
  color: #2563eb;
}