/**
 * ODOMIA — Conversational Form Styling
 * Chat bubbles, buttons, inputs, and result modals
 */

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --odomia-primary: #2a668a;
  --odomia-secondary: #1a9b8e;
  --odomia-light: #f0f7fa;
  --odomia-accent: #e8f5f2;
  --odomia-white: #ffffff;
  --odomia-text: #1a1a1a;
  --odomia-grey: #6b7280;
  --odomia-border: #e5e7eb;
}

/* CONTAINER OVERLAY - CACHÉ PAR DÉFAUT */
#estimation-form {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

#estimation-form.active {
  display: flex;
}

/* MODAL CHAT - CENTRÉE ET PLUS GRANDE */
.chat-modal {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: 0 40px 100px rgba(42, 102, 138, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 750px;
  height: auto;
  max-height: 90vh;
  min-height: min(550px, 90vh);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.chat-header {
  background: linear-gradient(135deg, #1e4d6b, #13776d);
  color: white;
  padding: 1.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(0,0,0,0.05);
}

.chat-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: 'Poppins', 'Montserrat', sans-serif;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* MESSAGES CONTAINER */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #fafbfc;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--odomia-light);
  border-radius: 3px;
}

/* CHAT BUBBLE */
.chat-bubble {
  display: flex;
  gap: 0.8rem;
  animation: slideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 0.5rem;
}

.chat-bubble.agent {
  justify-content: flex-start;
  flex-direction: column;
  align-items: flex-start;
}

.chat-bubble.user {
  justify-content: flex-end;
}

.bubble-content {
  padding: 14px 20px;
  border-radius: 18px;
  max-width: 80%;
  word-wrap: break-word;
  font-size: 1rem;
  line-height: 1.6;
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.agent .bubble-content {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  color: var(--odomia-text);
  border-radius: 20px 20px 20px 4px;
  border: 1px solid rgba(42, 102, 138, 0.1);
  box-shadow: 0 10px 25px rgba(42, 102, 138, 0.08);
}

.user .bubble-content {
  background: linear-gradient(135deg, var(--odomia-primary), #3b82f6);
  color: white;
  border-radius: 20px 20px 4px 20px;
  box-shadow: 0 10px 25px rgba(42, 102, 138, 0.2);
}

/* TYPING INDICATOR */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 24px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--odomia-secondary);
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

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

/* INPUT AREA */
.chat-footer {
  padding: 1.25rem;
  border-top: 2px solid var(--odomia-accent);
  background: linear-gradient(to bottom, #ffffff, #f8fbfc);
  display: none; /* Hidden by default, shown only for text input */
  animation: slideUp 0.3s ease-out;
}

.chat-footer.visible {
  display: block;
}

.input-group {
  display: flex;
  gap: 0.75rem;
}

.chat-input {
  flex: 1;
  border: 2px solid var(--odomia-primary);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s;
  background: white;
  color: var(--odomia-text);
}

.chat-input::placeholder {
  color: #9ca3af;
}

.chat-input:focus {
  outline: none;
  border-color: var(--odomia-secondary);
  box-shadow: 0 0 0 4px rgba(26, 155, 142, 0.1);
  background: #fafbfc;
}

.chat-input:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  border-color: #e0e6ed;
}

.send-btn {
  background: linear-gradient(135deg, #357ea6 0%, #4ca896 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  box-shadow: 0 10px 20px rgba(53, 126, 166, 0.2);
  white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(53, 126, 166, 0.3);
}

.send-btn:disabled {
  background: var(--odomia-grey);
  cursor: not-allowed;
  box-shadow: none;
}

/* BUTTONS GROUP — Sous le bubble, sans cadre */
.buttons-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
  width: 100%;
}

/* 2 boutons → 2 colonnes */
.buttons-group:has(> :nth-child(2)) {
  grid-template-columns: repeat(2, 1fr);
}

/* 3 boutons → 3 colonnes */
.buttons-group:has(> :nth-child(3)) {
  grid-template-columns: repeat(3, 1fr);
}

/* 4 boutons → Retour 2 colonnes pour lisibilité */
.buttons-group:has(> :nth-child(4)) {
  grid-template-columns: repeat(2, 1fr);
}

.chat-bubble .buttons-group {
  margin-top: 0.5rem;
}

.btn-option {
  background: linear-gradient(135deg, #357ea6 0%, #4ca896 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(53, 126, 166, 0.2);
  text-align: center;
}

.btn-option:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(53, 126, 166, 0.3);
}

.btn-option.selected {
  opacity: 0.7;
  cursor: default;
}

/* RESULT MODAL — Fullscreen */
.result-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}

.result-modal.hidden {
  display: none;
}

.result-content {
  background: white;
  border-radius: 24px;
  padding: 2rem;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
}

.result-header {
  margin-bottom: 2rem;
}

.result-subtitle {
  color: var(--odomia-grey);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.result-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--odomia-primary);
}

/* RESULT GRID */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.result-item {
  background: linear-gradient(135deg, var(--odomia-accent) 0%, var(--odomia-light) 100%);
  padding: 1.5rem;
  border-radius: 12px;
  border: 2px solid #d0e4f0;
  text-align: center;
}

.result-label {
  color: var(--odomia-grey);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--odomia-primary);
}

/* ERROR MESSAGE */
.error-message {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  color: #991b1b;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* INFO BOX */
.info-box {
  background: #f0fdf4;
  border-left: 4px solid var(--odomia-secondary);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #166534;
  margin-top: 1rem;
}

/* BUTTON GROUP BOTTOM */
.result-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.result-buttons button {
  flex: 1;
  padding: 14px 24px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #357ea6 0%, #4ca896 100%);
  color: white;
  box-shadow: 0 10px 20px rgba(53, 126, 166, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(53, 126, 166, 0.3);
}

.btn-secondary {
  background: var(--odomia-border);
  color: var(--odomia-text);
}

.btn-secondary:hover {
  background: #d0d5dd;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* AUTOCOMPLETE ADRESSE */
.address-suggestions {
  position: fixed;
  background: white;
  border: 1px solid var(--odomia-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 10000;
  max-height: 200px;
  overflow-y: auto;
  width: 520px;
  max-width: calc(100% - 40px);
  display: none;
}

.address-suggestions:not(:empty) {
  display: block;
}

.suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--odomia-text);
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--odomia-light); }

.input-group { position: relative; }

/* CTA RDV MODAL FINALE */
.cta-rdv-box {
  margin-top: 1.5rem;
}

.cta-rdv-text {
  font-size: 0.9rem;
  color: var(--odomia-grey);
  line-height: 1.6;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--odomia-light);
  border-left: 3px solid var(--odomia-secondary);
  border-radius: 0 8px 8px 0;
}

.btn-rdv {
  flex: 1;
  padding: 14px 24px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #357ea6 0%, #4ca896 100%);
  color: white;
  box-shadow: 0 10px 20px rgba(53, 126, 166, 0.2);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-rdv:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(53, 126, 166, 0.3);
}

/* RESPONSIVE */
@media (max-width: 640px) {
  .chat-modal {
    max-height: 95vh;
    border-radius: 16px;
  }

  .chat-header {
    padding: 1.25rem;
  }

  .chat-header h2 {
    font-size: 1.1rem;
  }

  .bubble-content {
    max-width: 90%;
    padding: 12px 16px;
    font-size: 0.95rem;
  }

  .input-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .send-btn {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    height: 54px;
    box-shadow: 0 4px 12px rgba(53, 126, 166, 0.2);
  }

  .chat-input {
    width: 100%;
    height: 54px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-content {
    margin: 0.5rem;
    padding: 1.25rem;
    border-radius: 16px;
  }

  .result-buttons {
    flex-direction: column;
    gap: 0.75rem;
  }
}

@media (max-width: 380px) {
  .chat-modal {
    min-height: 0;
    max-height: 100vh;
    border-radius: 0;
  }
  
  #estimation-form {
    padding: 0;
  }
  
  .chat-messages {
    padding: 1rem;
  }
}
