/* Feedback модалка и плавающая кнопка (product-strategy.md тема 6).
   Подключается на всех страницах через <link rel="stylesheet" href="feedback.css">. */

/* ===== ПЛАВАЮЩАЯ КНОПКА ===== */
.feedback-trigger {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: #fff;
  color: var(--accent, #c17a2a);
  border: 1.5px solid var(--line, #e8dcc8);
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transition: background 0.2s, transform 0.2s;
}
.feedback-trigger:hover { background: #fafafa; transform: translateY(-2px); }

.feedback-trigger { overflow: visible; }

.feedback-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 13px;
  height: 13px;
  background: #e03e3e;
  border-radius: 50%;
  border: 2px solid #fff;
  pointer-events: none;
  z-index: 1;
}

@media (max-width: 480px) {
  .feedback-badge {
    border-color: var(--accent, #c17a2a);
  }
}
.feedback-trigger span:first-child { font-size: 22px; line-height: 1; }

@media (max-width: 480px) {
  .feedback-trigger {
    padding: 12px 14px;
    right: 14px;
    bottom: 14px;
    background: #fff;
    color: var(--accent, #c17a2a);
    border: 2px solid var(--accent, #c17a2a);
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  }
  .feedback-trigger-text { display: none; }
}

/* ===== МОДАЛКА ===== */
.feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.feedback-modal.hidden { display: none; }

.feedback-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  animation: feedbackFadeIn 0.2s ease;
}

.feedback-dialog {
  position: relative;
  background: #fff;
  color: var(--text, #2c2416);
  border-radius: 16px;
  padding: 32px 28px 24px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
  animation: feedbackSlideUp 0.25s ease;
}

.feedback-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #999;
  padding: 6px 10px;
  line-height: 1;
}
.feedback-close:hover { color: #333; }

.feedback-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 18px;
  padding-right: 30px;
}

.feedback-section { margin-bottom: 18px; }
.feedback-section.hidden { display: none; }

.feedback-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted, #635541);
  margin-bottom: 8px;
}

.feedback-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-chip {
  padding: 8px 14px;
  background: #f5f0e8;
  border: 1px solid var(--border, #d9d2c5);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text, #2c2416);
  transition: all 0.15s;
}
.feedback-chip:hover { background: #ede7da; }
.feedback-chip.active {
  background: var(--accent, #c17a2a);
  color: #fff;
  border-color: var(--accent, #c17a2a);
}

.feedback-dialog textarea,
.feedback-dialog input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border, #d9d2c5);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text, #2c2416);
  background: #fff;
  resize: vertical;
}
.feedback-dialog textarea:focus,
.feedback-dialog input[type="email"]:focus {
  outline: 2px solid var(--accent, #c17a2a);
  outline-offset: 1px;
  border-color: transparent;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.feedback-actions .btn-primary,
.feedback-actions .btn-secondary {
  padding: 10px 22px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.feedback-actions .btn-primary {
  background: var(--accent, #c17a2a);
  color: #fff;
}
.feedback-actions .btn-primary:hover:not(:disabled) { background: var(--accent-hover, #a86520); }
.feedback-actions .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.feedback-actions .btn-secondary {
  background: #f5f0e8;
  color: var(--text, #2c2416);
}
.feedback-actions .btn-secondary:hover { background: #ede7da; }

.feedback-status {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.feedback-status.hidden { display: none; }
.feedback-status.success { background: #e4f4e1; color: #2a5a22; }
.feedback-status.error   { background: #fde6e6; color: #8a2828; }

@keyframes feedbackFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes feedbackSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 480px) {
  .feedback-dialog {
    padding: 24px 20px 20px;
    max-height: 90vh;
  }
  .feedback-title { font-size: 18px; }
  .feedback-chip { font-size: 12px; padding: 7px 12px; }
}

/* ===== CHAT WIDGET ===== */
.chat-widget {
  position: fixed;
  right: 20px;
  bottom: 78px;
  z-index: 901;
  width: 360px;
  filter: drop-shadow(0 8px 32px rgba(0,0,0,0.22));
}
.chat-widget.hidden { display: none; }

@keyframes chatWidgetOpen {
  from { transform: translateY(12px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}
.chat-widget:not(.hidden) {
  animation: chatWidgetOpen 0.2s ease;
}

.chat-dialog {
  background: #fff;
  color: var(--text, #2c2416);
  border-radius: 16px;
  width: 100%;
  height: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #d9d2c5);
  flex-shrink: 0;
}
.chat-back {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--accent, #c17a2a);
  padding: 4px 8px;
  line-height: 1;
}
.chat-back.hidden { display: none; }
.chat-header-title {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-close {
  background: transparent;
  border: none;
  font-size: 26px;
  cursor: pointer;
  color: #999;
  padding: 4px 8px;
  line-height: 1;
}
.chat-header-close:hover { color: #333; }

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-view.hidden { display: none; }

/* Thread list */
.chat-threads {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 4px;
}
.chat-thread-item {
  display: block;
  width: 100%;
  text-align: left;
  background: #faf6ef;
  border: 1px solid var(--border, #d9d2c5);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-thread-item:hover { background: #ede7da; }
.chat-thread-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  gap: 8px;
}
.chat-thread-type {
  font-weight: 600;
  font-size: 14px;
}
.chat-thread-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-new         { background: #dbeafe; color: #1e40af; }
.status-in-progress { background: #fef9c3; color: #854d0e; }
.status-resolved    { background: #dcfce7; color: #166534; }
.status-dismissed   { background: #f1f5f9; color: #64748b; }

.chat-thread-preview {
  font-size: 13px;
  color: var(--text-muted, #635541);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-thread-meta {
  font-size: 12px;
  color: #aaa;
}
.chat-empty {
  flex: 1;
  padding: 32px 20px 16px;
  text-align: center;
  color: var(--text-muted, #635541);
  font-size: 14px;
  line-height: 1.6;
}
.chat-empty.hidden { display: none; }

.chat-new-btn {
  margin: 6px 10px 10px;
  padding: 12px;
  width: calc(100% - 20px);
  background: var(--accent, #c17a2a);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.chat-new-btn:hover { background: var(--accent-hover, #a86520); }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-bubble--user {
  align-self: flex-end;
  background: var(--accent, #c17a2a);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble--admin {
  align-self: flex-start;
  background: #f5f0e8;
  color: var(--text, #2c2416);
  border-bottom-left-radius: 4px;
}
.chat-bubble-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

/* Reply area */
.chat-reply-area {
  border-top: 1px solid var(--border, #d9d2c5);
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-reply-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border, #d9d2c5);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  background: #fff;
  color: var(--text, #2c2416);
}
.chat-reply-input:focus {
  outline: 2px solid var(--accent, #c17a2a);
  outline-offset: 1px;
  border-color: transparent;
}
.chat-reply-send {
  padding: 10px 14px;
  background: var(--accent, #c17a2a);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s;
}
.chat-reply-send:disabled { background: #d9cfc3; color: #9a8878; cursor: default; }
.chat-reply-send:not(:disabled):hover { background: var(--accent-hover, #a86520); }

/* New message form */
.chat-new-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 10px;
  overflow: hidden;
}
.chat-new-hint {
  font-size: 13px;
  color: var(--text-muted, #635541);
  margin: 0;
}
.chat-new-form textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border, #d9d2c5);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text, #2c2416);
  background: #fff;
  resize: none;
}
.chat-new-form textarea:focus {
  outline: 2px solid var(--accent, #c17a2a);
  outline-offset: 1px;
  border-color: transparent;
}
.chat-new-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.chat-new-status {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
}
.chat-new-status.hidden { display: none; }
.chat-new-status.success { background: #e4f4e1; color: #2a5a22; }
.chat-new-status.error   { background: #fde6e6; color: #8a2828; }

/* Loading */
.chat-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--text-muted, #635541);
  font-size: 14px;
}
.chat-loading.hidden { display: none; }

/* Mobile backdrop (tap-outside-to-close) */
.chat-mobile-backdrop {
  display: none;
}
@media (max-width: 600px) {
  .chat-mobile-backdrop:not(.hidden) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 900;
  }
}

/* Mobile: bottom sheet */
@media (max-width: 600px) {
  .chat-widget {
    right: 0;
    bottom: 0;
    width: 100%;
    filter: drop-shadow(0 -4px 16px rgba(0,0,0,0.18));
  }
  .chat-dialog {
    border-radius: 16px 16px 0 0;
    height: 65vh;
    max-height: 560px;
  }
}

/* ===== REJECT FLOW (мелкая ссылка под результатом) ===== */
.reject-flow {
  margin-top: 14px;
  text-align: center;
}

.reject-link {
  background: transparent;
  border: none;
  color: var(--text-muted, #635541);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 12px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.reject-link:hover {
  color: var(--accent, #c17a2a);
  text-decoration-style: solid;
}
