/* ==========================================================================
   AGENT.CSS - Styles for the Simulated AI Estimator
   Provides a premium, software-like interface.
   ========================================================================== */

/* Overall Page Layout */
body.agent-page {
  background-color: #f4f7f6;
  background-image: radial-gradient(circle at top right, rgba(235, 90, 10, 0.05), transparent 400px),
                    radial-gradient(circle at bottom left, rgba(0, 0, 0, 0.05), transparent 400px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  box-shadow: 0 4px 20px rgba(0,0,0,0.02);
  position: relative;
  z-index: 10;
}

.ai-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: 12px;
  display: inline-block;
  vertical-align: middle;
}

.agent-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.agent-container {
  width: 100%;
  max-width: 800px;
}

/* Agent Component Wrapper */
.agent-wrapper {
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.02);
  display: flex;
  flex-direction: column;
  height: 75vh;
  min-height: 600px;
  max-height: 850px;
  overflow: hidden;
  position: relative;
}

/* Header */
.agent-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: #fafbfa;
}

.agent-avatar-wrap {
  position: relative;
  margin-right: 16px;
}

.agent-avatar {
  width: 48px;
  height: 48px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(235, 90, 10, 0.3);
}

.status-indicator {
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #fff;
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  right: 0;
}

.agent-title-area h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
  color: var(--gray-900);
  line-height: 1.1;
}

.agent-title-area p {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin: 4px 0 0 0;
}

#reset-agent {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}
#reset-agent:hover { opacity: 1; }

/* Chat Window */
.agent-chat-window {
  flex: 1;
  padding: 30px 24px;
  overflow-y: auto;
  scroll-behavior: smooth;
  background: #fff;
}

.chat-message {
  display: flex;
  margin-bottom: 24px;
  max-width: 85%;
}

.chat-message.bot-message {
  align-self: flex-start;
}

.chat-message.user-message {
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg-avatar {
  min-width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin: 0 12px;
}

.bot-message .msg-avatar {
  background: rgba(235, 90, 10, 0.1);
}

.user-message .msg-avatar {
  background: var(--gray-200);
  display: none; /* Usually don't need avatar for user in these flows */
}
.user-message .msg-bubble { margin-right: 0; }

.msg-bubble {
  background: #f4f5f7;
  padding: 14px 20px;
  border-radius: 16px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--gray-800);
}

.bot-message .msg-bubble {
  border-top-left-radius: 4px;
}

.user-message .msg-bubble {
  background: var(--gray-900);
  color: #fff;
  border-top-right-radius: 4px;
}

/* Estimate Summary Box */
.estimate-box {
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 20px;
  margin-top: 10px;
  box-shadow: 0 8px 24px rgba(235, 90, 10, 0.15);
}
.estimate-box h3 { font-family: var(--font-display); font-size: 1.8rem; margin: 0 0 8px 0; color: var(--gray-900); }
.estimate-box p { margin: 0; font-size: 0.95rem; color: var(--gray-600); }
.estimate-price { font-size: 2.5rem; font-weight: 800; color: var(--primary); margin: 12px 0; }

/* File Upload Zone */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  background: #fafbfa;
  transition: all 0.2s;
  max-width: 100%;
}
.upload-zone:hover {
  border-color: var(--primary);
  background: rgba(235, 90, 10, 0.05);
}
.upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-zone input[type="file"] { display: none; }

/* Date Picker form */
.date-form { 
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
.date-form input, .date-form select {
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
}
.date-form button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.date-form button:hover { opacity: 0.9; }

/* Input Controls */
.agent-controls {
  padding: 20px 24px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.controls-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end; /* Align user choices to right */
}

.agent-option-btn {
  background: #fff;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 12px 20px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.agent-option-btn:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(235, 90, 10, 0.2);
}

.skip-btn {
  border-color: var(--gray-400);
  color: var(--gray-600);
}
.skip-btn:hover {
  background: var(--gray-600);
  border-color: var(--gray-600);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Animations */
.animate-in {
  opacity: 0;
  transform: translateY(15px);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.delay-1 { animation-delay: 0.6s; }

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

/* AI Visualizer Box */
.ai-visualizer-box {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.visualizer-header {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.visualizer-img {
  width: 100%;
  height: auto;
  display: block;
}

.visualizer-caption {
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--gray-600);
  background: #fafbfa;
  border-top: 1px solid rgba(0,0,0,0.04);
}

/* Vision Loader Overlay */
.vision-loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.95);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.scanner-box {
  width: 250px;
  height: 250px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: #000;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.scanner-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.6;
}

.scanner-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: #00f0ff;
  box-shadow: 0 0 20px #00f0ff, 0 0 40px #00f0ff;
  animation: scan 2s infinite linear alternate;
}

@keyframes scan {
  from { top: 0; }
  to { top: calc(100% - 4px); }
}

.scanning-text {
  margin-top: 24px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--gray-900);
  letter-spacing: 0.05em;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* Mobile Adjustments */
@media(max-width: 768px) {
  .agent-wrapper {
    height: calc(100vh - 120px);
    border-radius: 16px;
  }
  .controls-inner {
    justify-content: flex-start;
  }
  .agent-option-btn {
    width: 100%;
    text-align: center;
  }
}

/* Widget Mode (when embedded on index.html) */
.agent-widget-overlay {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

.agent-widget-toggle {
  background: var(--primary);
  color: #fff;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  font-size: 1.8rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-ring 2.5s ease-in-out infinite;
}

.agent-widget-toggle.close-mode {
  animation: none;
  background: var(--gray-800);
}

.agent-widget-toggle:hover {
  transform: scale(1.05);
}

.agent-widget-window {
  pointer-events: auto;
  margin-bottom: 20px;
  width: 420px;
  max-width: calc(100vw - 48px);
  height: 650px;
  max-height: calc(100vh - 120px);
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.agent-widget-window.show {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.agent-widget-window .agent-wrapper {
  height: 100%;
  min-height: auto;
  max-height: none;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}

@media(max-width: 768px) {
  .agent-widget-window {
    width: calc(100vw - 48px);
    height: 500px;
  }
}

@keyframes tooltipFadeOut {
  0% { opacity: 1; transform: translateY(-50%); }
  100% { opacity: 0; transform: translateY(-50%) translateX(10px); pointer-events: none; }
}

#agentWidgetTooltip {
  animation: tooltipFadeOut 0.4s cubic-bezier(0.16, 1, 0.3, 1) 4.5s forwards;
}

@media(max-width: 1300px) {
  .agent-widget-toggle {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }
  .agent-widget-overlay {
    bottom: 16px;
    right: 16px;
  }
  .agent-widget-window {
    height: 560px;
  }
}
