/**
 * AiWebModule CSS - Minimal White Design
 * Version: 1.0.0
 * Author: Arnaud Cassone © Artcraft Visuals 2025
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

/* ========================================
   CONTAINER
   ======================================== */

.aiwebmodule-container {
  max-width: 800px;
  margin: 20px auto;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 40px);
  min-height: 500px;
}

/* ========================================
   HEADER
   ======================================== */

.aiwebmodule-logo {
  text-align: center;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.aiwebmodule-logo img {
  max-height: 60px;
  height: auto;
}

.aiwebmodule-header {
  text-align: center;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
}

.aiwebmodule-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: #222;
  margin-bottom: 5px;
}

.aiwebmodule-header .subtitle {
  font-size: 13px;
  color: #666;
  font-weight: 400;
}

/* ========================================
   MESSAGES AREA
   ======================================== */

.aiwebmodule-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #ffffff;
  scroll-behavior: smooth;
}

.aiwebmodule-message {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  max-width: 75%;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.aiwebmodule-message.user {
  background: #007bff;
  color: #ffffff;
  margin-left: auto;
  margin-right: 0;
  border-bottom-right-radius: 4px;
}

.aiwebmodule-message.assistant {
  background: #f1f3f5;
  color: #333;
  margin-left: 0;
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.aiwebmodule-message.welcome {
  background: #e7f5ff;
  border: 1px solid #a5d8ff;
  max-width: 100%;
}

.message-content {
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
}

.message-content p {
  margin-bottom: 10px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul,
.message-content ol {
  margin: 10px 0;
  padding-left: 20px;
}

.message-content li {
  margin-bottom: 5px;
}

.message-content a {
  color: #007bff;
  text-decoration: none;
  border-bottom: 1px solid #007bff;
}

.message-content a:hover {
  color: #0056b3;
  border-bottom-color: #0056b3;
}

.message-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 10px 0;
  display: block;
}

.message-content video {
  max-width: 100%;
  border-radius: 6px;
  margin: 10px 0;
}

.message-content iframe {
  max-width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin: 10px 0;
}

.message-content pre {
  background: #f6f8fa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
}

.message-content code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.4;
}

.message-content .cta {
  background: #e7f5ff;
  border-left: 3px solid #007bff;
  padding: 10px 12px;
  margin: 12px 0;
  border-radius: 4px;
}

.message-content .cta p {
  margin: 0;
  color: #0056b3;
  font-weight: 500;
}

.message-content .warning {
  background: #fff3cd;
  border-left: 3px solid #ffc107;
  padding: 10px 12px;
  margin: 12px 0;
  border-radius: 4px;
  color: #856404;
}

.message-timestamp {
  font-size: 11px;
  color: #999;
  margin-top: 5px;
  text-align: right;
}

.aiwebmodule-message.user .message-timestamp {
  color: rgba(255, 255, 255, 0.7);
}

/* ========================================
   TYPING INDICATOR
   ======================================== */

.aiwebmodule-typing {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  background: #f1f3f5;
  border-radius: 8px;
  margin: 0 20px 16px 20px;
  max-width: 60px;
}

.aiwebmodule-typing span {
  width: 8px;
  height: 8px;
  background: #666;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.aiwebmodule-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.aiwebmodule-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   INPUT AREA
   ======================================== */

.aiwebmodule-input {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #e0e0e0;
  background: #fafafa;
}

#aiwebmodule-textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-family: inherit;
  font-size: 15px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  background: #ffffff;
  color: #333;
  min-height: 44px;
  max-height: 150px;
}

#aiwebmodule-textarea:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#aiwebmodule-textarea::placeholder {
  color: #999;
}

#aiwebmodule-send {
  padding: 12px 24px;
  background: #007bff;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

#aiwebmodule-send:hover {
  background: #0056b3;
}

#aiwebmodule-send:active {
  background: #004085;
}

#aiwebmodule-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ========================================
   FOOTER
   ======================================== */

.aiwebmodule-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid #e0e0e0;
  background: #fafafa;
}

#aiwebmodule-clear {
  padding: 8px 16px;
  background: transparent;
  color: #666;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

#aiwebmodule-clear:hover {
  background: #f1f3f5;
  border-color: #999;
  color: #333;
}

.aiwebmodule-footer .version {
  font-size: 12px;
  color: #999;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .aiwebmodule-container {
    margin: 0;
    height: 100vh;
    border: none;
    border-radius: 0;
  }
  
  .aiwebmodule-message {
    max-width: 85%;
  }
  
  #aiwebmodule-send {
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  .aiwebmodule-header h1 {
    font-size: 20px;
  }
  
  .aiwebmodule-header .subtitle {
    font-size: 12px;
  }
  
  .aiwebmodule-messages {
    padding: 15px;
  }
  
  .aiwebmodule-message {
    max-width: 90%;
    padding: 10px 12px;
  }
  
  .message-content {
    font-size: 14px;
  }
  
  .aiwebmodule-input {
    padding: 12px 15px;
    gap: 8px;
  }
  
  #aiwebmodule-textarea {
    font-size: 14px;
    padding: 10px 12px;
  }
  
  #aiwebmodule-send {
    padding: 10px 14px;
    font-size: 14px;
  }
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

.aiwebmodule-messages::-webkit-scrollbar {
  width: 8px;
}

.aiwebmodule-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.aiwebmodule-messages::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.aiwebmodule-messages::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}
