/**
 * Configure Page Styles
 * Extracted from src/views/configure.js for better maintainability
 */

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f1f5f9; min-height: 100vh; padding: 20px; }
.container { max-width: 960px; margin: 0 auto; background: white; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.1); overflow: hidden; }
.header { background: #eef2ff; color: #111827; padding: 24px; text-align: left; border-bottom: 1px solid #e5e7eb; }
.brand { background: #4f46e5; color: #ffffff; padding: 16px 18px; border-radius: 10px; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 12px rgba(79,70,229,0.15); }
.brand h1 { font-size: 28px; margin: 0; line-height: 1.2; }
.brand .icon { font-size: 22px; opacity: 0.95; }
.brand .tag { background: rgba(255,255,255,0.15); color: #fff; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-left: auto; }
.header h2 { font-size: 18px; margin: 14px 0 6px 0; color: #111827; }
.subtitle { color: #374151; font-size: 14px; margin-bottom: 8px; }
.steps { margin: 6px 0 0 18px; color: #4b5563; font-size: 13px; }
.steps li { margin: 2px 0; }
.content { padding: 24px; }
.form-group { margin-bottom: 18px; }
label { display: block; font-weight: 600; margin-bottom: 6px; color: #333; font-size: 14px; }
input[type="text"], input[type="url"], input[type="email"], input[type="password"], select { width: 100%; padding: 10px 12px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 14px; }
.btn { background: #4f46e5; color: white; border: none; padding: 12px 22px; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn:hover { background: #4338ca; }
.row { display: grid; grid-template-columns: 2fr 1fr auto; gap: 10px; align-items: end; }
.row-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; align-items: start; }
.url-display { background: #f8fafc; padding: 10px; border: 1px solid #e2e8f0; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; overflow-wrap: break-word; }
.advanced-toggle { display: none; }
.advanced-options { display: block; margin-top: 8px; }
.section-title { font-size: 16px; font-weight: 700; margin: 6px 0 8px 0; color: #1f2937; }
.preview { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: #111827; white-space: pre-wrap; }
.install-btn { background: #0ea5e9; color: white; text-decoration: none; padding: 8px 14px; border-radius: 6px; display: inline-block; font-size: 13px; font-weight: 600; margin-left: 8px; }
.copy-btn { background: #22c55e; color: white; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.help-text { font-size: 12px; color: #666; margin-top: 5px; }
.login-section { background: #f0f9ff; border: 2px solid #0ea5e9; border-radius: 8px; padding: 16px; margin-bottom: 22px; }
.addon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.addon-card { background: white; border: 2px solid #e5e7eb; border-radius: 8px; padding: 12px; display: flex; align-items: center; gap: 10px; transition: all 0.2s; cursor: pointer; }
.addon-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.addon-card.wrappable { border-color: #10b981; }
.addon-card.not-wrappable { opacity: 0.6; cursor: not-allowed; }
.addon-card.already-wrapped { opacity: 1.0; cursor: pointer; background: #fffbeb; border-color: #f59e0b; }
.addon-card.already-wrapped.selected { background: #fef3c7; border-color: #d97706; }
.addon-card.selected { background: #dbeafe; border-color: #3b82f6; }
.addon-logo { width: 48px; height: 48px; object-fit: contain; background: #f3f4f6; border-radius: 6px; }
.addon-info { flex: 1; min-width: 0; }
.addon-name { font-weight: 600; font-size: 14px; color: #111827; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addon-status { font-size: 12px; color: #6b7280; display: flex; align-items: center; gap: 4px; }
.addon-card.not-wrappable .addon-status { color: #dc2626; font-weight: 500; }
.status-icon { font-size: 14px; }
.status-icon.wrappable { color: #10b981; }
.status-icon.not-wrappable { color: #ef4444; }
.addon-checkbox { width: 18px; height: 18px; cursor: pointer; }

/* Phase 1 & 2: Episode-Level Metadata Toggle & Individual Positioning Styles */
.metadata-control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.metadata-main-control {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0; /* Allow text truncation */
}

.metadata-position-control {
  flex: 0 0 100px;
  display: flex;
  align-items: center;
}

.metadata-position-select {
  width: 100%;
  padding: 4px 8px;
  font-size: 0.85em;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-family: inherit;
}

.metadata-position-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f3f4f6;
}

.metadata-position-select:not(:disabled):hover {
  border-color: #cbd5e1;
}

.metadata-position-select:not(:disabled):focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.metadata-episode-control {
  flex: 0 0 120px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.8;
  justify-content: flex-end;
}

.small-label {
  font-size: 0.85em;
  margin: 0;
  color: #6b7280;
  white-space: nowrap;
  font-weight: 500;
}

.episode-metadata-toggle {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.episode-metadata-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* Metadata Box Layout - Individual boxes for each metadata option */
.metadata-box {
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.metadata-box:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.metadata-box-header {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.metadata-toggle-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 0;
}

.metadata-toggle-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metadata-toggle-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.metadata-toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metadata-toggle-control input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

.metadata-toggle-control label {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin: 0;
  cursor: pointer;
}

.metadata-position-dropdown {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-family: inherit;
  margin-top: 2px;
}

.metadata-position-dropdown:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f3f4f6;
}

.metadata-position-dropdown:not(:disabled):hover {
  border-color: #cbd5e1;
}

.metadata-position-dropdown:not(:disabled):focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.metadata-extra-options {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  display: none;
}

.metadata-extra-options.visible {
  display: block;
}

.metadata-extra-options .form-group {
  margin-bottom: 12px;
}

.metadata-extra-options .form-group:last-child {
  margin-bottom: 0;
}

/* Responsive design for metadata boxes */
@media (max-width: 600px) {
  .metadata-toggle-section {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .metadata-toggle-column {
    padding-bottom: 8px;
  }

  .metadata-toggle-column:first-child {
    border-bottom: 1px solid #e5e7eb;
  }
}

/* Phase 3: Accordion Metadata Ordering */
.metadata-order-accordion {
  margin-bottom: 15px;
}

.accordion-header {
  cursor: pointer;
  background: #f3f4f6;
  padding: 10px 12px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  transition: background-color 0.2s;
}

.accordion-header:hover {
  background: #e5e7eb;
}

.accordion-content {
  padding: 10px 0;
}

/* Metadata order list styling */
.metadata-order-list {
  list-style: none;
  padding: 0;
  margin: 0;
  min-height: 40px;
  background: #f9fafb;
  border: 2px dashed #d1d5db;
  border-radius: 4px;
  padding: 8px;
}

.metadata-order-list:empty::after {
  content: 'Check metadata options above to add items';
  display: block;
  text-align: center;
  color: #9ca3af;
  font-style: italic;
  padding: 10px;
  font-size: 13px;
}

.metadata-order-item {
  background: white;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  transition: all 0.2s;
}

.metadata-order-item:hover {
  border-color: #4f46e5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.metadata-order-item.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.order-actions {
  display: flex;
  gap: 4px;
}

.order-actions button {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s;
}

.order-actions button:hover {
  background: #e5e7eb;
}

.order-actions button:active {
  background: #d1d5db;
}

/* Remove button styling */
.order-actions .remove-btn {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  font-weight: bold;
  margin-left: 4px;
}

.order-actions .remove-btn:hover {
  background: #fecaca;
  border-color: #f87171;
}

.order-actions .remove-btn:active {
  background: #fca5a5;
}

/* Metadata ordering section - enhanced visual separation */
#metadataOrderSection {
  margin-top: 40px;
  padding: 25px;
  background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
  border: 2px solid #4f46e5;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(79, 70, 229, 0.1);
}

#metadataOrderSection h3 {
  margin-top: 0;
  margin-bottom: 20px;
  color: #4f46e5;
  font-size: 20px;
  font-weight: 700;
}

.ordering-instructions {
  background: #eff6ff;
  border-left: 4px solid #3b82f6;
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: 4px;
  font-size: 14px;
  color: #1e40af;
}

.ordering-instructions strong {
  display: block;
  margin-bottom: 6px;
  color: #1e3a8a;
}

/* ========================================
   Tools Tab Styles
   ======================================== */

/* Tab Navigation */
.tab-navigation {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin: 0 24px;
  background: #f9fafb;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: 14px 20px;
  background: transparent;
  border: none;
  font-size: 15px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: #e5e7eb;
  color: #374151;
}

.tab-btn.active {
  background: white;
  color: #4f46e5;
  border-bottom: 3px solid #4f46e5;
  margin-bottom: -2px;
}

.tab-content {
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Auth Gate */
.tools-auth-gate {
  padding: 24px;
}

.auth-gate-card {
  background: #f0f9ff;
  border: 2px solid #38bdf8;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  margin: 40px auto;
}

.auth-gate-card i {
  font-size: 48px;
  color: #0284c7;
  margin-bottom: 16px;
  display: block;
}

.auth-gate-card h3 {
  color: #0369a1;
  margin-bottom: 8px;
}

.auth-gate-card p {
  color: #075985;
  margin-bottom: 20px;
}

/* Tools Content */
#tools-content {
  padding: 24px;
}

/* Tools Sections */
.tools-section {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.tools-section .section-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #111827;
  margin-bottom: 8px;
  font-size: 18px;
}

.tools-section .section-header h3 i {
  color: #4f46e5;
}

.tools-section .section-header p {
  color: #6b7280;
  font-size: 14px;
  margin-bottom: 16px;
}

.tools-loading {
  padding: 20px;
  text-align: center;
  color: #6b7280;
  font-style: italic;
}

.tools-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Addon Reorder List */
.addon-reorder-container {
  max-height: 400px;
  overflow-y: auto;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
}

.addon-reorder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.2s;
}

.addon-reorder-item:hover {
  background: #f9fafb;
}

.addon-reorder-item:last-child {
  border-bottom: none;
}

.addon-reorder-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.addon-reorder-info .addon-logo {
  width: 36px;
  height: 36px;
}

.addon-reorder-details {
  flex: 1;
  min-width: 0;
}

.addon-reorder-details .addon-name {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.addon-reorder-details .addon-id {
  font-size: 11px;
  color: #9ca3af;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.addon-reorder-controls {
  display: flex;
  gap: 4px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #374151;
}

.btn-icon:hover:not(:disabled) {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon.btn-danger {
  color: #dc2626;
  border-color: #fecaca;
}

.btn-icon.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}

/* Toggle Switches */
.cinemeta-options {
  margin-bottom: 8px;
}

.toggle-option {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #fafafa;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d1d5db;
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: #ef4444;
}

input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

.toggle-label {
  flex: 1;
}

.toggle-label strong {
  display: block;
  color: #111827;
  margin-bottom: 4px;
}

.toggle-label span {
  font-size: 13px;
  color: #6b7280;
}

/* Catalog Sub-Options */
.catalog-sub-options {
  margin-left: 32px;
  margin-bottom: 12px;
  padding: 12px 16px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
}

.sub-options-header {
  font-size: 13px;
  font-weight: 600;
  color: #0369a1;
  margin-bottom: 12px;
}

.sub-toggle-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e0f2fe;
  border-radius: 6px;
  margin-bottom: 8px;
  background: white;
}

.sub-toggle-option:last-child {
  margin-bottom: 0;
}

.toggle-switch.small {
  width: 40px;
  height: 22px;
}

.toggle-switch.small .toggle-slider:before {
  height: 16px;
  width: 16px;
}

.toggle-switch.small input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

.sub-toggle-option .toggle-label strong {
  font-size: 13px;
}

.sub-toggle-option .toggle-label span {
  font-size: 12px;
}

/* State Indicator */
.state-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #f3f4f6;
  border-radius: 8px;
  margin-bottom: 16px;
}

.state-label {
  font-weight: 600;
  color: #374151;
}

.state-value {
  color: #6b7280;
}

.state-value.state-modified {
  color: #f59e0b;
  font-weight: 600;
}

.state-value.state-default {
  color: #10b981;
  font-weight: 600;
}

/* Warning Box */
.warning-box {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 16px;
}

.warning-box i {
  color: #f59e0b;
  margin-top: 2px;
}

/* Backup Cards */
.backup-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.backup-card {
  background: #f9fafb;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.backup-card i {
  font-size: 36px;
  color: #6b7280;
  margin-bottom: 12px;
  display: block;
}

.backup-card h4 {
  color: #111827;
  margin-bottom: 8px;
}

.backup-card p {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 16px;
}

/* Backup Preview */
#backup-preview {
  background: #f0fdf4;
  border: 2px solid #86efac;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.backup-info {
  margin-bottom: 12px;
}

.backup-info p {
  margin: 4px 0;
  font-size: 14px;
  color: #374151;
}

.backup-addon-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  padding: 8px;
}

.backup-addon-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 13px;
  color: #374151;
}

.backup-addon-item img {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: #f3f4f6;
}

.backup-more {
  padding: 8px;
  text-align: center;
  color: #6b7280;
  font-style: italic;
  font-size: 12px;
}

/* Button Variants */
.btn-primary {
  background: #4f46e5;
  color: white;
}

.btn-primary:hover {
  background: #4338ca;
}

.btn-secondary {
  background: #6b7280;
  color: white;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

/* Status Messages */
.status-message {
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 14px;
}

.status-message.success {
  background: #d1fae5;
  border: 1px solid #10b981;
  color: #065f46;
}

.status-message.error {
  background: #fee2e2;
  border: 1px solid #ef4444;
  color: #991b1b;
}

.status-message.loading {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
}

/* Mobile Responsive for Tools Tab */
@media (max-width: 600px) {
  .tab-btn {
    padding: 12px 10px;
    font-size: 13px;
  }

  .tab-btn i {
    display: none;
  }

  .addon-reorder-controls {
    flex-direction: column;
  }

  .toggle-option {
    flex-direction: column;
    gap: 12px;
  }

  .backup-actions {
    grid-template-columns: 1fr;
  }

  .tools-actions {
    flex-direction: column;
  }

  .tools-actions .btn {
    width: 100%;
  }
}
