/* Reset & Base */
:root {
  --primary: #0ea5e9;
  --primary-gradient: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
  --bg-color: #f0f2f5;
  --text-main: #1f2937;
  --text-sub: #6b7280;
  --white: #ffffff;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

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

/* SVG Icons */
svg {
  width: 24px;
  height: 24px;
}

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

/* Background Animation */
.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.circle {
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(6, 182, 212, 0.1) 100%);
  animation: float 20s infinite ease-in-out;
}

.circle1 {
  width: 300px;
  height: 300px;
  top: -100px;
  left: -100px;
}

.circle2 {
  width: 200px;
  height: 200px;
  top: 40%;
  right: -50px;
  animation-delay: -5s;
}

.circle3 {
  width: 150px;
  height: 150px;
  bottom: -50px;
  left: 20%;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(20px, -20px); }
}

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

/* Card / App Window */
.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: 40px 30px;
  animation: fadeIn 0.3s ease;
}

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

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

.brand-logo {
  width: 80px;
  height: 80px;
  background: var(--primary-gradient);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: white;
  box-shadow: 0 10px 25px rgba(14, 165, 233, 0.3);
}

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

.welcome-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-main);
}

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

.start-form {
  width: 100%;
  max-width: 320px;
  margin-bottom: 40px;
}

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

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

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

.input-group input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  font-size: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #f9fafb;
  transition: all 0.3s;
  -webkit-appearance: none;
}

.input-group input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
  outline: none;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-primary:active {
  transform: scale(0.98);
}

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

.features {
  display: flex;
  width: 100%;
  justify-content: space-around;
  padding-top: 20px;
  border-top: 1px solid #f3f4f6;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-sub);
}

.feature-icon {
  width: 40px;
  height: 40px;
  background: #f0f9ff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

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

/* Language Switcher - Dropdown Style */
.lang-switcher {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 100;
  font-family: inherit;
}

.lang-btn {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #334155;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.lang-btn:hover {
  background: #fff;
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.lang-btn .icon-globe {
  width: 16px;
  height: 16px;
  stroke-width: 2px;
}

.lang-btn .icon-chevron {
  width: 14px;
  height: 14px;
  stroke-width: 2px;
  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-radius: 12px;
  padding: 8px;
  min-width: 140px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.lang-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: #334155;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.lang-option:hover {
  background: #f1f5f9;
  color: var(--primary);
}

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

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

.chat-header {
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid #f3f4f6;
  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-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

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

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

.status-online {
  font-size: 12px;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

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

.welcome-message {
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  margin: 20px 0;
  background: rgba(0,0,0,0.03);
  padding: 8px 16px;
  border-radius: 20px;
  align-self: center;
}

.bubble {
  max-width: 80%;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
  animation: messageIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.from-agent {
  align-self: flex-start;
  background: white;
  border-radius: 2px 18px 18px 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  color: var(--text-main);
  border: 1px solid #e5e7eb;
}

.from-customer {
  align-self: flex-end;
  background: var(--primary-gradient);
  border-radius: 18px 2px 18px 18px;
  color: white;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

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

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

.input-container {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #f3f4f6;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #f3f4f6;
  padding: 6px;
  border-radius: 24px;
}

.input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
  min-width: 0;
}

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

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

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

.hidden {
  display: none !important;
}

/* PC Adaptive Override */
@media (min-width: 768px) {
  .card {
    width: 400px;
    height: 650px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  }
  
  .background {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
  }
  
  .circle {
    background: rgba(255, 255, 255, 0.1);
  }
  
  .input-wrapper {
    background: white;
    border: 2px solid #e5e7eb;
    padding: 4px;
  }
  
  .input-wrapper input {
    padding: 8px 16px;
  }
  
  .btn-send {
    width: 36px;
    height: 36px;
  }
  
  /* Scrollbar */
  .messages-container::-webkit-scrollbar {
    width: 6px;
  }
  
  .messages-container::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .messages-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
  }
}