/* TAMS Chat Widget — self-contained styles */
/* All classes prefixed with tams-cw- to avoid conflicts */

/* ============ FLOATING BUTTON ============ */
.tams-cw-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0074D7, #75D3F8);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 116, 215, 0.4);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.tams-cw-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 116, 215, 0.5);
}
.tams-cw-btn svg {
  width: 28px;
  height: 28px;
  fill: white;
}
.tams-cw-btn-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============ CHAT WINDOW ============ */
.tams-cw-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.tams-cw-window.tams-cw-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Mobile: fullscreen */
@media (max-width: 480px) {
  .tams-cw-window {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  .tams-cw-btn {
    bottom: 16px;
    right: 16px;
  }
}

/* ============ HEADER ============ */
.tams-cw-header {
  background: linear-gradient(135deg, #00366B, #0074D7);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.tams-cw-header-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tams-cw-header-logo svg {
  width: 20px;
  height: 20px;
  fill: white;
}
.tams-cw-header-text {
  flex: 1;
  min-width: 0;
}
.tams-cw-header-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}
.tams-cw-header-subtitle {
  font-size: 12px;
  opacity: 0.8;
  line-height: 1.2;
}
.tams-cw-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: white;
  opacity: 0.8;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: opacity 0.15s, background 0.15s;
}
.tams-cw-close-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}
.tams-cw-close-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ============ MESSAGES AREA ============ */
.tams-cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* Bot/Operator message (left) */
.tams-cw-msg-bot {
  max-width: 85%;
  align-self: flex-start;
}
.tams-cw-msg-bot .tams-cw-bubble {
  background: white;
  color: #1e293b;
  border-radius: 4px 14px 14px 14px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  word-break: break-word;
}

/* Visitor message (right) */
.tams-cw-msg-user {
  max-width: 85%;
  align-self: flex-end;
}
.tams-cw-msg-user .tams-cw-bubble {
  background: linear-gradient(135deg, #0074D7, #2196F3);
  color: white;
  border-radius: 14px 4px 14px 14px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

/* System message */
.tams-cw-msg-system {
  align-self: center;
  max-width: 90%;
}
.tams-cw-msg-system .tams-cw-bubble {
  background: #e2e8f0;
  color: #64748b;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 12px;
  text-align: center;
}

/* Timestamp */
.tams-cw-msg-time {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  padding: 0 4px;
}
.tams-cw-msg-user .tams-cw-msg-time {
  text-align: right;
}

/* ============ BUTTONS (inline keyboard) ============ */
.tams-cw-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0;
}
.tams-cw-btn-inline {
  background: white;
  border: 1.5px solid #0074D7;
  color: #0074D7;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  line-height: 1.2;
}
.tams-cw-btn-inline:hover {
  background: #0074D7;
  color: white;
}

/* ============ PHOTO/DOCUMENT ============ */
.tams-cw-photo {
  max-width: 100%;
  border-radius: 10px;
  cursor: pointer;
  margin: 4px 0;
}
.tams-cw-document {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 8px 12px;
  text-decoration: none;
  color: #0074D7;
  font-size: 13px;
  margin: 4px 0;
}
.tams-cw-document:hover {
  background: #e2e8f0;
}
.tams-cw-document svg {
  width: 18px;
  height: 18px;
  fill: #0074D7;
  flex-shrink: 0;
}

/* ============ INPUT AREA ============ */
.tams-cw-input-area {
  border-top: 1px solid #e2e8f0;
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: white;
  flex-shrink: 0;
}
.tams-cw-textarea {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 36px;
  color: #1e293b;
  background: #f8fafc;
  transition: border-color 0.15s;
}
.tams-cw-textarea:focus {
  border-color: #0074D7;
}
.tams-cw-textarea::placeholder {
  color: #94a3b8;
}
.tams-cw-send-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0074D7, #2196F3);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
}
.tams-cw-send-btn:hover {
  transform: scale(1.08);
}
.tams-cw-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}
.tams-cw-send-btn svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* ============ IDENTIFY FORM ============ */
.tams-cw-identify {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  text-align: center;
}
.tams-cw-identify-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0074D7, #75D3F8);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.tams-cw-identify-icon svg {
  width: 32px;
  height: 32px;
  fill: white;
}
.tams-cw-identify h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 6px;
}
.tams-cw-identify p {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 20px;
}
.tams-cw-identify-form {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tams-cw-identify-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: #1e293b;
  background: white;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.tams-cw-identify-input:focus {
  border-color: #0074D7;
}
.tams-cw-identify-submit {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, #0074D7, #2196F3);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  margin-top: 4px;
}
.tams-cw-identify-submit:hover {
  opacity: 0.9;
}
.tams-cw-identify-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ============ TYPING INDICATOR ============ */
.tams-cw-typing {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
  align-items: center;
}
.tams-cw-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: tams-cw-bounce 1.4s infinite ease-in-out;
}
.tams-cw-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.tams-cw-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes tams-cw-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============ CONNECTION STATUS ============ */
.tams-cw-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.tams-cw-status-online { background: #22c55e; }
.tams-cw-status-offline { background: #ef4444; }
.tams-cw-status-connecting { background: #f59e0b; animation: tams-cw-pulse 1.5s infinite; }

@keyframes tams-cw-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============ SCROLLBAR ============ */
.tams-cw-messages::-webkit-scrollbar {
  width: 5px;
}
.tams-cw-messages::-webkit-scrollbar-track {
  background: transparent;
}
.tams-cw-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* ============ HTML IN MESSAGES ============ */
.tams-cw-bubble a {
  color: #0074D7;
  text-decoration: underline;
}
.tams-cw-msg-user .tams-cw-bubble a {
  color: #bfdbfe;
}
.tams-cw-bubble b, .tams-cw-bubble strong {
  font-weight: 600;
}
