:root {
  --primary-color: #111111;
  --primary-gradient: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  --secondary-color: #ff6b00;
  --bg-dark: #0a0a0a;
  --bg-panel: rgba(20, 20, 20, 0.75);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --font-family: "Inter", system-ui, -apple-system, sans-serif;
  
  --chat-viewport-height: 100dvh;
  --chat-viewport-offset-top: 0px;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-family);
  color: var(--text-main);
  position: relative;
  width: 100%;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(255, 107, 0, 0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.chat-app {
  height: var(--chat-viewport-height);
  width: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
  position: fixed;
  top: var(--chat-viewport-offset-top);
  left: 0;
  overflow: hidden;
  z-index: 1;
}

@media (min-width: 768px) {
  .chat-app {
    position: relative;
    top: auto;
    width: 100vw;
    height: 100vh;
    max-width: none;
    margin: 0;
    background: var(--bg-panel);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.2rem 2rem;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  z-index: 10;
}

.chat-brand-lockup {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.chat-logo-shell {
  position: relative;
  width: 48px;
  height: 48px;
}

.chat-header .logo {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-header .logo:hover {
  transform: scale(1.05);
}

.chat-presence-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid var(--bg-dark);
  border-radius: 50%;
}

.header-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-title h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.header-eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary-color);
  font-weight: 700;
  margin-bottom: 2px;
}

.header-title p {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
  animation: pulseGreen 2s infinite;
}

.premium-icon-button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.premium-icon-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

/* Messages */
#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  scrollbar-width: none; /* Hide scrollbar for a cleaner look */
}

#messages::-webkit-scrollbar {
  display: none;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 8px;
}

.message-row.user {
  justify-content: flex-end;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #2a2a2a;
}

.message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(12px);
}

.message.user {
  align-self: flex-end;
  background: var(--secondary-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.bot, .message.admin {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom-left-radius: 4px;
  color: var(--text-main);
}

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

/* Input Area */
.input-area {
  display: flex;
  align-items: flex-end;
  padding: 1.5rem 2rem;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

.composer-shell {
  flex: 1;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  display: flex;
  align-items: center;
  transition: all 0.3s;
}

.composer-shell:focus-within {
  border-color: var(--secondary-color);
  background: rgba(255, 255, 255, 0.08);
}

.composer-status-dot {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

#message-input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 14px 16px 14px 36px;
  color: var(--text-main);
  font-size: 16px;
  line-height: 1.5;
  outline: none;
  font-family: inherit;
  resize: none;
  max-height: 120px;
}

.composer-attachment-button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.composer-attachment-button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

#send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--secondary-color);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#send-btn:hover {
  transform: scale(1.08);
  background: #ff7b1a;
  box-shadow: 0 8px 20px rgba(255, 107, 0, 0.25);
}

/* Typing Indicator */
.typing {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 18px 18px 18px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin-left: 44px;
}

.typing span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Options */
.digix-options-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-left: 44px;
}

.digix-option-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  animation: slideUp 0.3s ease forwards;
}

.digix-option-chip:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* Cards */
.digix-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 300px;
  margin-top: 8px;
}

.digix-card-image {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.02);
}

.digix-card-body {
  padding: 16px;
}

.digix-card h4 {
  margin: 0 0 8px;
  color: var(--text-main);
  font-size: 15px;
}

.digix-card p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.digix-card-btn {
  display: block;
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 10px;
  border-radius: 10px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.digix-card-btn:hover {
  background: var(--secondary-color);
  color: #fff;
}

.hidden { display: none !important; }

/* Light Mode Overrides */
body.light-mode {
  --bg-dark: #f3f4f6;
  --bg-panel: rgba(255, 255, 255, 0.9);
  --glass-border: 1px solid rgba(0, 0, 0, 0.05);
  --text-main: #111827;
  --text-muted: #6b7280;
}

body.light-mode .chat-header {
  background: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-mode .message.bot, 
body.light-mode .message.admin {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

body.light-mode .input-area {
  background: rgba(255, 255, 255, 0.85);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-mode .composer-shell {
  background: #f9fafb;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .digix-option-chip {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

body.light-mode .digix-card {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .digix-card-btn {
  background: #f3f4f6;
  color: #111827;
}

@media (max-width: 767px) {
  .chat-header {
    padding: 1rem 1.25rem;
  }
  
  #messages {
    padding: 1.25rem;
  }
  
  .message {
    max-width: 85%;
    font-size: 14px;
    padding: 10px 14px;
  }
  
  .input-area {
    padding: 1rem 1.25rem;
  }
}
