/* ====== Global Styles ====== */
body {
  margin: 0;
  font-family: "Poppins", sans-serif;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  border-bottom: 1px solid #222;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 1px;
}

.menu-icon {
  font-size: 28px;
  cursor: pointer;
  user-select: none;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
}

.profile {
  font-size: 28px;
  cursor: pointer;
  user-select: none;
  margin-left: auto; /* pushes the profile icon to the far right */
}

/* ====== Chat Area ====== */
#chatbox {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #444 #111;
}

/* Messages */
.msg {
  max-width: 75%;
 
}
.user {
  background: #2d2d2d;
  align-self: flex-end;
  padding: 12px 16px;
  margin: 8px 0;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-line;
  animation: fadeIn 0.3s ease-in-out;
  position: relative;
  word-break: break-word;
}
.bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  max-width: 99%;
  padding: 12px 16px;
  margin: 1px 0;
  line-height: 1.5;
  white-space: pre-line;
  animation: fadeIn 0.3s ease-in-out;
  position: relative;
  word-break: break-word;
  justify-content:center;
}

/* Action buttons under AI replies */
.msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  font-size: 8px;
  opacity: 1;
  pointer-events: auto;
  position: relative;
}
.msg-actions button {
  background: rgba(255, 255, 255, 0.04);
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
  color: #ccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.msg-actions button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* Input Area fixed at bottom */
#input-area {
  position: fixed;       /* stick at bottom */
  bottom: 0px;
  left: 50%;            /* Center horizontally */
  transform: translateX(-50%); /* Center adjustment */
  display: flex;
  align-items: center;
  padding: 12px;        /* Increased padding for height */
  background: rgba(255, 255, 255, 0.05);  /* Dark color matching screenshot */
  border: 1px solid rgba(255,255,255,0.15); /* Subtle border */
  width: 85%;
  border-radius: 25px;  /* Slightly larger radius for a smoother look */
  z-index: 1000;
   box-shadow: 0 8px 30px rgba(0,0,0,0.5);
      animation: fadeIn 1s ease-out;; /* Soft shadow for depth */
  min-height: 60px;    
  backdrop-filter: blur(12px);
   /* Increased height */
}

/* Wrapper around textarea + small mic */
.input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

/* Prevent chat overlapping input */
#chatbox {
  padding-bottom: 60px;  /* space for input area */
  overflow-y: auto;
}

/* Textarea styling */
#user-input {
  flex: 1;
  padding: 11px 40px 11px 18px;  /* extra right space for mic */
  background: transparent;
  border: none;
  border-radius: 25px;
  color: #fff;
  font-size: 13px;
  resize: none;
  overflow-y: hidden;
  min-height: 46px;
  max-height: 200px;
  font-family: inherit;
  box-sizing: border-box;
}
#user-input:focus {
  outline: none;
}

/* Small mic inside textarea */
#voice-to-text {
  position: absolute;
  right: 12px;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  user-select: none;
}
#voice-to-text.hidden {
  display: none;
}

/* Big button (waves / send) */
#action-btn {
  background: #3b82f6;
  border: none;
  border-radius: 50%;
  padding: 12px;
  margin-left: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#action-btn:hover {
  background: #2563eb;
}
#action-btn .material-icons {
  color: white;
  font-size: 16px;
}

/* While listening */
#action-btn.listening {
  background: red;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7); }
  70%  { box-shadow: 0 0 0 12px rgba(255, 0, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}

/* ====== Animations ====== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
/* ====== Drawer ====== */
.drawer {
  position: fixed;
  top: 0;
  left: -100%;
  width: 220px;
  height: 100%;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  padding: 20px;
  z-index: 2000;
  transition: 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: #fff;
}
.drawer.active { left: 0; }

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: none;
  z-index: 1999;
}
.overlay.active { display: block; }

.sidebar-search {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  padding: 8px 12px;
  gap: 8px;
}
.sidebar-search input {
  border: none;
  background: transparent;
  outline: none;
  color: #e8eef9;
  font-size: 10px;
  width: 100%;
}
.sidebar-search .material-icons {
  color: #6c757d;
  font-size: 18px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(90deg, #00ffcc, #0077ff);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  font-family: inherit;
}
.new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #444 #111;
  padding-right: 6px;
}
.chat-history-item {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 10px;
  color: #fff;
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}
.chat-history-item:hover {
  background: rgba(255,255,255,0.03);
}

/* ====== Popup & Modal ====== */
#popup {
  position: fixed;
  display: none;
  background: #0b1220;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 2000;
}
#popup button {
  display: block;
  background: none;
  border: none;
  color: #fff;
  padding: 8px 12px;
  text-align: left;
  width: 70%;
  cursor: pointer;
  border-radius: 6px;
}
#popup button:hover {
  background: rgba(255,255,255,0.03);
}

#modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  z-index: 3000;
}
.modal-card {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 18px;
  border-radius: 12px;
  min-width: 320px;
  box-shadow: 0 12px 40px rgba(2,6,23,0.8);
}
.modal-card h3 { margin: 0 0 8px 0; font-size: 16px; }
.modal-card p { margin: 0 0 12px 0; color: #cbd5e1; font-size: 14px; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}
.modal-actions button { padding: 8px 12px; border-radius: 8px; border: none; cursor: pointer; }
.btn-cancel { background: transparent; color: #9aa4b2; }
.btn-confirm { background: #ef4444; color: #fff; }
.modal-input {
  width: 75%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  background: transparent;
  color: #fff;
}

/* ====== Toast ====== */
#toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  display: none;
  z-index: 4000;
  font-size: 13px;
}

/* ====== Image Upload & Chat Images ====== */
#upload-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 8px;
  font-size: 17px;
  transition: background 0.2s ease;
}
#upload-btn:hover { background: #1d4ed8; }
#upload-btn:active { background: #1e40af; }

.upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.upload-preview img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.chat-image {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 6px 0;
  display: block;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.chat-image.loading { opacity: 0.3; background: #eee; }
.chat-image.loaded { opacity: 1; transition: opacity 0.4s ease; }

.image-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.image-actions button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 9px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.image-actions button:hover { background: #1d4ed8; }

/* Chat images container (multiple images) */
.chat-images {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}
.chat-images img {
  max-width: 45%;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s;
}
.chat-images img:hover { transform: scale(1.05); }

/* ====== Lightbox ====== */
.lightbox {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.9);
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}
.lightbox.active { display: flex; }

.lightbox img { max-width: 90%; max-height: 80%; border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.6); }
.lightbox-close { position: absolute; top: 10px; right: 10px; font-size: 36px; color: white; cursor: pointer; }

.lightbox-gallery-container {
  overflow-x: auto;
  display: flex;
  width: 90%;
  height: 50%;
}
.lightbox-gallery {
  display: flex;
  gap: 10px;
  height: 100%;
}
.lightbox-gallery img.lb-img {
  height: 100%;
  cursor: pointer;
  flex-shrink: 0;
}

.download-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  font-size: 28px;
  color: white;
  background: #0a84ff;
  padding: 12px 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: background 0.3s;
}
.download-btn:hover { background: #006edc; }

/* ====== Responsive ====== */
@media (max-width:480px) {
  .drawer { width: 70%; }
}
    /* Suggestions (kept) */
    #welcome { text-align:center; margin-top:60px; animation:fadeIn 0.6s ease-in-out; }
    #welcome h2 { font-size:15px; margin-bottom:20px; font-weight:600; }
    .suggestions { display:flex; flex-wrap:wrap; gap:12px; justify-content:center; }
    .suggestion { border: 1px solid rgba(255,255,255,0.15); border-radius:25px; padding:10px 16px; font-size:10px; cursor:pointer; color:#ccc; display:flex; align-items:center; gap:6px; transition:0.2s; }
    .suggestion:hover { border-color:#666; color:#fff; background:#111; }
    .loading-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
   background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  z-index: 9999;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.loader {
  width: 120px; height: 120px;
  animation: rotate 2s linear infinite;
}

.logo {
  width: 100%; height: 100%;
  animation: fadePulse 1.5s ease-in-out infinite;
}

.text {
  margin-top: 1rem;
  font-size: 26px;
  color: #fff;
  letter-spacing: 2px;
  font-family: Times New Roman;
  animation: fadeIn 1.5s ease-in-out infinite alternate;
}

/* Hide loader when app is ready */
body.loaded .loading-container {
  opacity: 0;
  visibility: hidden;
}

@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes fadePulse {
  0%,100% { opacity: 0.6; }
  50% { opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}
.warning-box {
  background: #ffebee;
  border: 1px solid #f44336;
  border-radius: 10px;
  padding: 10px;
  margin: 10px;
  color: #b71c1c;
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.retry-btn {
  font-size: 27px;   /* make it big */
  cursor: pointer;
  color: #f44336;
  transition: transform 0.3s ease;
}

.retry-btn.clicked {
  animation: spin 0.8s linear;
}

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