:root {
    --chat-bg: var(--clr-bg);
    --chat-border: var(--clr-border);
    --chat-accent: var(--clr-primary);
    --chat-user-bg: rgba(100, 149, 237, 0.1);
    --chat-discord-bg: rgba(220, 220, 220, 0.3);
}
/* Container & Steps (desktop default) */
.chat-container {
  /* span the full viewport width and height */
  width: 100vw;
  height: 100vh;

  /* drop any centering margins or padding */
  margin: 0;
  padding: 0;

  /* flex layout as before */
  display: flex;
  flex-direction: column;

  /* prevent container from scrolling; only .chat-messages will scroll */
  overflow: hidden;
}


.chat-step {
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-md);
  transition: opacity 0.3s;
  flex: 1;
}

.chat-step.hidden {
  display: none;
}

/* Forms */
.chat-form {
  margin-top: auto;
}
.chat-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border: 1px solid var(--chat-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}
.chat-form button {
  width: auto;
}

/* Policy */
.chat-policy {
  margin: 1.5rem 0;
  color: var(--clr-text-secondary);
  font-size: 0.95rem;
  text-align: left;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Chat Panel */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--chat-border);
  margin-bottom: 1rem;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.status-indicator {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--chat-border);
  position: relative;
}
.status-indicator.connecting {
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% {
    background: var(--chat-accent);
  }
  50% {
    background: var(--clr-border);
  }
}
.header-right button {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--clr-text-secondary);
}

/* Messages */
.chat-messages {
  flex: 1;             /* take all remaining space within .chat-panel */
  min-height: 0;       /* crucial for overflow in flex children */
  overflow-y: auto;
  padding: 1rem;
  background: var(--chat-discord-bg);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}
.message {
  max-width: 75%;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-lg);
  word-wrap: break-word;
}

/* CHAT.CSS */
/* (above code unchanged) */

.btn--icon {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
}

.typing {
  font-style: italic;
  color: var(--clr-text-secondary);
  text-align: center;
  margin: 0.5rem 0;
}
.typing.hidden {
  display: none;
}

.attachment {
  margin-top: 0.5rem;
  width: 25px;

  max-width: 50px;
  border-radius: var(--radius-sm);
}

.message img {
  display: block;
  margin-top: 0.5rem;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* Persisted theme & history is all JS-driven, layout intact */

.from-user {
  align-self: flex-end;
  background: var(--chat-user-bg);
}
.from-discord {
  align-self: flex-start;
  background: white;
}
.message .timestamp {
  display: block;
  font-size: 0.7rem;
  color: var(--clr-text-secondary);
  margin-top: 0.25rem;
  text-align: right;
}

/* Input */
.chat-input {
  display: flex;
  gap: 0.5rem;
}
.chat-input input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--chat-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}
.send-btn {
  background: var(--chat-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  z-index: 1000;
}
.modal-overlay.hidden {
  display: none;
}
.modal-content {
  background: var(--chat-bg);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 90%;
  max-width: 400px;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-content h3 {
  margin-bottom: 1rem;
}
.modal-content label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.modal-content input[type="text"],
.modal-content input[type="email"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--chat-border);
  border-radius: var(--radius-sm);
}
.toggle-theme {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
}
.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
}

/* === Desktop Full-Screen View === */
@media (min-width: 769px) {
  html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
  }

  .chat-container {
    position: fixed;
    inset: 0;
    overflow: hidden;
  }

  .chat-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    margin: 0;
    padding: 0 0rem;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    z-index: 999;
  }

  /* ensure each step fills the viewport */
  .chat-step {
    display: flex;
    flex-direction: column;
    flex: 1;
  }

  /* keep header and input visible, allow only messages to scroll */
  .chat-header {
    flex-shrink: 0;
  }
  .chat-messages {
    flex: 1;
  }
  .chat-input {
    flex-shrink: 0;
  }
}

/* === Mobile Full View === */
@media (max-width: 768px) {
  html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    touch-action: manipulation;
  }

  .chat-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100dvh;
    max-width: none;
    z-index: 999;
  }

  .chat-step {
    border-radius: 0;
    padding: 1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .chat-header {
    margin-bottom: 0.5rem;
  }

  .chat-messages {
    flex: 1;
    margin-bottom: 0.5rem;
    height: auto;
  }

  .chat-input input {
    font-size: 1rem;
  }

  footer.footer {
    display: none;
  }
}

/* 1) hide the native file-picker control completely */
.file-picker input[type="file"] {
  display: none;
}

/* 2) ensure your paperclip is inline with the text field */
.file-picker {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* 3) tiny badge to show “filename.ext” */
.file-name {
  max-width: 6rem;               /* adjust for how much room you want */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--clr-text-secondary);
}

/* 4) make sure only the text input flexes */
.chat-input input[type="text"] {
  flex: 1;
}

.chat-input .send-btn,
.chat-input #emojiBtn,
.chat-input #attachBtn {
  flex: 0 0 auto;
}



.chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;             /* fill available space */
  min-height: 0;       /* allow children to shrink below content size */
  padding-bottom: 15px;     /* ↟ gap below the input */

}


/* 1) Let .chat-step (the flex item in .chat-container) actually shrink */
.chat-step {
  min-height: 0;
}


.chat-messages {
  flex: 1;             /* take up all remaining space in .chat-panel */
  min-height: 0;       /* crucial for nested flex + overflow */
  overflow-y: auto;    /* enable scrolling when content overflows */
  padding: 1rem;
  background: var(--chat-discord-bg);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}


/* ============================================================================
   Center only the *visible* “step” screens (except the live chat)
   ============================================================================ */

/* ensure hidden steps stay hidden */
.chat-step.hidden {
  display: none;
}

/* flex-center any step that is:
     • not the actual chat (#step-chat)
     • AND not hidden
*/
.chat-step:not(#step-chat):not(.hidden) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  /* allow proper shrinking in nested flex layouts */
  min-height: 0;
}

/* constrain the form width and spacing on visible steps */
.chat-step:not(#step-chat):not(.hidden) .chat-form {
  margin: 0;               /* override any top-auto margin */
  width: 100%;
  max-width: 360px;        /* adjust to taste */
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* same for the policy text container */
.chat-step:not(#step-chat):not(.hidden) .chat-policy {
  max-width: 360px;
  margin: 1rem auto;
  text-align: center;
}

/* tweak the heading spacing on visible steps */
.chat-step:not(#step-chat):not(.hidden) h2 {
  margin-bottom: 1rem;
}


:root[data-theme="dark"] .from-discord {
    background: var(--chat-discord-bg);
    color: var(--clr-text-primary);
  }
  :root[data-theme="dark"] .from-user {
    background: var(--chat-user-bg);
    color: var(--clr-text-primary);
  }
  :root[data-theme="dark"] .from-user strong {
    color: var(--chat-username-self);
  }
  :root[data-theme="dark"] .from-discord strong {
    color: var(--chat-username-other);
  }
  :root[data-theme="dark"] .chat-input input {
    background: var(--chat-input-bg);
    border-color: var(--chat-input-border);
    color: var(--chat-input-text);
  }
  :root[data-theme="dark"] .chat-input input::placeholder {
    color: var(--chat-input-placeholder);
  }
  :root[data-theme="dark"] .btn--icon,
  :root[data-theme="dark"] .header-right button,
  :root[data-theme="dark"] .status-indicator {
    color: var(--icon-color);
  }
  :root[data-theme="dark"] .btn--icon:hover,
  :root[data-theme="dark"] .header-right button:hover {
    color: var(--icon-hover-color);
  }
  :root[data-theme="dark"] .chat-panel {
    background: var(--chat-bg);
  }