/* ==========================================================================
   Chat UI (Gemini / ChatGPT Style - Final Visuals)
   ========================================================================== */

/* Wrapper for the transition of the header visibility */
.chat-header-wrapper {
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
  /* FIX: Increased padding to push text down initially */
  padding-top: 40px; 
}

/* State class added via JS when user interacts */
.chat-mode-active .chat-header-wrapper {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding-top: 0;
  pointer-events: none;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  flex: 1;                /* fill all available vertical space */
  min-height: 0;          /* flex overflow fix */
  background: var(--bg-surface);
  overflow: hidden;
  position: relative;     /* context for absolute background logo */
  transition: all 0.3s ease;
}

/* --- BACKGROUND LOGO ANIMATION --- */
.chat-bg-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 140px;
  color: var(--amber);
  opacity: 0.06; /* Very subtle transparency */
  filter: blur(8px); /* Blurred effect */
  pointer-events: none;
  z-index: 0; /* Behind text */
  transition: all 0.6s ease-out;
}

/* When chat starts, logo fades out and moves up */
.chat-mode-active .chat-bg-logo {
  top: 20%;
  opacity: 0;
  transform: translate(-50%, -80%) scale(0.8);
}

/* Message Area */
.chat-output {
  flex: 1;
  overflow-y: auto;
  padding: 40px 24px 10px; 
  display: flex;
  flex-direction: column;
  gap: 24px; 
  scroll-behavior: smooth;
  transform: translateZ(0);
  position: relative;
  z-index: 2; /* Above the logo */
}

/* User Message */
.msg-user {
  align-self: flex-end;
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 20px;
  border-bottom-right-radius: 4px; 
  font-size: 15px;
  line-height: 1.5;
  max-width: 85%;
  border: 1px solid var(--border);
  word-wrap: break-word;
}

/* AI Message */
.msg-ai {
  align-self: flex-start;
  background: transparent;
  color: var(--text);
  padding: 0 4px;
  font-size: 15px;
  line-height: 1.6;
  max-width: 100%;
  width: 100%;
}
.msg-ai strong { color: var(--green); font-weight: 600; }
.msg-ai ul { padding-left: 20px; margin: 8px 0; }
.msg-ai li { margin-bottom: 4px; }

/* AI Header (Avatar + Name) */
.ai-header {
  display: flex; 
  align-items: center; 
  gap: 8px; 
  margin-bottom: 6px; 
  opacity: 0.9;
}

/* Form Area */
.chat-form {
  padding: 10px 24px 20px;
  background: transparent;
  flex-shrink: 0;
  display: flex;
  flex-direction: column; /* Stack input and disclaimer */
  align-items: center;
  position: relative;
  z-index: 20;
}

.chat-input-wrapper {
  width: 100%;
  max-width: 760px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 8px 8px 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.chat-input-wrapper:focus-within {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.08),
    0 0 0 4px rgba(227,116,0,0.16);
}

.chat-input {
  flex: 1;
  border: none !important;      
  background: transparent !important;
  box-shadow: none !important;   
  outline: none !important;     
  padding: 4px 0 !important;
  font-size: 16px; 
  color: var(--text);
  height: auto;
  max-height: 120px;
}


.chat-input:focus::placeholder {
  opacity: 0;
  transition: opacity 0.2s ease; 
}

.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text);
  color: var(--bg);
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
  flex-shrink: 0;
}

/* --- DISCLAIMER FOOTER --- */
.chat-disclaimer {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
  opacity: 0.7;
  max-width: 400px;
}
.chat-disclaimer a {
  text-decoration: underline;
  color: var(--text);
}

.chat-copy-btn {
  margin-top: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.chat-copy-btn:hover { color: var(--text); background: var(--bg-elev-2); }
.chat-copy-btn .material-icons { font-size: 16px; }

.chat-loading{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:8px;
}

.chat-spinner{
  font-size:18px;
  display:inline-block;
  animation: chatSpin 1s linear infinite;
}

@keyframes chatSpin{
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ==========================================================================
   Desktop: Immersive Full-Space Chat Layout  (min-width: 981px)
   The chat fills the entire .content area — no card, no margins.
   Mobile (≤980px) is handled separately in main.css (position:fixed overlay).
   ========================================================================== */

@media (min-width: 981px) {

  /* Remove .content padding so chat goes edge-to-edge */
  body.view-mode-chat .content {
    padding: 0;
    overflow: hidden; /* chat-output handles its own scroll */
  }

  /* Chat section stretches to fill the content area */
  #glasbox_chat.view-section {
    max-width: none;
    margin: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    animation: none; /* skip fadeUp — immersive host */
  }

  #glasbox_chat.view-section.active {
    display: flex;
  }

}
