/* AI Message Box Component Styles
   --------------------------------------------------
   All .ai-message-box rules are consolidated here.
   This file is the single source of truth for the component's styles.
*/

.ai-message-box {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  left: auto;
  z-index: 1010;
  width: 360px;
  max-width: calc(100vw - 3rem);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 1rem 1rem 0.75rem 1rem;
  border: 1px solid rgba(244, 119, 33, 0.12);
  overflow: hidden;
  transition: width 0.25s ease, padding 0.25s ease, border-radius 0.25s ease, box-shadow 0.25s ease;
}
@media (max-width: 768px) {
  .ai-message-box:not(.minimized) {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    width: auto;
    max-width: none;
  }
}

@media (max-width: 576px) {
  .ai-message-box:not(.minimized) {
    bottom: 0.5rem;
    right: 0.5rem;
    left: 0.5rem;
  }
}

.ai-message-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(244, 119, 33, 0.05) 100%);
  pointer-events: none;
}

.ai-message a, .ai-message-box a {
  pointer-events: auto;
  color: #f47721;
  text-decoration: underline;
  cursor: pointer;
}

.ai-message a:hover, .ai-message-box a:hover {
  color: #d96a1b;
}
.ai-message-box:focus-within {
  box-shadow: 0 0 0 3px rgba(244,119,33,0.11);
}
.ai-message-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.ai-avatar {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.8rem;
  background: linear-gradient(135deg, #fff4e6 0%, #f47721 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  box-shadow: 0 2px 12px rgba(244, 119, 33, 0.1);
}
#ai-messages {
  min-height: 80px;
  max-height: 210px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 0.75rem;
  padding: 0.85rem 1.1rem 0.85rem 1.1rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}
.ai-message {
  background: rgba(244, 119, 33, 0.05);
  color: #f47721;
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  max-width: 90%;
  box-shadow: 0 1px 3px rgba(244, 119, 33, 0.1);
  position: relative;
  overflow: hidden;
  pointer-events: auto;
}
.ai-message::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(244, 119, 33, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  pointer-events: none;
}
.ai-message:hover::before {
  transform: translateX(0);
}
.user-message {
  background: rgba(255, 255, 255, 0.95);
  color: #444;
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  margin-left: auto;
  text-align: right;
  max-width: 90%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}
.user-message::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(244, 119, 33, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.user-message:hover::before {
  transform: translateX(0);
}
.ai-input-row {
  display: flex;
  gap: 0.5rem;
}
#user-input {
  flex: 1;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.95);
  padding: 0.6rem 0.8rem;
  transition: all 0.2s ease;
}
#user-input:focus {
  border-color: rgba(244, 119, 33, 0.2);
  box-shadow: 0 0 0 3px rgba(244, 119, 33, 0.1);
}
#ai-send-btn {
  min-width: 70px;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #fff4e6 0%, #f47721 100%);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
}
#ai-send-btn:hover {
  background: linear-gradient(135deg, #f47721 0%, #fff4e6 100%);
  box-shadow: 0 2px 8px rgba(244, 119, 33, 0.2);
}
.ai-spinner {
  display: none;
  margin-left: 0.5rem;
  align-self: center;
}
.ai-message-box.loading .ai-spinner {
  display: inline-block;
}
.ai-status {
  min-height: 1.4em;
  font-size: 0.96em;
  color: #444;
  margin-top: 0.5em;
  margin-bottom: 0.1em;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.ai-status::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(244, 119, 33, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.ai-status:hover::before {
  transform: translateX(0);
}

.ai-minimize-toggle {
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(244, 119, 33, 0.08);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.ai-minimize-toggle:hover {
  background: rgba(244, 119, 33, 0.18);
}

.ai-minimize-toggle i {
  font-size: 0.75rem;
  transition: transform 0.3s ease;
}

/* Expanded — arrow points down (click to minimize) */
.ai-minimize-toggle i { transform: rotate(0deg); }

/* Minimized — arrow points up (click to expand) */
.ai-message-box.minimized .ai-minimize-toggle i {
  transform: rotate(180deg);
}

/* ── Minimized pill ─────────────────────────────────────────────────── */
.ai-message-box.minimized {
  width: auto;
  min-width: 0;
  padding: 0.45rem 0.85rem;
  border-radius: 50px;
  box-shadow: 0 4px 16px rgba(244, 119, 33, 0.15);
  cursor: pointer;
}

.ai-message-box.minimized .ai-message-header {
  margin-bottom: 0;
  gap: 0.5rem;
}

.ai-message-box.minimized .ai-avatar {
  width: 1.6rem;
  height: 1.6rem;
  font-size: 0.85rem;
}

.ai-message-box.minimized h5 {
  font-size: 0.85rem;
}

.ai-message-box.minimized #ai-messages,
.ai-message-box.minimized .ai-spinner,
.ai-message-box.minimized #ai-message-form,
.ai-message-box.minimized #ai-status {
  display: none !important;
}
/* Dark mode styles */
/* Dark mode support for AI Message Box */
body.dark-mode .ai-message-box {
  background: rgba(25, 25, 25, 0.95);
  border-color: rgba(45, 45, 45, 0.15);
}
body.dark-mode .ai-avatar {
  background: linear-gradient(135deg, #f47721 60%, #fff4e6 100%);
}
body.dark-mode #ai-messages {
  background: rgba(25, 25, 25, 0.95);
  border-color: rgba(45, 45, 45, 0.15);
}
body.dark-mode .ai-message {
  background: rgba(244, 119, 33, 0.1);
  color: #f47721;
}
body.dark-mode .user-message {
  background: rgba(25, 25, 25, 0.95);
  color: #ddd;
}
body.dark-mode #user-input {
  background: rgba(25, 25, 25, 0.95);
  border-color: rgba(45, 45, 45, 0.15);
  color: #ddd;
}
body.dark-mode #user-input::placeholder {
  color: #666;
}
body.dark-mode .ai-status {
  color: #ddd;
}
@media (max-width: 576px) {
  .ai-message-box {
    max-width: 99vw;
    padding: 1rem 0.5rem 0.5rem 0.5rem;
  }
  #ai-messages {
    padding: 0.5rem 0.3rem 0.5rem 0.3rem;
  }
}
/* Container padding for fixed AI message box */
.container-wrapper {
  padding-bottom: 320px;
}

/* Streaming typing cursor */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #f47721;
  margin-left: 2px;
  vertical-align: middle;
  animation: ai-blink 0.7s infinite;
}

@keyframes ai-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Links inside AI messages */
.ai-link {
  color: #f47721;
  text-decoration: underline;
  pointer-events: auto;
}

.ai-link:hover {
  color: #d96a1b;
}

/* Internal navigation links → pill buttons */
.ai-action-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 2rem;
  background: rgba(244, 119, 33, 0.09);
  border: 1px solid rgba(244, 119, 33, 0.28);
  color: #f47721;
  font-size: 0.83em;
  font-weight: 500;
  text-decoration: none;
  margin: 2px 2px;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
  pointer-events: auto;
}

.ai-action-link:hover {
  background: rgba(244, 119, 33, 0.18);
  color: #c95e10;
  text-decoration: none;
}

body.dark-mode .ai-action-link {
  background: rgba(244, 119, 33, 0.14);
  border-color: rgba(244, 119, 33, 0.32);
  color: #ff9147;
}

/* Bullet points */
.ai-bullet {
  display: block;
  padding-left: 0.5rem;
  margin-bottom: 0.15rem;
}

body.dark-mode .ai-link {
  color: #ff9147;
}

body.dark-mode .typing-cursor {
  background: #ff9147;
}
