/**
 * Стили виджета обратной связи Ananas.Click
 * Идеально вписаны в дизайн-систему сайта
 */

/* ===== CSS Custom Properties ===== */
:root {
  --fw-blue: #3f61db;
  --fw-blue-2: #2578fc;
  --fw-blue-gradient: linear-gradient(135deg, #4267eb, #213791);
  --fw-orange: #ff8e01;
  --fw-orange-gradient: linear-gradient(135deg, #ff8a00, #ff6b00);
  --fw-dark: #10152f;
  --fw-text: #1b1f33;
  --fw-muted: rgba(27, 31, 51, 0.72);
  --fw-gray: #f4f7ff;
  --fw-white: #ffffff;
  --fw-border: #dfe5f3;
  --fw-error: #d93025;
  --fw-success: #32ba7c;
  --fw-shadow: 0 18px 45px rgba(28, 51, 140, 0.14);
  --fw-font: 'Roboto', Arial, sans-serif;
}

/* ===== FAB Button ===== */
.fw-fab {
  position: fixed;
  bottom: 70px;
  right: 30px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--fw-blue-gradient);
  border: none;
  cursor: pointer;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(63, 97, 219, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fw-pulse 3s infinite;
}

/* ===== Badge ===== */
.fw-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  background: var(--fw-orange);
  color: #fff;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 8px rgba(255, 142, 1, 0.5);
  animation: fw-badge-pop 0.3s ease;
}

@keyframes fw-badge-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ===== Tabs ===== */
.fw-tabs {
  display: flex;
  gap: 8px;
  padding: 16px 16px 0;
  border-bottom: 2px solid var(--fw-border);
}

.fw-tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: var(--fw-font);
  font-size: 14px;
  font-weight: 500;
  color: var(--fw-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.fw-tab:hover {
  background: var(--fw-gray);
  color: var(--fw-blue);
}

.fw-tab.active {
  color: var(--fw-blue);
  border-bottom-color: var(--fw-blue);
}

/* ===== Broadcast List ===== */
.fw-broadcast-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fw-broadcast-item {
  padding: 16px;
  border-bottom: 1px solid var(--fw-border);
  cursor: pointer;
  transition: background 0.2s ease;
  position: relative;
}

.fw-broadcast-item:hover {
  background: var(--fw-gray);
}

.fw-broadcast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.fw-broadcast-header strong {
  color: var(--fw-text);
  font-size: 15px;
  font-weight: 600;
  padding-right: 8px;
}

.fw-broadcast-date {
  font-size: 12px;
  color: var(--fw-muted);
  white-space: nowrap;
}

.fw-broadcast-text {
  margin: 0 0 8px;
  color: var(--fw-muted);
  font-size: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fw-broadcast-unread {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 10px;
  height: 10px;
  background: var(--fw-orange);
  border-radius: 50%;
}

/* ===== Broadcast Detail ===== */
.fw-broadcast-content {
  padding: 20px 16px;
}

.fw-broadcast-content p {
  margin: 0 0 16px;
  color: var(--fw-text);
  font-size: 15px;
  line-height: 1.7;
}

.fw-broadcast-meta {
  font-size: 13px;
  color: var(--fw-muted);
  padding-top: 16px;
  border-top: 1px solid var(--fw-border);
}

/* ===== FAB ===== */
.fw-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(63, 97, 219, 0.55);
}

.fw-fab:active {
  transform: scale(0.95);
}

.fw-fab svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: transform 0.3s ease;
}

.fw-fab.fw-open svg.fw-icon-chat {
  display: none;
}

.fw-fab.fw-open svg.fw-icon-close {
  display: block;
}

.fw-fab svg.fw-icon-close {
  display: none;
}

@keyframes fw-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(63, 97, 219, 0.4); }
  50% { box-shadow: 0 4px 30px rgba(63, 97, 219, 0.6); }
}

/* ===== Notification Badge ===== */
.fw-fab .fw-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--fw-orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ===== Widget Window ===== */
.fw-window {
  position: fixed;
  bottom: 150px;
  right: 30px;
  width: 420px;
  height: 620px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 140px);
  border-radius: 20px;
  background: var(--fw-white);
  box-shadow: var(--fw-shadow);
  z-index: 99998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.fw-window.fw-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ===== Header ===== */
.fw-header {
  background: var(--fw-blue-gradient);
  color: #fff;
  padding: 18px 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fw-header-title {
  font-family: var(--fw-font);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.fw-header-subtitle {
  font-size: 12px;
  opacity: 0.8;
  margin: 4px 0 0;
}

.fw-header-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s;
}

.fw-header-close:hover {
  background: rgba(255,255,255,0.25);
}

/* ===== Body / Content ===== */
.fw-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: var(--fw-gray);
}

.fw-body::-webkit-scrollbar {
  width: 6px;
}

.fw-body::-webkit-scrollbar-track {
  background: transparent;
}

.fw-body::-webkit-scrollbar-thumb {
  background: rgba(63, 97, 219, 0.3);
  border-radius: 3px;
}

/* ===== Auth Form ===== */
.fw-auth {
  padding: 30px 24px;
}

.fw-auth h3 {
  font-family: var(--fw-font);
  font-size: 20px;
  font-weight: 700;
  color: var(--fw-text);
  margin: 0 0 6px;
}

.fw-auth p {
  font-size: 14px;
  color: var(--fw-muted);
  margin: 0 0 24px;
}

.fw-input-group {
  margin-bottom: 16px;
}

.fw-input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--fw-text);
  margin-bottom: 6px;
}

.fw-input {
  width: 100%;
  min-height: 54px;
  border: 2px solid var(--fw-border);
  border-radius: 16px;
  padding: 0 16px;
  font-family: var(--fw-font);
  font-size: 16px;
  color: var(--fw-text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.fw-input:focus {
  outline: none;
  border-color: var(--fw-blue);
  box-shadow: 0 0 0 3px rgba(63, 97, 219, 0.1);
}

.fw-input.fw-error {
  border-color: var(--fw-error);
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.1);
}

.fw-input::placeholder {
  color: #b0b8cc;
}

.fw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 30px;
  border: none;
  border-radius: 100px;
  font-family: var(--fw-font);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  text-decoration: none;
}

.fw-btn-primary {
  background: var(--fw-orange-gradient);
  color: #fff;
  width: 100%;
}

.fw-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 142, 1, 0.4);
}

.fw-btn-primary:active {
  transform: translateY(0);
}

.fw-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.fw-btn-secondary {
  background: var(--fw-gray);
  color: var(--fw-text);
}

.fw-btn-secondary:hover {
  background: #e8edf8;
}

.fw-btn-small {
  padding: 10px 20px;
  font-size: 13px;
}

/* ===== Ticket List ===== */
.fw-ticket-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fw-ticket-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--fw-gray);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.fw-ticket-item:hover {
  background: #fff;
}

.fw-ticket-item:last-child {
  border-bottom: none;
}

.fw-ticket-item-subject {
  font-family: var(--fw-font);
  font-size: 15px;
  font-weight: 500;
  color: var(--fw-text);
  margin: 0 0 4px;
  padding-right: 24px;
}

.fw-ticket-item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--fw-muted);
}

.fw-ticket-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}

.fw-ticket-status.open {
  background: rgba(50, 186, 124, 0.12);
  color: var(--fw-success);
}

.fw-ticket-status.closed {
  background: rgba(176, 184, 204, 0.2);
  color: #b0b8cc;
}

.fw-ticket-status.pending {
  background: rgba(255, 138, 0, 0.12);
  color: var(--fw-orange);
}

.fw-ticket-unread {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fw-blue);
}

/* ===== New Ticket Form ===== */
.fw-new-ticket {
  padding: 24px 20px;
}

.fw-new-ticket h3 {
  font-family: var(--fw-font);
  font-size: 18px;
  font-weight: 700;
  color: var(--fw-text);
  margin: 0 0 20px;
}

.fw-textarea {
  width: 100%;
  min-height: 100px;
  border: 2px solid var(--fw-border);
  border-radius: 16px;
  padding: 14px 16px;
  font-family: var(--fw-font);
  font-size: 15px;
  color: var(--fw-text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
  box-sizing: border-box;
}

.fw-textarea:focus {
  outline: none;
  border-color: var(--fw-blue);
  box-shadow: 0 0 0 3px rgba(63, 97, 219, 0.1);
}

/* ===== Dialogue / Messages ===== */
.fw-dialogue-header {
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--fw-gray);
  display: flex;
  align-items: center;
  gap: 12px;
}

.fw-dialogue-back {
  background: none;
  border: none;
  color: var(--fw-blue);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: opacity 0.2s;
}

.fw-dialogue-back:hover {
  opacity: 0.7;
}

.fw-dialogue-subject {
  font-family: var(--fw-font);
  font-size: 15px;
  font-weight: 600;
  color: var(--fw-text);
  margin: 0;
  flex: 1;
}

.fw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--fw-gray);
}

.fw-messages::-webkit-scrollbar {
  width: 4px;
}

.fw-messages::-webkit-scrollbar-thumb {
  background: rgba(63, 97, 219, 0.2);
  border-radius: 2px;
}

.fw-message {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 16px;
  font-family: var(--fw-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fw-text);
  word-wrap: break-word;
  animation: fw-msg-in 0.25s ease;
}

@keyframes fw-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fw-message.client {
  align-self: flex-end;
  background: var(--fw-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.fw-message.admin {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--fw-border);
  border-bottom-left-radius: 4px;
}

.fw-message-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  display: block;
}

.fw-message.client .fw-message-time {
  color: rgba(255,255,255,0.7);
  text-align: right;
}

/* ===== Message Input ===== */
.fw-message-input {
  padding: 16px 20px;
  background: #fff;
  border-top: 1px solid var(--fw-gray);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.fw-message-input .fw-textarea {
  min-height: 48px;
  max-height: 120px;
  flex: 1;
  resize: none;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 0;
}

.fw-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--fw-orange-gradient);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fw-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 142, 1, 0.4);
}

.fw-send-btn:active {
  transform: scale(0.95);
}

.fw-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.fw-send-btn svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

/* ===== Empty State ===== */
.fw-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 30px;
  text-align: center;
}

.fw-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--fw-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 28px;
}

.fw-empty h4 {
  font-family: var(--fw-font);
  font-size: 16px;
  font-weight: 600;
  color: var(--fw-text);
  margin: 0 0 8px;
}

.fw-empty p {
  font-size: 13px;
  color: var(--fw-muted);
  margin: 0;
}

/* ===== Loading ===== */
.fw-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.fw-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--fw-gray);
  border-top-color: var(--fw-blue);
  border-radius: 50%;
  animation: fw-spin 0.8s linear infinite;
}

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

/* ===== Notification Toast ===== */
.fw-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--fw-dark);
  color: #fff;
  padding: 14px 24px;
  border-radius: 12px;
  font-family: var(--fw-font);
  font-size: 14px;
  z-index: 100000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.fw-toast.fw-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.fw-toast.fw-success {
  background: var(--fw-success);
}

.fw-toast.fw-error {
  background: var(--fw-error);
}

/* ===== Actions Bar ===== */
.fw-actions {
  padding: 12px 20px;
  background: #fff;
  border-top: 1px solid var(--fw-gray);
  display: flex;
  gap: 10px;
}

.fw-actions .fw-btn {
  flex: 1;
}

/* ===== Overlay ===== */
.fw-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 21, 47, 0.3);
  z-index: 99997;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.fw-overlay.fw-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .fw-window {
    right: 10px;
    left: 10px;
    bottom: 100px;
    width: auto;
    height: calc(100vh - 120px);
    border-radius: 16px;
  }

  .fw-fab {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  .fw-fab svg {
    width: 24px;
    height: 24px;
  }

  .fw-message {
    max-width: 90%;
  }
}

