﻿/**
 * BVM SmileCheck AI Chat Widget Styles
 * Mobile-first responsive dental clinic design
 * Version: 1.0.3 - ChatGPT typewriter cursor & streaming animation
 */

:root {
  --dai-primary: #0a9396;
  --dai-primary-dark: #005f73;
  --dai-accent: #94d2bd;
  --dai-bg: #ffffff;
  --dai-bg-chat: #f8fafc;
  --dai-text: #1e293b;
  --dai-text-muted: #64748b;
  --dai-border: #e2e8f0;
  --dai-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.15), 0 8px 12px -6px rgba(0, 0, 0, 0.1);
  --dai-radius: 16px;
  --dai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#dai-root {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999999;
  font-family: var(--dai-font);
  font-size: 14px;
  color: var(--dai-text);
  box-sizing: border-box;
}

#dai-root * {
  box-sizing: border-box;
}

/* Floating Action Button */
.dai-bubble {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--dai-primary) 0%, var(--dai-primary-dark) 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.8);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(10, 147, 150, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: absolute;
  bottom: 0;
  right: 0;
}

.dai-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(10, 147, 150, 0.6);
}

.dai-bubble-icon {
  font-size: 30px;
  line-height: 1;
}

.dai-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* Main Chat Panel */
.dai-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 110px);
  background: var(--dai-bg);
  border-radius: var(--dai-radius);
  box-shadow: var(--dai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--dai-border);
  animation: daiSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes daiSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.dai-header {
  background: linear-gradient(135deg, var(--dai-primary) 0%, var(--dai-primary-dark) 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dai-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dai-header-avatar {
  font-size: 22px;
  background: rgba(255, 255, 255, 0.2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dai-header-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.dai-header-sub {
  font-size: 12px;
  opacity: 0.85;
}

.dai-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dai-lang-switcher {
  display: flex;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 2px;
}

.dai-lang-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  cursor: pointer;
}

.dai-lang-btn.active {
  background: #ffffff;
  color: var(--dai-primary-dark);
}

.dai-close-btn {
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

.dai-close-btn:hover {
  opacity: 1;
}

/* Consent Screen */
.dai-consent-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #ffffff;
}

.dai-consent-body {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dai-consent-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.dai-consent-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--dai-primary-dark);
  margin: 0 0 8px 0;
}

.dai-consent-intro {
  font-size: 13px;
  color: var(--dai-text-muted);
  margin: 0 0 16px 0;
  line-height: 1.4;
}

.dai-consent-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--dai-text);
}

.dai-consent-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  font-size: 12px;
  color: var(--dai-text-muted);
  background: #f8fafc;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--dai-border);
  margin-bottom: 16px;
  cursor: pointer;
}

.dai-consent-label input {
  margin-top: 2px;
}

.dai-consent-btn {
  width: 100%;
  padding: 12px;
  background: var(--dai-primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.dai-consent-btn:hover {
  background: var(--dai-primary-dark);
}

/* Chat Screen */
.dai-chat-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--dai-bg-chat);
  overflow: hidden;
  position: relative;
}

.dai-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dai-message {
  display: flex;
  gap: 8px;
  max-width: 86%;
  font-size: 13.5px;
  line-height: 1.45;
}

.dai-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.dai-message.assistant {
  align-self: flex-start;
}

.dai-avatar {
  font-size: 18px;
  margin-top: 2px;
  flex-shrink: 0;
}

.dai-bubble-text {
  padding: 10px 14px;
  border-radius: 14px;
  word-break: break-word;
}

.dai-message.user .dai-bubble-text {
  background: var(--dai-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.dai-message.assistant .dai-bubble-text {
  background: #ffffff;
  color: var(--dai-text);
  border: 1px solid var(--dai-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ChatGPT Cursor Effect */
.dai-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background-color: var(--dai-primary);
  margin-left: 3px;
  vertical-align: -2px;
  animation: daiBlink 0.7s infinite;
}

@keyframes daiBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.dai-preview-img {
  max-width: 180px;
  max-height: 180px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--dai-primary);
}

/* Image Type Selector */
.dai-type-selector {
  background: #ffffff;
  padding: 12px 16px;
  border-top: 1px solid var(--dai-border);
  border-bottom: 1px solid var(--dai-border);
}

.dai-type-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--dai-primary-dark);
  margin-bottom: 8px;
}

.dai-type-options {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.dai-type-option {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 6px;
}

.dai-type-actions {
  display: flex;
  gap: 8px;
}

.dai-type-send-btn {
  flex: 1;
  background: var(--dai-primary);
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.dai-type-cancel-btn {
  background: #e2e8f0;
  color: var(--dai-text-muted);
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* Quick Replies */
.dai-quick-replies {
  display: flex;
  gap: 6px;
  padding: 6px 14px;
  background: #ffffff;
  border-top: 1px solid var(--dai-border);
  overflow-x: auto;
}

.dai-quick-btn {
  background: #f1f5f9;
  border: 1px solid var(--dai-border);
  color: var(--dai-primary-dark);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.dai-quick-btn:hover {
  background: var(--dai-accent);
  color: var(--dai-primary-dark);
}

/* Input Area */
.dai-input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid var(--dai-border);
  gap: 6px;
}

.dai-media-buttons {
  display: flex;
  gap: 4px;
}

.dai-media-btn {
  background: #f1f5f9;
  border: 1px solid var(--dai-border);
  color: var(--dai-primary-dark);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  padding: 0;
}

.dai-media-btn:hover {
  background: var(--dai-accent);
  transform: scale(1.05);
}

.dai-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

.dai-input {
  width: 100%;
  border: 1px solid var(--dai-border);
  border-radius: 18px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.4;
  background: #f8fafc;
}

.dai-input:focus {
  border-color: var(--dai-primary);
  background: #ffffff;
}

.dai-char-count {
  font-size: 9.5px;
  color: #94a3b8;
  text-align: right;
  padding-right: 6px;
  margin-top: 2px;
}

.dai-send-btn {
  background: var(--dai-primary);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  padding: 0;
}

.dai-send-btn:hover:not(:disabled) {
  background: var(--dai-primary-dark);
}

.dai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Disclaimer footer */
.dai-disclaimer {
  background: #f8fafc;
  padding: 4px 10px;
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
  border-top: 1px solid #f1f5f9;
}

/* Typing Indicator Animation */
.dai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.dai-typing span {
  width: 6px;
  height: 6px;
  background: var(--dai-primary);
  border-radius: 50%;
  animation: daiBounce 1.4s infinite ease-in-out both;
}

.dai-typing span:nth-child(1) { animation-delay: -0.32s; }
.dai-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes daiBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

.dai-loading-text {
  display: block;
  font-size: 12px;
  color: var(--dai-text-muted);
  margin-bottom: 4px;
}

/* Laptop / PC Webcam Capture Modal */
.dai-cam-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.dai-cam-container {
  width: 100%;
  max-width: 340px;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dai-cam-header {
  padding: 10px 14px;
  background: var(--dai-primary-dark);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.dai-cam-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.dai-cam-view {
  width: 100%;
  height: 240px;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.dai-cam-view video, .dai-cam-view img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dai-cam-actions {
  padding: 12px;
  display: flex;
  gap: 8px;
  justify-content: center;
  background: #f8fafc;
}

.dai-cam-btn-primary {
  background: var(--dai-primary);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.dai-cam-btn-secondary {
  background: #e2e8f0;
  color: var(--dai-text);
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Error toast */
.dai-error-toast {
  position: absolute;
  top: 60px;
  left: 12px;
  right: 12px;
  background: #ef4444;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: daiSlideUp 0.2s ease;
  z-index: 10;
}

/* Responsive Mobile View */
@media (max-width: 480px) {
  #dai-root {
    bottom: 18px;
    right: 18px;
  }

  .dai-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
}
