/* ==========================================================================
   Redline Feedback Widget — Styles
   All classes prefixed .redline- to avoid host site conflicts.
   ========================================================================== */

/* Reset for all redline elements */
[class^="redline-"],
[class*=" redline-"] {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------------------------------------------------------------------------
   Overlay (PIN gate / identity modal backdrop)
   --------------------------------------------------------------------------- */

.redline-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------------------------------------------------------------------
   Modals (PIN gate + identity)
   --------------------------------------------------------------------------- */

.redline-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border-radius: 12px;
  padding: 32px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 100000;
  text-align: center;
}

.redline-modal h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: #1a1a1a;
}

.redline-modal p {
  margin: 0 0 20px 0;
  font-size: 14px;
  color: #666;
}

.redline-modal-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
  color: #1a1a1a;
  background: #fafafa;
}

.redline-modal-input:focus {
  border-color: #e74c3c;
  background: #fff;
}

.redline-modal-btn {
  display: block;
  width: 100%;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: #e74c3c;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.redline-modal-btn:hover {
  background: #c0392b;
}

.redline-modal-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.redline-modal-error {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}

.redline-modal-label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  margin-bottom: 4px;
}

.redline-modal-optional {
  font-weight: 400;
  color: #999;
}

/* Shake animation for invalid PIN */
.redline-modal.shake {
  animation: redline-shake 0.5s ease-in-out;
}

@keyframes redline-shake {
  0%, 100% { transform: translate(-50%, -50%); }
  10%, 50%, 90% { transform: translate(-52%, -50%); }
  30%, 70% { transform: translate(-48%, -50%); }
}

/* ---------------------------------------------------------------------------
   Feedback button (floating pill)
   --------------------------------------------------------------------------- */

.redline-feedback-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99997;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(231, 76, 60, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.redline-feedback-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
}

.redline-feedback-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.redline-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #e74c3c;
  background: #fff;
  border-radius: 10px;
  margin-left: 2px;
}

.redline-badge:empty {
  display: none;
}

/* ---------------------------------------------------------------------------
   Feedback panel (slide-out)
   --------------------------------------------------------------------------- */

.redline-panel {
  position: fixed;
  top: 0;
  right: -350px;
  width: 350px;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  transition: right 0.3s ease;
  z-index: 99998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.redline-panel.open {
  right: 0;
}

.redline-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.redline-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.redline-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.redline-panel-icon-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}

.redline-panel-icon-btn:hover {
  background: #f5f5f5;
  color: #e74c3c;
}

.redline-panel-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.redline-panel-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.redline-panel-close:hover {
  color: #333;
}

/* Tab bar */
.redline-panel-tabs {
  display: flex;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.redline-panel-tab {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #999;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.redline-panel-tab.active {
  color: #e74c3c;
  border-bottom-color: #e74c3c;
}

/* Compose area */
.redline-panel-compose {
  padding: 16px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.redline-panel-textarea {
  display: block;
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  color: #1a1a1a;
  background: #fafafa;
  transition: border-color 0.2s;
}

.redline-panel-textarea:focus {
  border-color: #e74c3c;
  background: #fff;
}

.redline-panel-submit {
  display: block;
  width: 100%;
  padding: 8px 16px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #e74c3c;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.redline-panel-submit:hover {
  background: #c0392b;
}

.redline-panel-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Comments list */
.redline-panel-comments {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.redline-comment {
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.redline-comment:last-child {
  border-bottom: none;
}

.redline-comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.redline-comment-author {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}

.redline-comment-time {
  font-size: 11px;
  color: #999;
}

.redline-comment-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  background: #e74c3c;
}

.redline-comment-type.pin {
  background: #3498db;
}

.redline-comment-text {
  font-size: 14px;
  color: #333;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.redline-panel-empty {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 14px;
}

/* ---------------------------------------------------------------------------
   Pin-drop mode
   --------------------------------------------------------------------------- */

.redline-pin-overlay {
  position: fixed;
  inset: 0;
  cursor: crosshair;
  background: rgba(0, 0, 0, 0.1);
  z-index: 99995;
}

.redline-pin-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #e74c3c;
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  z-index: 99996;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.redline-pin-banner-cancel {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
}

.redline-pin-banner-cancel:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Pin popover (comment input at pin location) */
.redline-pin-popover {
  position: absolute;
  width: 260px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  padding: 14px;
  z-index: 99996;
}

.redline-pin-popover textarea {
  display: block;
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 6px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  color: #1a1a1a;
}

.redline-pin-popover textarea:focus {
  border-color: #e74c3c;
}

.redline-pin-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.redline-pin-popover-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.redline-pin-popover-btn.cancel {
  background: #f0f0f0;
  color: #555;
}

.redline-pin-popover-btn.submit {
  background: #e74c3c;
  color: #fff;
}

/* ---------------------------------------------------------------------------
   Pin markers
   --------------------------------------------------------------------------- */

.redline-pin-marker {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 99990;
  transform: translate(-50%, -50%);
  transition: transform 0.15s;
  user-select: none;
}

.redline-pin-marker:hover {
  transform: translate(-50%, -50%) scale(1.2);
  z-index: 99991;
}

.redline-pin-marker.addressed {
  background: #999;
}

.redline-pin-marker.addressed::after {
  content: '\2713';
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 10px;
  background: #fff;
  color: #999;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Pin tooltip */
.redline-pin-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 99992;
}

.redline-pin-marker:hover .redline-pin-tooltip {
  opacity: 1;
}

.redline-pin-tooltip-author {
  font-weight: 600;
  margin-bottom: 2px;
}

.redline-pin-tooltip-text {
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------------------
   Toast notification
   --------------------------------------------------------------------------- */

.redline-toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: #1a1a1a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 100001;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
}

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

/* ---------------------------------------------------------------------------
   Addressed feedback banner
   --------------------------------------------------------------------------- */

.redline-addressed-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #2c3e50;
  color: #fff;
  padding: 12px 20px;
  font-size: 14px;
  z-index: 99993;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.redline-addressed-banner-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.redline-addressed-banner-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.redline-addressed-banner-dismiss {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.redline-addressed-banner-dismiss:hover {
  color: #fff;
}

/* Addressed items list inside panel */
.redline-addressed-item {
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.redline-addressed-item:last-child {
  border-bottom: none;
}

.redline-addressed-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
}

.redline-addressed-status.addressed {
  background: #27ae60;
  color: #fff;
}

.redline-addressed-status.noted {
  background: #f39c12;
  color: #fff;
}

.redline-addressed-status.deferred {
  background: #95a5a6;
  color: #fff;
}

.redline-addressed-comment {
  color: #555;
  margin-top: 4px;
}

.redline-addressed-response {
  color: #333;
  font-style: italic;
  margin-top: 4px;
}

/* ---------------------------------------------------------------------------
   Mobile responsive — bottom sheet
   --------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .redline-panel {
    top: auto;
    bottom: -70vh;
    right: 0;
    left: 0;
    width: 100%;
    height: 70vh;
    border-radius: 16px 16px 0 0;
    transition: bottom 0.3s ease;
  }

  .redline-panel.open {
    bottom: 0;
    right: 0;
  }

  .redline-panel.redline-bottom-sheet {
    /* Marker class for mobile detection */
  }

  .redline-modal {
    width: 90vw;
    padding: 24px;
  }
}
