/* Reset & Base */
:root {
  --primary: #17aecb;
  --primary-grad: linear-gradient(135deg, #3fd3e7 0%, #12a8c7 100%);
  --bg-color: #ffffff;
  --text-main: #1f2937;
  --text-sub: #6b7280;
  --white: #ffffff;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  height: 100vh;
  overflow: hidden;
  color: var(--text-main);
}

svg {
  width: 24px;
  height: 24px;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* Background */
.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  background: #ffffff;
}

.circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(23, 174, 203, 0.05);
}

.circle1 { width: 280px; height: 280px; top: -120px; left: -110px; }
.circle2 { width: 190px; height: 190px; top: 42%; right: -60px; }
.circle3 { width: 140px; height: 140px; bottom: -50px; left: 18%; }

/* Layout */
.container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  width: 100%;
  height: 100%;
  background: var(--white);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Start Screen */
.start-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 26px;
  animation: fadeIn 0.3s ease;
}

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

.welcome-header {
  text-align: center;
  margin-bottom: 36px;
}

.brand-logo {
  width: 76px;
  height: 76px;
  background: var(--primary-grad);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 22px;
  color: #fff;
  box-shadow: 0 8px 20px rgba(23, 174, 203, 0.28);
}

.brand-logo svg {
  width: 40px;
  height: 40px;
}

.welcome-header h1 {
  font-size: 23px;
  font-weight: 700;
  margin-bottom: 9px;
  color: #111827;
  letter-spacing: 0.5px;
}

.subtitle {
  font-size: 14.5px;
  color: var(--text-sub);
}

.start-form {
  width: 100%;
  max-width: 330px;
  margin-bottom: 34px;
}

.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-icon {
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa4b2;
  pointer-events: none;
  display: flex;
}

.input-icon svg {
  width: 20px;
  height: 20px;
}

.input-group input {
  width: 100%;
  padding: 16px 16px 16px 48px;
  font-size: 15.5px;
  border: 1px solid #e8edf2;
  border-radius: var(--radius);
  background: #f7f9fa;
  color: var(--text-main);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.input-group input::placeholder {
  color: #9aa4b2;
}

.input-group input:focus {
  border-color: #bfe9f2;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(23, 174, 203, 0.1);
  outline: none;
}

.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--primary-grad);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 6px 16px rgba(23, 174, 203, 0.28);
}

.btn-primary:active {
  transform: scale(0.985);
  box-shadow: 0 4px 10px rgba(23, 174, 203, 0.24);
}

.btn-primary .icon-arrow {
  width: 18px;
  height: 18px;
}

.features {
  display: flex;
  width: 100%;
  max-width: 330px;
  justify-content: space-between;
  padding-top: 22px;
  border-top: 1px solid #f1f4f7;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: #7b8794;
  flex: 1;
}

.feature-icon {
  width: 42px;
  height: 42px;
  background: #eef8fc;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #25aecb;
}

.feature-icon svg {
  width: 21px;
  height: 21px;
}

/* Language Switcher */
.lang-switcher {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 100;
}

.lang-btn {
  background: #ffffff;
  border: 1px solid #e6ebf0;
  color: #3c4654;
  padding: 9px 15px;
  border-radius: 22px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.05);
  font-family: inherit;
}

.lang-btn:hover {
  color: var(--primary);
  border-color: #cfeaf2;
}

.lang-btn .icon-globe,
.lang-btn .icon-chevron {
  stroke-width: 1.9;
}

.lang-btn .icon-globe { width: 16px; height: 16px; }
.lang-btn .icon-chevron { width: 14px; height: 14px; transition: transform 0.2s ease; }

.lang-switcher.open .icon-chevron {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: #fff;
  border: 1px solid #eef1f5;
  border-radius: 12px;
  padding: 6px;
  min-width: 140px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.18s ease;
  max-height: 260px;
  overflow-y: auto;
}

.lang-switcher.open .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: #3c4654;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
  font-family: inherit;
}

.lang-option:hover { background: #f4f7fa; }

.lang-option.active {
  background: #eef8fc;
  color: var(--primary);
  font-weight: 600;
}

/* Chat Screen */
.chat-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.chat-header {
  padding: 15px 18px;
  background: #fff;
  border-bottom: 1px solid #f1f4f7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

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

.agent-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary-grad);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 10px rgba(23, 174, 203, 0.22);
}

.agent-avatar svg { width: 20px; height: 20px; }

.agent-info h3 {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 3px;
}

.status-online {
  font-size: 12px;
  color: #22b07d;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #22b07d;
  border-radius: 50%;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: #f7f9fa;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}

.welcome-message {
  text-align: center;
  color: #98a2b3;
  font-size: 12.5px;
  margin: 12px 0;
  background: rgba(16, 24, 40, 0.035);
  padding: 8px 16px;
  border-radius: 14px;
  align-self: center;
  max-width: 88%;
}

.bubble {
  max-width: 80%;
  padding: 11px 14px;
  font-size: 14.8px;
  line-height: 1.55;
  position: relative;
  word-wrap: break-word;
  animation: messageIn 0.25s ease;
}

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

.from-agent {
  align-self: flex-start;
  background: #fff;
  border-radius: 4px 14px 14px 14px;
  border: 1px solid #eef1f5;
  color: var(--text-main);
}

.from-customer {
  align-self: flex-end;
  background: var(--primary-grad);
  border-radius: 14px 4px 14px 14px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(23, 174, 203, 0.22);
}

.message-meta {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.65;
  text-align: right;
}

.from-agent .message-meta { text-align: left; }

.input-container {
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #f1f4f7;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #f7f9fa;
  border: 1px solid #eef1f5;
  padding: 5px 5px 5px 14px;
  border-radius: 24px;
}

.input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 9px 0;
  font-size: 15px;
  outline: none;
  min-width: 0;
  color: var(--text-main);
}

.input-wrapper input::placeholder { color: #9aa4b2; }

.btn-send {
  width: 38px;
  height: 38px;
  background: var(--primary-grad);
  border: none;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.btn-send:disabled { background: #cfd6de; cursor: not-allowed; }

.btn-send svg {
  width: 17px;
  height: 17px;
  margin-left: -2px;
}

.hidden { display: none !important; }

/* Desktop */
@media (min-width: 768px) {
  body { background: #eef4f8; }

  .background {
    background: linear-gradient(160deg, #f4fafc 0%, #e6f1f7 100%);
  }

  .circle { background: rgba(23, 174, 203, 0.07); }

  .card {
    width: 420px;
    height: 700px;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(16, 42, 66, 0.13);
  }

  .messages-container::-webkit-scrollbar { width: 6px; }
  .messages-container::-webkit-scrollbar-track { background: transparent; }
  .messages-container::-webkit-scrollbar-thumb { background: #d5dde6; border-radius: 3px; }
}
