/**
 * ERPSolo Support Widget - Styles
 * Version: 1.0.0
 */

:root {
  --erpsolo-primary: #3B82F6;
  --erpsolo-primary-dark: #2563EB;
  --erpsolo-gray-50: #F9FAFB;
  --erpsolo-gray-100: #F3F4F6;
  --erpsolo-gray-200: #E5E7EB;
  --erpsolo-gray-300: #D1D5DB;
  --erpsolo-gray-400: #9CA3AF;
  --erpsolo-gray-500: #6B7280;
  --erpsolo-gray-600: #4B5563;
  --erpsolo-gray-700: #374151;
  --erpsolo-gray-800: #1F2937;
  --erpsolo-gray-900: #111827;
  --erpsolo-red: #EF4444;
  --erpsolo-green: #10B981;
  --erpsolo-yellow: #F59E0B;
  --erpsolo-blue: #3B82F6;
}

/* Container */
#erpsolo-widget-container {
  position: fixed;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.erpsolo-widget-bottom-right {
  bottom: 20px;
  right: 20px;
}

.erpsolo-widget-bottom-left {
  bottom: 20px;
  left: 20px;
}

.erpsolo-widget-top-right {
  top: 20px;
  right: 20px;
}

.erpsolo-widget-top-left {
  top: 20px;
  left: 20px;
}

/* Button */
.erpsolo-widget-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--erpsolo-primary);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  font-size: 15px;
  font-weight: 500;
}

.erpsolo-widget-btn:hover {
  background: var(--erpsolo-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.erpsolo-widget-btn svg {
  width: 20px;
  height: 20px;
}

.erpsolo-widget-btn.active {
  background: var(--erpsolo-gray-800);
}

/* Panel */
.erpsolo-widget-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 450px;
  max-width: calc(100vw - 40px);
  height: 650px;
  max-height: calc(100vh - 100px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .erpsolo-widget-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    border-radius: 12px 12px 0 0;
  }
}

/* Header */
.erpsolo-widget-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--erpsolo-primary);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.erpsolo-widget-header h3 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.erpsolo-widget-back,
.erpsolo-widget-close {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.erpsolo-widget-back:hover,
.erpsolo-widget-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.erpsolo-widget-back svg,
.erpsolo-widget-close svg {
  width: 20px;
  height: 20px;
}

/* Body */
.erpsolo-widget-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--erpsolo-gray-50);
}

.erpsolo-widget-loading,
.erpsolo-widget-error,
.erpsolo-widget-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--erpsolo-gray-500);
}

.erpsolo-widget-error {
  color: var(--erpsolo-red);
}

.erpsolo-widget-hint {
  font-size: 13px;
  color: var(--erpsolo-gray-400);
  margin-top: 8px;
}

/* Buttons */
.erpsolo-widget-btn-primary,
.erpsolo-widget-btn-secondary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 16px;
}

.erpsolo-widget-btn-primary {
  background: var(--erpsolo-primary);
  color: white;
}

.erpsolo-widget-btn-primary:hover:not(:disabled) {
  background: var(--erpsolo-primary-dark);
}

.erpsolo-widget-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.erpsolo-widget-btn-secondary {
  background: white;
  color: var(--erpsolo-gray-700);
  border: 1px solid var(--erpsolo-gray-300);
}

.erpsolo-widget-btn-secondary:hover {
  background: var(--erpsolo-gray-50);
}

/* Tickets List */
.erpsolo-widget-tickets-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.erpsolo-widget-ticket-item {
  background: white;
  border: 1px solid var(--erpsolo-gray-200);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.erpsolo-widget-ticket-item:hover {
  border-color: var(--erpsolo-primary);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.erpsolo-widget-ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.erpsolo-widget-ticket-subject {
  font-weight: 500;
  color: var(--erpsolo-gray-900);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.erpsolo-widget-ticket-desc {
  font-size: 13px;
  color: var(--erpsolo-gray-600);
  margin: 8px 0;
  line-height: 1.5;
}

.erpsolo-widget-ticket-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--erpsolo-gray-400);
}

.erpsolo-widget-unread-dot {
  width: 8px;
  height: 8px;
  background: var(--erpsolo-red);
  border-radius: 50%;
}

/* Badges */
.erpsolo-widget-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.erpsolo-widget-badge-new {
  background: #DBEAFE;
  color: #1E40AF;
}

.erpsolo-widget-badge-in_progress {
  background: #FEF3C7;
  color: #92400E;
}

.erpsolo-widget-badge-resolved {
  background: #D1FAE5;
  color: #065F46;
}

.erpsolo-widget-badge-closed {
  background: var(--erpsolo-gray-200);
  color: var(--erpsolo-gray-600);
}

/* Form */
.erpsolo-widget-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.erpsolo-widget-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.erpsolo-widget-form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--erpsolo-gray-700);
}

.erpsolo-widget-form-group input,
.erpsolo-widget-form-group textarea,
.erpsolo-widget-form-group select {
  padding: 10px 12px;
  border: 1px solid var(--erpsolo-gray-300);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  transition: all 0.2s;
}

.erpsolo-widget-form-group input:focus,
.erpsolo-widget-form-group textarea:focus,
.erpsolo-widget-form-group select:focus {
  outline: none;
  border-color: var(--erpsolo-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.erpsolo-widget-form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* Ticket Detail */
.erpsolo-widget-ticket-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.erpsolo-widget-ticket-info {
  background: white;
  border: 1px solid var(--erpsolo-gray-200);
  border-radius: 8px;
  padding: 12px;
}

.erpsolo-widget-ticket-info h4 {
  margin: 0 0 8px 0;
  font-size: 15px;
  color: var(--erpsolo-gray-900);
}

.erpsolo-widget-ticket-date {
  font-size: 12px;
  color: var(--erpsolo-gray-400);
  margin-top: 8px;
}

/* Messages */
.erpsolo-widget-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
}

.erpsolo-widget-message {
  background: white;
  border: 1px solid var(--erpsolo-gray-200);
  border-radius: 8px;
  padding: 12px;
}

.erpsolo-widget-message.from-customer {
  border-left: 3px solid var(--erpsolo-blue);
}

.erpsolo-widget-message.from-support {
  border-left: 3px solid var(--erpsolo-green);
  background: var(--erpsolo-gray-50);
}

.erpsolo-widget-message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
}

.erpsolo-widget-message-header strong {
  color: var(--erpsolo-gray-900);
  font-weight: 600;
}

.erpsolo-widget-message-header span {
  color: var(--erpsolo-gray-400);
}

.erpsolo-widget-message-body {
  color: var(--erpsolo-gray-700);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Reply Form */
.erpsolo-widget-reply-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: white;
  border: 1px solid var(--erpsolo-gray-200);
  border-radius: 8px;
  padding: 12px;
}

.erpsolo-widget-reply-form textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--erpsolo-gray-300);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
}

.erpsolo-widget-reply-form textarea:focus {
  outline: none;
  border-color: var(--erpsolo-primary);
}

.erpsolo-widget-reply-form button {
  padding: 10px 20px;
  background: var(--erpsolo-primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
  align-self: flex-end;
}

.erpsolo-widget-reply-form button:hover:not(:disabled) {
  background: var(--erpsolo-primary-dark);
}

.erpsolo-widget-reply-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.erpsolo-widget-closed-notice,
.erpsolo-widget-info-notice {
  text-align: center;
  padding: 12px;
  background: var(--erpsolo-gray-100);
  border: 1px solid var(--erpsolo-gray-200);
  border-radius: 8px;
  color: var(--erpsolo-gray-600);
  font-size: 13px;
}

.erpsolo-widget-info-notice {
  background: #E3F2FD;
  border-color: #90CAF9;
  color: #1565C0;
}

/* Scrollbar styles */
.erpsolo-widget-body::-webkit-scrollbar,
.erpsolo-widget-messages::-webkit-scrollbar {
  width: 6px;
}

.erpsolo-widget-body::-webkit-scrollbar-track,
.erpsolo-widget-messages::-webkit-scrollbar-track {
  background: transparent;
}

.erpsolo-widget-body::-webkit-scrollbar-thumb,
.erpsolo-widget-messages::-webkit-scrollbar-thumb {
  background: var(--erpsolo-gray-300);
  border-radius: 3px;
}

.erpsolo-widget-body::-webkit-scrollbar-thumb:hover,
.erpsolo-widget-messages::-webkit-scrollbar-thumb:hover {
  background: var(--erpsolo-gray-400);
}

/* Assistant client */
.erpsolo-assistant-body { display: flex; flex-direction: column; gap: 8px; }
.erpsolo-assistant-msg { max-width: 88%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; word-wrap: break-word; }
.erpsolo-assistant-bot { align-self: flex-start; background: #fff; border: 1px solid var(--erpsolo-gray-300); color: #1f2937; }
.erpsolo-assistant-user { align-self: flex-end; background: var(--erpsolo-primary, #3B82F6); color: #fff; }
.erpsolo-assistant-attente { color: #6b7280; font-style: italic; }
.erpsolo-assistant-avis { margin-top: 6px; font-size: 12px; color: #6b7280; }
.erpsolo-assistant-avis button { border: 0; background: transparent; cursor: pointer; font-size: 14px; padding: 0 4px; }
.erpsolo-assistant-form { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--erpsolo-gray-300); background: #fff; }
.erpsolo-assistant-form input { flex: 1; border: 1px solid var(--erpsolo-gray-300); border-radius: 18px; padding: 8px 12px; font-size: 14px; }
.erpsolo-assistant-pied { padding: 6px 12px 10px; font-size: 11px; color: #6b7280; background: #fff; }
.erpsolo-assistant-lien { border: 0; background: transparent; color: var(--erpsolo-primary, #3B82F6); cursor: pointer; text-decoration: underline; font-size: 11px; padding: 0 0 0 6px; }
