/**
 * Yaraa AI Conversations Page Styles.
 *
 * @package    YaraaAI.
 * @subpackage YaraaAI/admin/css.
 */

/* Page Styles. */
.yaraa-conversations-page h1 {
  font-size: 28px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Notice.*/
.yaraa-notice {
  background: #fff;
  border-left: 4px solid #dba617;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.yaraa-notice p {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Stats Bar. */
.yaraa-stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.yaraa-stat-item {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
}

.yaraa-stat-item:nth-child(1) {
  border-left: 4px solid #6366f1;
}

.yaraa-stat-item:nth-child(2) {
  border-left: 4px solid #10b981;
}

.yaraa-stat-item:nth-child(3) {
  border-left: 4px solid #8b5cf6;
}

.yaraa-stat-item:nth-child(4) {
  border-left: 4px solid #f59e0b;
}

.yaraa-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.yaraa-stat-item:nth-child(1) .yaraa-stat-icon {
  background: #ede9fe;
  color: #7c3aed;
}

.yaraa-stat-item:nth-child(2) .yaraa-stat-icon {
  background: #d1fae5;
  color: #059669;
}

.yaraa-stat-item:nth-child(3) .yaraa-stat-icon {
  background: #f3e8ff;
  color: #9333ea;
}

.yaraa-stat-item:nth-child(4) .yaraa-stat-icon {
  background: #fef3c7;
  color: #d97706;
}

.yaraa-stat-icon .dashicons {
  font-size: 22px;
  width: 22px;
  height: 22px;
}

.yaraa-stat-label {
  display: block;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 6px;
}

.yaraa-stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: #1e293b;
}

/* Table Container. */
.yaraa-table-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.yaraa-table-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.yaraa-table-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.yaraa-bulk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.yaraa-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
}

.yaraa-search-box {
  position: relative;
  flex: 1;
  max-width: 300px;
}

.yaraa-search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
}

.yaraa-search-box::before {
  content: "\f179";
  font-family: dashicons;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.yaraa-filter-box select,
.yaraa-filter-box select#conversations-status-filter {
  padding: 8px 32px 8px 12px !important;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  background-color: #fff !important;
  min-width: 130px;
  height: auto;
  cursor: pointer;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 12px !important;
}

.yaraa-filter-box select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Loading State. */
.yaraa-loading-state {
  text-align: center;
  padding: 60px 20px;
}

.yaraa-loading-state .dashicons {
  font-size: 40px;
  width: 40px;
  height: 40px;
  color: #6366f1;
}

.yaraa-spin {
  animation: yaraa-spin 1s linear infinite;
}

@keyframes yaraa-spin {
  100% {
    transform: rotate(360deg);
  }
}

/* Table. */
.yaraa-conversations-table {
  width: 100%;
  border-collapse: collapse;
}

.yaraa-conversations-table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  border-bottom: 1px solid #e2e8f0;
}

.yaraa-conversations-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.yaraa-conversations-table tr:hover {
  background: #f8fafc;
}

/* Visitor Info. */
.yaraa-visitor-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.yaraa-visitor-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  position: relative;
}

.yaraa-visitor-avatar.online::after {
  content: "";
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #fff;
  border-radius: 50%;
}

.yaraa-visitor-details strong {
  display: block;
  color: #1e293b;
  font-size: 14px;
  margin-bottom: 2px;
}

.yaraa-visitor-meta {
  font-size: 12px;
  color: #64748b;
}

.yaraa-visitor-meta span {
  margin-right: 12px;
}

.yaraa-visitor-meta .dashicons {
  font-size: 12px;
  width: 12px;
  height: 12px;
  vertical-align: middle;
}

.yaraa-visitor-badges {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.yaraa-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.yaraa-badge .dashicons {
  font-size: 12px;
  width: 12px;
  height: 12px;
}

.yaraa-badge-success {
  background: #d1fae5;
  color: #059669;
}

.yaraa-badge-warning {
  background: #fef3c7;
  color: #d97706;
}

.yaraa-badge-info {
  background: #dbeafe;
  color: #2563eb;
}

/* Message Count. */
.yaraa-message-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #f1f5f9;
  border-radius: 16px;
  font-size: 13px;
  color: #475569;
}

.yaraa-message-count .dashicons {
  font-size: 14px;
  width: 14px;
  height: 14px;
  color: #94a3b8;
}

/* Status Badge. */
.yaraa-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
}

.yaraa-status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.yaraa-status-badge.status-active {
  background: #d1fae5;
  color: #059669;
}

.yaraa-status-badge.status-active::before {
  background: #10b981;
}

.yaraa-status-badge.status-closed {
  background: #f1f5f9;
  color: #64748b;
}

.yaraa-status-badge.status-closed::before {
  background: #94a3b8;
}

/* Time. */
.yaraa-time {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.yaraa-time-primary {
  color: #334155;
  font-weight: 500;
  font-size: 13px;
}

.yaraa-time-secondary {
  font-size: 11px;
  color: #94a3b8;
}

/* Actions. */
.yaraa-actions {
  display: flex;
  gap: 6px;
}

.yaraa-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: all 0.15s;
}

.yaraa-action-btn:hover {
  background: #f8fafc;
  color: #334155;
}

.yaraa-action-btn.view:hover {
  background: #ede9fe;
  border-color: #c4b5fd;
  color: #7c3aed;
}

.yaraa-action-btn.delete:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.yaraa-action-btn .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

/* Empty State. */
.yaraa-empty-state-container {
  padding: 60px 20px;
}

.yaraa-empty-state {
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}

.yaraa-empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: #ede9fe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yaraa-empty-state-icon .dashicons {
  font-size: 36px;
  width: 36px;
  height: 36px;
  color: #7c3aed;
}

.yaraa-empty-state h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #1e293b;
}

.yaraa-empty-state p {
  margin: 0 0 20px;
  color: #64748b;
  font-size: 14px;
}

.yaraa-empty-state-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff !important;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
}

.yaraa-empty-state-btn:hover {
  color: #fff !important;
  opacity: 0.9;
}

/* Pagination. */
.yaraa-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.yaraa-pagination-info {
  font-size: 14px;
  color: #64748b;
}

.yaraa-pagination-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
}

.yaraa-pagination-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yaraa-pagination-btn:hover:not(:disabled):not(.active) {
  background: #f8fafc;
  color: #334155;
}

.yaraa-pagination-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
}

.yaraa-pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.yaraa-pagination-ellipsis {
  padding: 0 8px;
  color: #94a3b8;
}

/* Modal. */
.yaraa-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yaraa-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.yaraa-modal-container {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.yaraa-modal-lg {
  max-width: 1200px;
}

.yaraa-modal-sm {
  max-width: 400px;
}

.yaraa-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.yaraa-modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #2563eb;
  display: flex;
  align-items: center;
  gap: 8px;
}

.yaraa-modal-header h3 .dashicons {
  color: #2563eb;
}

.yaraa-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #64748b;
  padding: 0;
  line-height: 1;
}

.yaraa-modal-close:hover {
  color: #1e293b;
}

.yaraa-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.yaraa-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.yaraa-modal-loading {
  text-align: center;
  padding: 60px 20px;
  color: #64748b;
}

.yaraa-modal-loading .dashicons {
  font-size: 40px;
  width: 40px;
  height: 40px;
  color: #6366f1;
}

/* Visitor Card.*/
.yaraa-visitor-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.yaraa-visitor-card-header {
  display: flex;
  gap: 20px;
}

.yaraa-visitor-avatar-lg {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 20px;
  flex-shrink: 0;
}

.yaraa-visitor-card-content {
  flex: 1;
}

.yaraa-visitor-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 12px;
}

.yaraa-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.yaraa-info-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.yaraa-info-value {
  font-size: 14px;
  color: #1e293b;
  font-weight: 500;
}

.yaraa-info-value .dashicons {
  font-size: 14px;
  width: 14px;
  height: 14px;
  vertical-align: middle;
  margin-right: 4px;
}

/* Conversation History. */
.yaraa-conversation-history {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}

.yaraa-conversation-history-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.yaraa-conversation-history-header h4 {
  margin: 0;
  font-size: 16px;
  color: #1e293b;
}

/* Accordion. */
.yaraa-accordion-item {
  border-bottom: 1px solid #e2e8f0;
}

.yaraa-accordion-item:last-child {
  border-bottom: none;
}

.yaraa-accordion-header {
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  transition: background 0.2s;
}

.yaraa-accordion-header:hover {
  background: #f8fafc;
}

.yaraa-accordion-header.active {
  background: transparent;
}

.yaraa-accordion-title {
  flex: 1;
}

.yaraa-accordion-title strong {
  display: block;
  font-size: 16px;
  color: #1e293b;
  margin-bottom: 8px;
}

.yaraa-accordion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.yaraa-accordion-dates {
  text-align: right;
  font-size: 13px;
  color: #64748b;
  min-width: 200px;
}

.yaraa-accordion-dates div {
  margin-bottom: 2px;
}

.yaraa-accordion-arrow {
  color: #64748b;
  font-size: 20px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 4px;
}

.yaraa-accordion-body {
  padding: 0 20px 20px;
}

.yaraa-url-badge {
  color: #64748b;
  cursor: help;
}

.yaraa-url-badge .dashicons {
  font-size: 14px;
  width: 14px;
  height: 14px;
}

.yaraa-chat-loading-inline {
  text-align: center;
  padding: 20px;
  color: #64748b;
  font-size: 13px;
}

.yaraa-chat-loading-inline .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: middle;
}

.yaraa-no-conversations,
.yaraa-no-messages {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
  font-style: italic;
}

.yaraa-error {
  color: #dc2626;
  text-align: center;
  padding: 20px;
}

/* Chat Container. */
.yaraa-chat-container {
  background: #f5f7fb;
  border-radius: 8px;
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.yaraa-chat-message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.yaraa-chat-message.user {
  flex-direction: row;
}

.yaraa-chat-message.bot {
  flex-direction: row-reverse;
}

.yaraa-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.yaraa-message-avatar.bot {
  background: #10b981;
}

.yaraa-message-avatar .dashicons {
  font-size: 18px;
  width: 18px;
  height: 18px;
}

.yaraa-message-content {
  max-width: 70%;
}

.yaraa-message-header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
}

.yaraa-chat-message.bot .yaraa-message-header {
  flex-direction: row-reverse;
}

.yaraa-message-time {
  color: #94a3b8;
}

.yaraa-message-bubble {
  background: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
}

.yaraa-chat-message.user .yaraa-message-bubble {
  background: #e3f2fd;
  border-bottom-left-radius: 4px;
}

.yaraa-chat-message.bot .yaraa-message-bubble {
  border-bottom-right-radius: 4px;
}

.yaraa-chat-loading {
  text-align: center;
  padding: 40px;
  color: #64748b;
}

/* Voice Message Styles. */
.yaraa-voice-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #fef3c7;
  color: #d97706;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

.yaraa-voice-badge .dashicons {
  font-size: 12px;
  width: 12px;
  height: 12px;
}

.yaraa-voice-message {
  background: #fefce8 !important;
}

.yaraa-voice-message audio {
  display: block;
  width: 100%;
  max-width: 300px;
}

.yaraa-transcription {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  font-style: italic;
  color: #64748b;
  font-size: 13px;
}

/* AI Response HTML Formatting. */
.yaraa-ai-response {
  line-height: 1.6;
}

.yaraa-ai-response b,
.yaraa-ai-response strong {
  font-weight: 600;
  color: #1e293b;
}

.yaraa-ai-response ul,
.yaraa-ai-response ol {
  margin: 10px 0;
  padding-left: 20px;
}

.yaraa-ai-response ul {
  list-style-type: disc;
}

.yaraa-ai-response ol {
  list-style-type: decimal;
}

.yaraa-ai-response li {
  margin-bottom: 6px;
  padding-left: 4px;
}

.yaraa-ai-response p {
  margin-bottom: 8px;
}

.yaraa-ai-response p:last-child {
  margin-bottom: 0;
}

.yaraa-ai-response a {
  color: #2563eb;
  text-decoration: underline;
}

.yaraa-ai-response code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.yaraa-ai-response pre {
  background: #f1f5f9;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 10px 0;
}

.yaraa-ai-response blockquote {
  border-left: 3px solid #6366f1;
  padding-left: 12px;
  margin: 10px 0;
  color: #64748b;
}

.yaraa-ai-response table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
}

.yaraa-ai-response th,
.yaraa-ai-response td {
  border: 1px solid #e2e8f0;
  padding: 8px;
  text-align: left;
}

.yaraa-ai-response th {
  background: #f8fafc;
  font-weight: 600;
}

/* Responsive. */
@media (max-width: 768px) {
  .yaraa-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .yaraa-table-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .yaraa-search-box {
    max-width: none;
  }

  .yaraa-conversations-table thead {
    display: none;
  }

  .yaraa-conversations-table tr {
    display: block;
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
  }

  .yaraa-conversations-table td {
    display: block;
    padding: 8px 0;
    border: none;
  }

  .yaraa-conversations-table td:first-child {
    position: absolute;
    top: 16px;
    right: 16px;
  }

  .yaraa-pagination {
    flex-direction: column;
    gap: 12px;
  }

  .yaraa-modal-container {
    width: 95%;
    max-height: 95vh;
  }

  .yaraa-visitor-card-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .yaraa-visitor-info-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .yaraa-accordion-header {
    flex-direction: column;
    position: relative;
    padding-right: 40px;
  }

  .yaraa-accordion-dates {
    text-align: left;
    min-width: auto;
    margin-top: 8px;
  }

  .yaraa-accordion-arrow {
    position: absolute;
    right: 20px;
    top: 20px;
  }
}

.yaraa-conversations-table th:first-child {
  width: 40px;
}