
/* ==========================================
   TINVIN AI — PREMIUM NEON GLASS CHAT
   Visual redesign only — functionality preserved
========================================== */

#chatPage {
  width: 100%;
  min-width: 0;
  color: var(--text);
}

/* Main Glass Workspace */

#chatPage .chat-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: min(76vh, 850px);
  min-height: 520px;
  max-height: 850px;
  overflow: hidden;
  padding: 18px;
  border-radius: 26px;
  box-sizing: border-box;

  background:
    radial-gradient(ellipse at 0% 0%, rgba(52, 150, 255, .20), transparent 43%),
    radial-gradient(ellipse at 100% 100%, rgba(155, 75, 255, .19), transparent 45%),
    radial-gradient(ellipse at 55% 45%, rgba(40, 190, 220, .06), transparent 55%),
    linear-gradient(145deg, rgba(15, 27, 55, .88), rgba(8, 14, 32, .94));

  border: 1px solid rgba(100, 175, 255, .27);

  box-shadow:
    0 20px 65px rgba(0, 0, 0, .35),
    0 0 35px rgba(50, 130, 255, .09),
    inset 0 1px 1px rgba(255, 255, 255, .10);

  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

/* Chat History */

#chatPage .chat-history {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  max-height: none;
  padding: 12px 5px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(80, 165, 255, .65) transparent;
}

#chatPage .chat-history::-webkit-scrollbar {
  width: 5px;
}

#chatPage .chat-history::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #51b8ff, #8c72ff, #c16cff);
  border-radius: 10px;
}

/* Glass Messages */

#chatPage .chat-bubble {
  width: fit-content;
  max-width: 88%;
  padding: 14px 17px;

  border: 1px solid rgba(135, 180, 255, .20);
  border-radius: 20px;

  background:
    linear-gradient(135deg,
      rgba(55, 130, 220, .16),
      rgba(110, 85, 190, .13));

  color: var(--text);
  line-height: 1.8;
  overflow-wrap: anywhere;

  box-shadow:
    0 7px 25px rgba(0, 0, 0, .17),
    inset 0 1px 1px rgba(255, 255, 255, .08);

  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  animation: chatMessageIn .22s ease;
}

#chatPage .chat-bubble.user {
  align-self: flex-end;

  border: 1px solid rgba(105, 185, 255, .42);
  border-bottom-right-radius: 6px;

  background:
    linear-gradient(125deg,
      rgba(24, 133, 240, .90),
      rgba(92, 94, 230, .90),
      rgba(139, 77, 220, .85));

  color: #fff;

  box-shadow:
    0 8px 28px rgba(45, 120, 255, .23),
    inset 0 1px 1px rgba(255, 255, 255, .22);
}

#chatPage .chat-bubble.assistant {
  align-self: flex-start;
  border-bottom-left-radius: 6px;

  background:
    linear-gradient(135deg,
      rgba(255, 255, 255, .075),
      rgba(55, 135, 230, .12),
      rgba(145, 90, 210, .10));
}

#chatPage .chat-message {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#chatPage .chat-image {
  display: block;
  width: 100%;
  max-width: 520px;
  max-height: 520px;
  margin-top: 10px;
  border-radius: 17px;
  object-fit: contain;

  border: 1px solid rgba(100, 175, 255, .28);

  box-shadow:
    0 10px 30px rgba(0, 0, 0, .25),
    0 0 20px rgba(70, 150, 255, .10);
}

#chatPage .chat-user-attachment {
  border: 1px solid rgba(100, 175, 255, .35);
  border-radius: 14px;
}

#chatPage .chat-file-item {
  margin-top: 8px;
  padding: 10px 13px;

  border: 1px solid rgba(105, 165, 255, .25);
  border-radius: 13px;

  background: rgba(55, 125, 220, .11);
  overflow-wrap: anywhere;
  font-size: 13px;
}

/* Attachment Preview */

#chatPage .chat-attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 10px;
}

#chatPage .chat-attachment-preview:empty {
  display: none;
}

#chatPage .chat-attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px 11px;

  border: 1px solid rgba(100, 170, 255, .30);
  border-radius: 13px;

  background: rgba(35, 100, 190, .16);
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

#chatPage .chat-attachment-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#chatPage .chat-attachment-item button {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(90, 120, 240, .30);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

/* Glass Composer */

#chatPage .chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  flex: 0 0 auto;
  padding: 12px;
  margin-top: 8px;

  border: 1px solid rgba(105, 170, 255, .30);
  border-radius: 22px;

  background:
    linear-gradient(135deg,
      rgba(30, 100, 190, .18),
      rgba(100, 65, 180, .16),
      rgba(30, 150, 190, .11));

  box-shadow:
    0 10px 35px rgba(0, 0, 0, .18),
    0 0 25px rgba(60, 130, 255, .08),
    inset 0 1px 1px rgba(255, 255, 255, .09);

  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
}

#chatPage .chat-attachment-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

#chatPage .chat-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 43px;
  height: 48px;
  padding: 0;

  border: 1px solid rgba(105, 170, 255, .32);
  border-radius: 15px;

  background: rgba(45, 120, 220, .17);
  color: #8dccff;
  font-size: 20px;
  cursor: pointer;

  transition: .25s ease;
}

#chatPage .chat-attach-btn:hover {
  border-color: #51b8ff;
  background: rgba(65, 145, 255, .28);
  color: #fff;
  transform: translateY(-2px);

  box-shadow:
    0 0 20px rgba(65, 160, 255, .24);
}

/* Input */

#chatPage #chatInput {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  max-height: 130px;
  resize: vertical;

  padding: 13px 15px;
  border-radius: 16px;
  box-sizing: border-box;

  border: 1px solid rgba(105, 170, 255, .25);

  background:
    linear-gradient(135deg,
      rgba(8, 19, 42, .78),
      rgba(45, 55, 110, .28));

  color: #fff;
  font-size: 15px;

  outline: none;

  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  transition: .25s ease;
}

#chatPage #chatInput::placeholder {
  color: rgba(180, 210, 245, .55);
}

#chatPage #chatInput:focus {
  border-color: rgba(75, 175, 255, .85);

  box-shadow:
    0 0 0 3px rgba(65, 155, 255, .12),
    0 0 25px rgba(65, 155, 255, .15);
}

/* Send Button */

#chatPage #sendBtn {
  flex: 0 0 auto;
  min-width: 58px;
  min-height: 48px;
  padding: 0 15px;

  border: 1px solid rgba(130, 190, 255, .40);
  border-radius: 15px;

  background:
    linear-gradient(125deg, #219cf2, #5669ed, #9955e9);

  color: #fff;
  font-weight: 700;
  cursor: pointer;

  box-shadow:
    0 6px 23px rgba(50, 130, 255, .30),
    inset 0 1px 1px rgba(255, 255, 255, .25);

  transition: .25s ease;
}

#chatPage #sendBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 9px 30px rgba(65, 140, 255, .42);
}

#chatPage #sendBtn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

#chatPage #newChatBtn {
  flex: 0 0 auto;
  margin-top: 10px;
}

#chatPage #chatStatus {
  flex: 0 0 auto;
  min-height: 18px;
  padding: 7px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

/* Premium Upgrade */

#chatPage .chat-upgrade-btn {
  margin-top: 10px;
}

/* Animation */

@keyframes chatMessageIn {
  from {
    opacity: 0;
    transform: translateY(7px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile */

@media (max-width: 600px) {
  #chatPage .chat-layout {
    height: 74vh;
    min-height: 440px;
    max-height: 760px;
    padding: 12px;
    border-radius: 20px;
  }

  #chatPage .chat-history {
    min-height: 0;
    gap: 14px;
    padding: 8px 3px 15px;
  }

  #chatPage .chat-bubble {
    max-width: 94%;
    padding: 11px 13px;
    font-size: 14px;
    border-radius: 17px;
  }

  #chatPage .chat-compose {
    gap: 6px;
    padding: 9px;
    border-radius: 18px;
  }

  #chatPage .chat-attachment-controls {
    gap: 5px;
  }

  #chatPage .chat-attach-btn {
    width: 38px;
    height: 46px;
    font-size: 18px;
    border-radius: 12px;
  }

  #chatPage #chatInput {
    min-height: 46px;
    max-height: 110px;
    padding: 11px 10px;
    font-size: 16px;
  }

  #chatPage #sendBtn {
    min-width: 48px;
    min-height: 46px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 13px;
  }

  #chatPage .chat-image {
    max-height: 350px;
  }
}

@media (max-width: 370px) {
  #chatPage .chat-attach-btn {
    width: 34px;
  }

  #chatPage .chat-compose {
    gap: 5px;
  }

  #chatPage #sendBtn {
    min-width: 43px;
    padding: 0 7px;
  }
}

/* Reduced Motion */

@media (prefers-reduced-motion: reduce) {
  #chatPage .chat-bubble {
    animation: none;
  }

  #chatPage .chat-history {
    scroll-behavior: auto;
  }
}
