#chat-widget-input::placeholder {
  text-align: right;
}

:root {
  --chat-accent: #008080;
  --chat-accent-rgb: 0, 128, 128;
  --chat-accent-hover: #006666;
}

/* --- Футър бутони за чат --- */
.footer-icon-group {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-right: 8px;
}

.footer-icon-btn-container {
  position: relative;
  display: flex;
  align-items: center;
}

.footer-icon-btn {
  width: 34px;
  height: 34px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  color: #888;
  padding: 0;
  outline: none;
}
.footer-icon-btn:hover {
  background: #f0f9ff;
  color: var(--chat-accent);
  box-shadow: 0 2px 8px rgba(var(--chat-accent-rgb), 0.08);
}
.footer-icon-btn svg {
  display: block;
}

.footer-tooltip {
  display: none;
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.footer-icon-btn-container:hover .footer-tooltip {
  display: block;
  opacity: 1;
}
.emoji-btn-big {
  width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* --- Стилизиране на икони вътре в input контейнера --- */
.input-with-icons {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
}

.input-icons, .footer-icon-group {
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 8px;
  z-index: 2;
}

.input-with-icons textarea {
  padding-left: 70px !important;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #888;
  padding: 0 2px;
  transition: color 0.2s, background 0.2s;
  border-radius: 5px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  color: var(--chat-accent);
  background: #f0f9ff;
}
/* =============================================
   ЧАТ WIDGET - СТИЛОВЕ (CSS)
   ============================================= 
   Тук се дефинира визуалния вид на чат widget-а
*/

/* Премахване на черното очертание при фокус */
button:focus,
button:active,
input:focus,
textarea:focus,
select:focus,
a:focus {
  outline: none !important;
}

/* Бутон икона (пощенски плик) */
#chat-widget-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(var(--chat-accent-rgb), 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: all 0.3s ease;
  outline: none;
}

#chat-widget-button:focus {
  outline: none;
}

#chat-widget-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(var(--chat-accent-rgb), 0.6);
  background: white;
}

#chat-widget-button:hover svg {
  fill: var(--chat-accent);
}

#chat-widget-button svg {
  width: 30px;
  height: 30px;
  fill: white;
  transition: fill 0.3s ease;
}

/* Бадж с нови съобщения */
#chat-widget-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Главен чат прозорец */
#chat-widget-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#chat-widget-window.active {
  display: flex;
}

/* Хедър на чата */
#chat-widget-header {
  background: var(--chat-accent);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

#chat-widget-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.header-buttons {
  display: flex;
  gap: 8px;
}

#chat-widget-close,
#chat-widget-minimize {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  outline: none;
}

#chat-widget-close:focus,
#chat-widget-minimize:focus {
  outline: none;
}

#chat-widget-minimize {
  font-size: 28px;
  font-weight: bold;
}

#chat-widget-close:hover,
#chat-widget-minimize:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Minimized състояние - скрива прозореца напълно */
#chat-widget-window.minimized {
  display: none !important;
}

/* Форма за данни */
#chat-widget-form {
  padding: 20px;
  background: #f9f9f9;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

#chat-widget-form input {
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}

#chat-widget-form input:focus {
  outline: none;
  border-color: var(--chat-accent);
}

#chat-widget-form button {
  width: 100%;
  padding: 12px;
  background: var(--chat-accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  outline: none;
}

#chat-widget-form button:focus {
  outline: none;
}

#chat-widget-form button:hover {
  opacity: 0.9;
}

/* Контейнер със съобщения */
#chat-widget-messages {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fafafa;
  display: flex;
  flex-direction: column;
}

/* Отделно съобщение */
.chat-message {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
  align-items: flex-end;
}

.chat-message.agent {
  align-items: flex-start;
}

.chat-message-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  position: relative;
}

.chat-message.user .chat-message-bubble {
  background: var(--chat-accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.agent .chat-message-bubble {
  background: white;
  color: #333;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
}

.chat-message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

.chat-message-file {
  margin-top: 8px;
  font-size: 13px;
  word-break: break-word;
}

.chat-message-file a {
  color: #0066cc;
  text-decoration: none;
}

.chat-message-file a:hover {
  text-decoration: underline;
}

/* Системно съобщение */
.chat-message.system {
  align-items: center;
}

.chat-message.system .chat-message-bubble {
  background: #f0f0f0;
  color: #000000;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 90%;
}

/* Поле за писане */
#chat-widget-input-container {
  display: flex;
  gap: 10px;
  padding: 15px 20px;
  background: white;
  border-top: 1px solid #e0e0e0;
  align-items: flex-end;
  flex-shrink: 0;
}

#chat-widget-input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  resize: none;
  font-family: Arial, sans-serif;
  min-height: 45px;
  max-height: 100px;
  line-height: 1.4;
}

#chat-attach-btn {
  width: 45px;
  height: 45px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s, color 0.2s;
  flex-shrink: 0;
  font-size: 18px;
  color: #555;
}

#chat-attach-btn:hover {
  background: #f5f5f5;
  color: var(--chat-accent);
  transform: translateY(-1px);
}

#chat-widget-input:focus {
  outline: none;
  border-color: var(--chat-accent);
}

#chat-widget-send {
  width: 45px;
  height: 45px;
  border: none;
  background: var(--chat-accent);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
  outline: none;
}

#chat-widget-send:focus,
#chat-widget-send:active {
  outline: none;
}

#chat-widget-send:hover {
  transform: scale(1.05);
}

#chat-widget-send svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* Индикатор за писане */
.typing-indicator {
  display: none;
  padding: 10px 15px;
  background: white;
  border-radius: 18px;
  border: 1px solid #e0e0e0;
  width: fit-content;
  margin: 0 20px 10px 20px;
}

.typing-indicator.active {
  display: block;
}

.typing-indicator span {
  height: 8px;
  width: 8px;
  background: #999;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Офлайн форма */
#chat-widget-offline-form {
  display: none;
  flex-direction: column;
  padding: 20px;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

#chat-widget-offline-form.active {
  display: flex;
}

#chat-widget-offline-form p {
  margin: 0 0 10px 0;
  color: #333;
}

#chat-widget-offline-form input,
#chat-widget-offline-form textarea {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: Arial, sans-serif;
}

#chat-widget-offline-form input:focus,
#chat-widget-offline-form textarea:focus {
  outline: none;
  border-color: var(--chat-accent);
}

#chat-widget-offline-form textarea {
  min-height: 100px;
  resize: vertical;
}

#chat-widget-offline-form button {
  padding: 12px;
  background: var(--chat-accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  outline: none;
}

#chat-widget-offline-form button:focus,
#chat-widget-offline-form button:active {
  outline: none;
}

#chat-widget-offline-form button:hover {
  opacity: 0.9;
}

/* Responsive */
@media (max-width: 480px) {
  #chat-widget-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    right: 10px;
    bottom: 80px;
  }

  #chat-widget-button {
    bottom: 15px;
    right: 15px;
  }
}

/* Скролбар */
#chat-widget-messages::-webkit-scrollbar,
#chat-widget-offline-form::-webkit-scrollbar {
  width: 6px;
}

#chat-widget-messages::-webkit-scrollbar-track,
#chat-widget-offline-form::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#chat-widget-messages::-webkit-scrollbar-thumb,
#chat-widget-offline-form::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

#chat-widget-messages::-webkit-scrollbar-thumb:hover,
#chat-widget-offline-form::-webkit-scrollbar-thumb:hover {
  background: #999;
}
