:root {
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.5);
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%);
  --accent-cyan: #06b6d4;
  --accent-gold: #f59e0b;
  --bg-main: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.95);
  --bg-glass: rgba(31, 41, 55, 0.65);
  --bg-input: rgba(15, 23, 42, 0.8);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-glass: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(59, 130, 246, 0.6);
  --success: #10b981;
  --danger: #ef4444;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-main: 0 30px 70px -15px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 25px rgba(37, 99, 235, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 20% 20%, #172554 0%, #0b0f19 50%, #030712 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-x: hidden;
}

.chat-app-container {
  width: 100%;
  max-width: 440px;
  height: 90vh;
  max-height: 780px;
  background: var(--bg-card);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-main), 0 0 0 1px var(--border-glass);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  animation: modalPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.watermark-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 34px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.025);
  letter-spacing: 6px;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  white-space: nowrap;
}

.chat-header {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass);
  position: relative;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  position: relative;
  flex-shrink: 0;
}

.brand-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: var(--success);
  border-radius: 50%;
  border: 2px solid #0f172a;
  box-shadow: 0 0 8px var(--success);
}

.brand-details h1 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vip-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.brand-details .status-text {
  font-size: 11px;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.pulse-indicator {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-selector-header {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--border-glass);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.lang-selector-header:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
}

.lang-selector-header option {
  background: #0f172a;
  color: #fff;
}

.btn-icon-head {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: #cbd5e1;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon-head:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.login-screen {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  position: relative;
  z-index: 2;
}

.welcome-box {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  box-shadow: var(--shadow-glow);
  text-align: center;
  backdrop-filter: blur(16px);
}

.welcome-icon-box {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.2);
}

.welcome-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.welcome-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.lang-switch-pills {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-glass);
  padding: 4px;
  border-radius: 30px;
  margin-bottom: 24px;
  gap: 4px;
}

.lang-pill-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 20px;
  cursor: pointer;
  color: #94a3b8;
  transition: all 0.2s;
}

.lang-pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.form-group-field {
  text-align: left;
  margin-bottom: 18px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 8px;
}

.input-container-glass {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-box {
  position: absolute;
  left: 14px;
  color: #64748b;
  font-size: 16px;
  pointer-events: none;
}

.input-field-k1 {
  width: 100%;
  padding: 14px 14px 14px 44px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-glass);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: #fff;
  transition: all 0.25s;
  outline: none;
}

.input-field-k1:focus {
  border-color: var(--primary);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input-field-k1::placeholder {
  color: #64748b;
}

.btn-start-action {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.btn-start-action:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.55);
}

.btn-start-action:active {
  transform: translateY(0);
}

.security-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: #64748b;
  margin-top: 18px;
}

.k1-customer-watermark {
  margin-top: 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.16);
  text-transform: uppercase;
  text-align: center;
  user-select: none;
}

.chat-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100% - 76px);
  position: relative;
  z-index: 2;
}

.chat-messages {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #090e17;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  position: relative;
  animation: slideBubble 0.2s ease-out;
}

@keyframes slideBubble {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.system {
  align-self: center;
  max-width: 90%;
  margin: 6px 0;
}

.system-bubble {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 20px;
  text-align: center;
  line-height: 1.4;
  border: 1px solid var(--border-glass);
}

.message-row.customer {
  align-self: flex-end;
}

.message-row.customer .bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.message-row.customer .msg-meta {
  align-self: flex-end;
  font-size: 10px;
  color: #64748b;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.message-row.admin {
  align-self: flex-start;
}

.message-row.admin .sender-label {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 3px;
  margin-left: 2px;
}

.message-row.admin .bubble {
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 16px;
  border-radius: 18px 18px 18px 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.message-row.admin .msg-meta {
  align-self: flex-start;
  font-size: 10px;
  color: #64748b;
  margin-top: 4px;
}

.bubble-attachment {
  margin-top: 8px;
}

.bubble-attachment img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bubble-attachment img:hover {
  transform: scale(1.02);
}

.bubble-attachment video {
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  background: #000;
  display: block;
  outline: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bubble-attachment a.doc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  color: #38bdf8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.typing-box {
  padding: 8px 20px;
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.06);
  border-top: 1px solid rgba(56, 189, 248, 0.1);
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #38bdf8;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.chat-footer {
  background: #0f172a;
  padding: 12px 14px;
  border-top: 1px solid var(--border-glass);
  position: relative;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #1e293b;
  border: 1.5px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: all 0.2s;
}

.input-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 26px;
  font-size: 14px;
  line-height: 1.4;
  color: #fff;
  font-family: inherit;
  padding: 3px 0;
}

.btn-input-action {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-input-action:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.btn-send {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none;
  color: #ffffff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-send:hover {
  transform: scale(1.06);
}

.emoji-tray {
  position: absolute;
  bottom: 76px;
  left: 14px;
  right: 14px;
  background: #1e293b;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  display: none;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
}

.emoji-tray::-webkit-scrollbar {
  width: 4px;
}
.emoji-tray::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.emoji-btn {
  font-size: 22px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.15);
}

.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  cursor: pointer;
}

.lightbox-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.upload-status {
  display: none;
  font-size: 12px;
  color: #38bdf8;
  margin-top: 4px;
  padding: 4px 8px;
  background: rgba(56, 189, 248, 0.1);
  border-radius: 6px;
}

@media (max-width: 480px) {
  body {
    padding: 0;
  }
  .chat-app-container {
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
}
