/* ======================================================
   VARIABLES
   ====================================================== */
:root {
  --bg: #0b0c0f;
  --panel: rgba(255,255,255,0.03);
  --glass: rgba(255,255,255,0.04);
  --muted: #b9bbbf;
  --accent: linear-gradient(90deg,#3dd7ff 0%, #4a90ff 60%);
  --accent-solid: #4a90ff;
  --success: #7bffbf;
  --danger: #ff7b7b;
  --radius: 12px;
  --glass-border: rgba(255,255,255,0.06);
}

/* ======================================================
   RESET & BASE
   ====================================================== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: radial-gradient(
    1200px 600px at 10% 10%,
    rgba(74,144,255,0.04),
    transparent
  ), var(--bg);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  color: #e9eef8;
  overflow-x: hidden;
  overflow-y: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ======================================================
   APP WRAPPER
   ====================================================== */
.root-wrap {
  height: 100vh;
  padding: 16px;
  display: flex;
}

/* ======================================================
   MOBILE FIRST LAYOUT (DEFAULT)
   ====================================================== */
.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.two-col-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.left {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.right {
  display: none;
}

/* Hide image on mobile */
.image-panel {
  display: none;
}

/* ======================================================
   TOPBAR
   ====================================================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid var(--glass-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
}

.brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg,#4a90ff,#3dd7ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.auth-controls {
  display: flex;
  gap: 10px;
}

/* ======================================================
   CHAT CARD
   ====================================================== */
.chat-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  padding: 16px 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.015), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.03);
}

#chatWindow {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 16px;
}

#chatWindow,
#inputBar {
  padding-left: 16px;
  padding-right: 16px;
}

/* ======================================================
   CHAT BUBBLES
   ====================================================== */
.bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}

.user {
  margin-left: auto;
  background: linear-gradient(90deg,#3dd7ff,#4a90ff);
  color: #021227;
  font-weight: 600;
  border-radius: 14px 14px 6px 14px;
}

.bot {
  margin-right: auto;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.03);
}

/* ======================================================
   INPUT BAR
   ====================================================== */
#inputBar {
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

#userInput {
  flex: 1;
  min-height: 48px;
  resize: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.04);
  background: rgba(255,255,255,0.01);
  color: #e9eef8;
  font-size: 15px;
  outline: none;
}

.send-btn {
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  background: var(--accent-solid);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* ======================================================
   TABLET (OPTIONAL IMAGE)
   ====================================================== */
@media (min-width: 768px) {
  .image-panel {
    display: block;
    border-radius: 14px;
    overflow: hidden;
  }

  .two-col-layout {
    display: grid;
    grid-template-columns: 45% 55%;
    gap: 14px;
  }
}

/* ======================================================
   DESKTOP
   ====================================================== */


@media (min-width: 981px) {
  .two-col-layout {
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 16px;
  }

  .right {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .chat-card {
    padding: 18px 0;
    display: flex;
    flex-direction: column;
  }

  .image-panel {
    display: flex;
    align-items: stretch;  /* stretch vertically */
  }

  .image-panel img {
    width: 100%;
    height: 100%;           /* fill the container height */
    object-fit: cover;      /* maintain aspect ratio and crop if needed */
    border-radius: 14px;
  }
}

/* ======================================================
   MOBILE FIXED INPUT BAR
   ====================================================== */
@media (max-width: 767px) {

  .left {
    position: relative;
  }

  #inputBar {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding-top: 8px;
    padding-bottom: 8px;
    z-index: 10;
  }

  .chat-card {
    padding-bottom: 8px;
  }

  #chatWindow {
    padding-bottom: 80px; /* space for input bar */
  }
}

/* ======================================================
   BRAND AVATAR (MOBILE)
   ====================================================== */
.brand-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

.brand-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hide avatar on desktop (image panel already exists) */
@media (min-width: 768px) {
  .brand-avatar {
    display: none;
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(5, 8, 15, 0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.modal {
  width: min(92vw, 420px);
  max-height: 90vh;
  overflow-y: auto;

  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.08),
    rgba(255,255,255,0.03)
  );

  border-radius: 20px;
  padding: 24px 22px;

  border: 1px solid rgba(255,255,255,0.15);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.6),
    inset 0 0 0 1px rgba(255,255,255,0.04);

  animation: modalIn 0.35s ease;
}


@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.modal label {
  font-size: 13px;
  color: var(--muted);
}

.modal input,
.modal textarea,
.modal select {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 12px;
  color: #e9eef8;
  font-size: 14px;
  outline: none;
}

.modal select option {
  background-color: #0b0c0f; /* dark background */
  color: #e9eef8; /* light text */
}


.modal input:focus,
.modal textarea:focus,
.modal select:focus {
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 2px rgba(74,144,255,0.25);
}


.modal .error {
  background: rgba(255,123,123,0.12);
  border: 1px solid rgba(255,123,123,0.35);
  color: #ffbaba;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

.modal .actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.btn {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  border: none;
  font-weight: 700;
  cursor: pointer;
}

.btn {
  background: var(--accent-solid);
  color: #fff;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.15);
}

.modal .consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

.input-inner {
  display: flex;
  gap: 12px;             /* spacing between icon, textarea, and button */
  width: 100%;           /* stretch across chat area */
  padding-left: 16px;    /* align with chat padding */
  padding-right: 16px;   /* align with chat padding */
  box-sizing: border-box;
}

.textarea-wrapper {
  flex: 1;               /* textarea fills remaining space */
  display: flex;
  flex-direction: column;
}

/*#userInput {
  width: 100%;
}*/

#userInput {
  flex: 1;
  min-height: 48px;
  max-height: 120px; /* Limit maximum height */
  resize: none;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.04);
  background: rgba(255,255,255,0.01);
  color: #e9eef8;
  font-size: 15px;
  outline: none;
  line-height: 1.5;
  transition: height 0.2s ease;
  overflow-y: auto;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:disabled:hover {
  filter: none;
}