/**
 * Milemarker Documentation Change Request Widget v2
 * Enhanced turnkey editing styles
 */

/* Milemarker Brand Colors */
:root {
  --mm-widget-orange: #F26522;
  --mm-widget-orange-dark: #d9561b;
  --mm-widget-orange-light: #ff7a3d;
  --mm-widget-navy: #1e3a5f;
  --mm-widget-navy-dark: #0f2744;
}

/* Widget Container */
.mm-docs-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Floating Button */
.mm-widget-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--mm-widget-orange) 0%, var(--mm-widget-orange-dark) 100%);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  box-shadow:
    0 4px 14px -2px rgba(242, 101, 34, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  transition: all 0.2s ease;
  font-family: inherit;
}

.mm-widget-trigger:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px -4px rgba(242, 101, 34, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.mm-widget-trigger:active {
  transform: translateY(0);
}

.mm-widget-trigger svg {
  width: 18px;
  height: 18px;
}

/* Panel */
.mm-widget-panel {
  position: absolute;
  bottom: 60px;
  left: 0;
  width: 400px;
  max-height: 85vh;
  background: white;
  border-radius: 16px;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.95);
  transform-origin: bottom left;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mm-widget-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Dark mode support */
.dark .mm-widget-panel {
  background: #1e293b;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Panel Header */
.mm-panel-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #fff8f5 0%, #ffffff 100%);
  flex-shrink: 0;
}

.dark .mm-panel-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(242, 101, 34, 0.1) 0%, #1e293b 100%);
}

.mm-panel-header h3 {
  margin: 0 0 4px 0;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
}

.dark .mm-panel-header h3 {
  color: #f8fafc;
}

.mm-panel-header p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

.dark .mm-panel-header p {
  color: #94a3b8;
}

.mm-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #64748b;
  transition: all 0.15s ease;
}

.dark .mm-close-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

.mm-close-btn:hover {
  background: #e2e8f0;
  color: #475569;
}

.dark .mm-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f8fafc;
}

/* Panel Body */
.mm-panel-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Form Elements */
.mm-form-group {
  margin-bottom: 16px;
}

.mm-form-group:last-child {
  margin-bottom: 0;
}

.mm-form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dark .mm-form-label {
  color: #e2e8f0;
}

.mm-form-label .optional {
  font-weight: 400;
  color: #9ca3af;
  text-transform: none;
}

/* Context Info Container */
.mm-context-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

/* Page URL field */
.mm-page-url {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 11px;
  color: #64748b;
}

.dark .mm-page-url {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

.mm-page-url svg {
  flex-shrink: 0;
  color: var(--mm-widget-orange);
}

.mm-page-url span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* User Info in Context */
.mm-context-info #mm-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 6px;
  font-size: 11px;
  color: #7c3aed;
  font-weight: 500;
}

.dark .mm-context-info #mm-user-info {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
  color: #a78bfa;
}

.mm-context-info #mm-user-info svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Current Section Display */
.mm-current-section-container {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 6px;
  font-size: 11px;
  color: #7c3aed;
  margin-top: 8px;
}

.dark .mm-current-section-container {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
  color: #a78bfa;
}

.mm-current-section-container svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Selected Text Display */
#mm-selected-text-container {
  display: none;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.04));
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.dark #mm-selected-text-container {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.mm-selected-text-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.mm-selected-text-header > span {
  font-size: 11px;
  font-weight: 600;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mm-selected-text-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mm-selected-text-label svg {
  width: 12px;
  height: 12px;
}

.mm-clear-text-btn,
#mm-clear-selected-text {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: transparent;
  border: none;
  font-size: 10px;
  color: #64748b;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
}

.mm-clear-text-btn:hover,
#mm-clear-selected-text:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #374151;
}

.dark .mm-clear-text-btn:hover,
.dark #mm-clear-selected-text:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.mm-clear-text-btn svg,
#mm-clear-selected-text svg {
  width: 10px;
  height: 10px;
}

#mm-selected-text {
  font-size: 13px;
  color: #1e293b;
  line-height: 1.4;
  font-style: italic;
  padding-left: 10px;
  border-left: 2px solid #3b82f6;
}

.dark #mm-selected-text {
  color: #e2e8f0;
}

/* Quick Fix Pills */
.mm-quick-fixes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.mm-quick-fix {
  padding: 6px 12px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  color: #92400e;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dark .mm-quick-fix {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
  color: #fbbf24;
}

.mm-quick-fix:hover {
  background: #fde68a;
  border-color: #f59e0b;
}

.dark .mm-quick-fix:hover {
  background: rgba(251, 191, 36, 0.25);
  border-color: rgba(251, 191, 36, 0.5);
}

.mm-quick-fix.selected {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: transparent;
  color: white;
}

.mm-quick-fix svg {
  width: 12px;
  height: 12px;
}

/* Change Type Pills */
.mm-change-types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mm-change-type {
  padding: 8px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.dark .mm-change-type {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

.mm-change-type:hover {
  background: #fff8f5;
  border-color: #fcd5c3;
  color: var(--mm-widget-orange-dark);
}

.dark .mm-change-type:hover {
  background: rgba(242, 101, 34, 0.1);
  border-color: rgba(242, 101, 34, 0.3);
  color: var(--mm-widget-orange);
}

.mm-change-type.selected {
  background: linear-gradient(135deg, var(--mm-widget-orange) 0%, var(--mm-widget-orange-dark) 100%);
  border-color: transparent;
  color: white;
}

/* Priority Toggle */
.mm-priority-toggle {
  display: flex;
  gap: 8px;
}

.mm-priority-btn {
  flex: 1;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.dark .mm-priority-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

.mm-priority-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.dark .mm-priority-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mm-priority-btn.selected {
  background: #f8fafc;
  border-color: var(--mm-widget-orange);
  color: var(--mm-widget-orange);
}

.mm-priority-btn.selected[data-priority="high"] {
  background: #fef2f2;
  border-color: #ef4444;
  color: #dc2626;
}

.mm-priority-btn.selected[data-priority="critical"] {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  border-color: transparent;
  color: white;
}

.dark .mm-priority-btn.selected {
  background: rgba(242, 101, 34, 0.1);
}

.dark .mm-priority-btn.selected[data-priority="high"] {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
}

.dark .mm-priority-btn.selected[data-priority="critical"] {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  border-color: transparent;
  color: white;
}

.mm-priority-btn svg {
  width: 14px;
  height: 14px;
}

/* Textarea */
.mm-textarea {
  width: 100%;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: #1e293b;
  resize: vertical;
  min-height: 80px;
  transition: all 0.15s ease;
}

.dark .mm-textarea {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.mm-textarea:focus {
  outline: none;
  border-color: var(--mm-widget-orange);
  box-shadow: 0 0 0 3px rgba(242, 101, 34, 0.1);
}

.mm-textarea::placeholder {
  color: #94a3b8;
}

.mm-textarea-small {
  min-height: 60px;
}

/* Suggested Fix Container */
#mm-suggested-fix-container {
  display: none;
}

#mm-suggested-fix {
  width: 100%;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(16, 185, 129, 0.02));
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #1e293b;
  resize: vertical;
  min-height: 60px;
  transition: all 0.15s ease;
}

.dark #mm-suggested-fix {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #f8fafc;
}

#mm-suggested-fix:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

#mm-suggested-fix::placeholder {
  color: #6b7280;
}

.mm-suggested-fix-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #10b981;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mm-suggested-fix-label svg {
  width: 12px;
  height: 12px;
}

/* Submit Button */
.mm-submit-btn {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--mm-widget-orange) 0%, var(--mm-widget-orange-dark) 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.mm-submit-btn:hover:not(:disabled) {
  box-shadow: 0 4px 12px -2px rgba(242, 101, 34, 0.4);
  transform: translateY(-1px);
}

.mm-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Button Text and Loading States */
.mm-btn-text {
  display: inline;
}

.mm-btn-loading {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.mm-spinner {
  animation: mm-spin 1s linear infinite;
}

/* Loading State */
.mm-submit-btn.loading .mm-btn-text {
  display: none;
}

.mm-submit-btn.loading .mm-btn-loading {
  display: inline-flex;
}

@keyframes mm-spin {
  to { transform: rotate(360deg); }
}

/* Success State */
.mm-success-state {
  display: none;
  text-align: center;
  padding: 32px 24px;
}

.mm-success-state.show {
  display: block;
}

.mm-success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mm-success-icon svg {
  width: 32px;
  height: 32px;
  color: white;
}

.mm-success-state h4 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.dark .mm-success-state h4 {
  color: #f8fafc;
}

.mm-success-state p {
  margin: 0 0 20px;
  font-size: 14px;
  color: #64748b;
  line-height: 1.5;
}

.dark .mm-success-state p {
  color: #94a3b8;
}

#mm-issue-link {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  margin-bottom: 12px;
  transition: all 0.15s ease;
}

#mm-issue-link:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.dark #mm-issue-link {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.dark #mm-issue-link:hover {
  background: rgba(255, 255, 255, 0.15);
}

#mm-issue-link svg {
  width: 14px;
  height: 14px;
}

.mm-another-btn {
  padding: 10px 20px;
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}

.dark .mm-another-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.mm-another-btn:hover {
  background: #e2e8f0;
}

.dark .mm-another-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* File Upload Area */
.mm-file-upload {
  position: relative;
}

.mm-file-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  background: #f8fafc;
  border: 2px dashed #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dark .mm-file-label {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.mm-file-label:hover {
  background: #fff8f5;
  border-color: var(--mm-widget-orange);
}

.dark .mm-file-label:hover {
  background: rgba(242, 101, 34, 0.05);
  border-color: rgba(242, 101, 34, 0.3);
}

.mm-file-label svg {
  width: 20px;
  height: 20px;
  color: #94a3b8;
}

.mm-file-label span {
  font-size: 11px;
  color: #64748b;
  text-align: center;
}

.dark .mm-file-label span {
  color: #94a3b8;
}

.mm-file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
}

/* Image Previews */
#mm-image-previews {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mm-image-preview {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.dark .mm-image-preview {
  border-color: rgba(255, 255, 255, 0.1);
}

.mm-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mm-remove-image {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: white;
  padding: 0;
  transition: background 0.15s ease;
}

.mm-remove-image:hover {
  background: rgba(239, 68, 68, 0.9);
}

/* Toast Notifications */
.mm-toast {
  position: fixed;
  bottom: 100px;
  left: 24px;
  padding: 12px 20px;
  background: #1e293b;
  color: white;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

.mm-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mm-toast-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.mm-toast-error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.mm-toast-success {
  background: linear-gradient(135deg, #10b981, #059669);
}

/* Hide on login and admin pages */
body.login-page .mm-docs-widget,
.login-page .mm-docs-widget,
body.admin-page .mm-docs-widget,
.admin-page .mm-docs-widget {
  display: none !important;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .mm-docs-widget {
    bottom: 20px;
    left: auto;
    right: 16px;
  }

  /* iOS-style floating action button */
  .mm-widget-trigger {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    box-shadow:
      0 4px 12px rgba(242, 101, 34, 0.4),
      0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .mm-widget-trigger span {
    display: none;
  }

  .mm-widget-trigger svg {
    width: 24px;
    height: 24px;
  }

  .mm-widget-panel {
    width: calc(100vw - 32px);
    max-width: 380px;
    left: auto;
    right: 0;
    bottom: 86px;
    max-height: 70vh;
  }

  .mm-panel-body {
    padding: 16px 20px 20px;
  }

  .mm-quick-fixes {
    gap: 4px;
  }

  .mm-quick-fix {
    padding: 5px 10px;
    font-size: 11px;
  }

  .mm-toast {
    left: 16px;
    right: 16px;
    bottom: 90px;
  }
}
