/* =============================================================================
   Contact Widget - Floating Chat Widget Styles
   ============================================================================= */

/* ---------- FAB Button ---------- */

.contact-widget-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}

.contact-widget-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.contact-widget-fab.active {
  background: var(--card-background);
  color: var(--primary-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ---------- Panel ---------- */

.contact-widget-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 520px;
  z-index: 9998;
  border-radius: 16px;
  background: var(--card-background);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.contact-widget-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ---------- Panel Header ---------- */

.contact-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--background-color);
  flex-shrink: 0;
}

.contact-widget-header-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary-color);
}

.contact-widget-header-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--border-radius-sm);
  color: var(--primary-color);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s, background-color 0.15s;
}

.contact-widget-header-close:hover {
  opacity: 1;
  background-color: var(--light-background);
}

/* ---------- Panel Body ---------- */

.contact-widget-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ---------- List View ---------- */

.contact-widget-list-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.contact-conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.contact-widget-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  margin: 0.5rem;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.contact-widget-new-btn:hover {
  opacity: 0.9;
}

/* ---------- Chat View ---------- */

.contact-widget-chat-view {
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ---------- Form View ---------- */

.contact-widget-form-view {
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ---------- Conversations List Items ---------- */

.contact-conversation-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.4rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s;
  border: 1px solid rgba(39, 76, 119, 0.1);
  background: var(--card-background);
  box-shadow: 0 2px 6px rgba(39, 76, 119, 0.06);
}

.contact-conversation-item:last-child {
  margin-bottom: 0;
}

.contact-conversation-item:hover {
  background-color: rgba(39, 76, 119, 0.04);
  border-color: rgba(39, 76, 119, 0.2);
  box-shadow: 0 3px 10px rgba(39, 76, 119, 0.1);
}

.contact-conversation-item.active {
  background-color: rgba(39, 76, 119, 0.06);
  border-color: var(--primary-color);
}

.contact-conversation-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.contact-conversation-subject {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  line-height: 1.3;
}

.contact-conversation-date {
  font-size: 0.75rem;
  color: #a0aab4;
  white-space: nowrap;
  flex-shrink: 0;
}

.contact-conversation-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.contact-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}

.contact-category-badge svg {
  flex-shrink: 0;
}

.contact-category-badge.bug {
  background-color: rgba(220, 53, 69, 0.1);
  color: #dc3545;
}

.contact-category-badge.question {
  background-color: rgba(23, 162, 184, 0.1);
  color: #17a2b8;
}

.contact-category-badge.suggestion {
  background-color: rgba(40, 167, 69, 0.1);
  color: #28a745;
}

.contact-category-badge.other {
  background-color: rgba(108, 117, 125, 0.1);
  color: #6c757d;
}

.contact-status-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-weight: 500;
}

.contact-status-badge.open {
  background-color: rgba(40, 167, 69, 0.1);
  color: #28a745;
}

.contact-status-badge.closed {
  background-color: rgba(108, 117, 125, 0.1);
  color: #6c757d;
}

.contact-status-badge.archived {
  background-color: rgba(108, 117, 125, 0.08);
  color: #a0aab4;
}

.contact-conversation-preview {
  font-size: 0.8rem;
  color: #8e99a4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* ---------- Chat Header ---------- */

.contact-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--background-color);
  gap: 0.5rem;
  flex-shrink: 0;
}

.contact-chat-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-radius: var(--border-radius-sm);
  color: var(--primary-color);
  cursor: pointer;
  flex-shrink: 0;
}

.contact-chat-back-btn:hover {
  background-color: var(--light-background);
}

.contact-chat-header-info {
  flex: 1;
  min-width: 0;
}

.contact-chat-subject {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-color);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-chat-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.1rem;
}

.contact-chat-close-btn {
  padding: 0.25rem 0.5rem;
  background: none;
  border: 1px solid #dc3545;
  border-radius: var(--border-radius-sm);
  color: #dc3545;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.contact-chat-close-btn:hover {
  background-color: #dc3545;
  color: #fff;
}

/* ---------- Messages area ---------- */

.contact-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

.contact-message {
  max-width: 85%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius-lg);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.contact-message--user {
  align-self: flex-end;
  background: var(--gradient-primary);
  color: #fff;
}

.contact-message--admin {
  align-self: flex-start;
  background: var(--light-background);
  color: var(--primary-color);
}

.contact-message-body {
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.contact-message-time {
  font-size: 0.6rem;
  opacity: 0.7;
  margin-top: 0.2rem;
  text-align: right;
}

.contact-message--admin .contact-message-sender {
  font-size: 0.65rem;
  font-weight: 600;
  margin-bottom: 0.1rem;
  opacity: 0.8;
}

/* ---------- Chat Input ---------- */

.contact-chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--background-color);
  align-items: flex-end;
  flex-shrink: 0;
}

.contact-chat-textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--background-color);
  border-radius: var(--border-radius-md);
  padding: 0.45rem 0.65rem;
  font-family: inherit;
  font-size: 0.8rem;
  min-height: 36px;
  max-height: 100px;
  outline: none;
  transition: border-color 0.15s;
  background: var(--card-background);
  color: var(--primary-color);
}

.contact-chat-textarea:focus {
  border-color: var(--primary-color);
}

.contact-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.contact-send-btn:hover {
  opacity: 0.9;
}

.contact-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.contact-chat-closed-notice {
  padding: 0.6rem 0.75rem;
  text-align: center;
  font-size: 0.75rem;
  color: #8e99a4;
  border-top: 1px solid var(--background-color);
  background-color: var(--light-background);
  flex-shrink: 0;
}

/* ---------- New Conversation Form ---------- */

.contact-new-form-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--background-color);
  flex-shrink: 0;
}

.contact-new-form-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-radius: var(--border-radius-sm);
  color: var(--primary-color);
  cursor: pointer;
}

.contact-new-form-back-btn:hover {
  background-color: var(--light-background);
}

.contact-new-form-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  margin: 0;
}

.contact-new-form-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.contact-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.contact-form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-color);
}

.contact-form-select,
.contact-form-input,
.contact-form-textarea {
  border: 1px solid var(--background-color);
  border-radius: var(--border-radius-md);
  padding: 0.45rem 0.65rem;
  font-family: inherit;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.15s;
  background: var(--card-background);
  color: var(--primary-color);
}

.contact-form-select:focus,
.contact-form-input:focus,
.contact-form-textarea:focus {
  border-color: var(--primary-color);
}

.contact-form-textarea {
  resize: vertical;
  min-height: 80px;
}

.contact-form-submit {
  padding: 0.55rem 1rem;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  align-self: flex-end;
}

.contact-form-submit:hover {
  opacity: 0.9;
}

.contact-form-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Empty State ---------- */

.contact-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #8e99a4;
  gap: 0.5rem;
  padding: 1.5rem;
}

.contact-empty-state svg {
  opacity: 0.4;
}

.contact-empty-state p {
  font-size: 0.8rem;
  text-align: center;
  margin: 0;
}

/* ---------- Loading ---------- */

.contact-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #8e99a4;
  font-size: 0.8rem;
}

/* ---------- Page Mode (contactform page) ---------- */

.contact-page-header-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--primary-color, #274c77) 0%, var(--secondary-color, #6096ba) 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(39, 76, 119, 0.25);
  color: #fff;
}

.contact-page-subtitle {
  margin: 0.75rem 0 0;
  font-size: 1.1rem;
  color: rgba(39, 76, 119, 0.7);
  font-weight: 400;
}

.contact-page-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem 1.5rem;
}

.contact-widget-panel.page-mode {
  position: relative;
  bottom: auto;
  right: auto;
  width: 100%;
  max-width: 420px;
  height: 460px;
  border-radius: 16px;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: none;
}

@media (max-width: 768px) {
  .contact-page-container {
    padding: 0.75rem;
  }

  .contact-widget-panel.page-mode {
    max-width: 100%;
    height: 420px;
    border-radius: var(--border-radius-lg);
  }

  .contact-page-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }

  .contact-page-subtitle {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .contact-page-container {
    padding: 0.5rem;
  }

  .contact-widget-panel.page-mode {
    border-radius: var(--border-radius-md);
    height: calc(100vh - 220px);
  }

  .contact-page-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .contact-page-subtitle {
    font-size: 0.8rem;
  }
}

/* ---------- Mobile: Quasi-fullscreen panel ---------- */

@media (max-width: 480px) {
  .contact-widget-fab {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }

  .contact-widget-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: calc(100vh - 60px);
    border-radius: 16px 16px 0 0;
  }

  .contact-widget-panel.open {
    bottom: 0;
  }
}
