@import url('https://cdn.web-fonts.ge/fonts/bpg-mrgvlovani/css/bpg-mrgvlovani.min.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css');

/*
  Responsive, mobile-first refinement for your chat UI.
  Highlights:
  - Fluid type & spacing with clamp()
  - Viewport-safe heights (100dvh + iOS safe-area insets)
  - Tighter mobile layout, larger touch targets
  - Landscape & very-small-device tweaks
  - High-contrast and reduced-motion support
  - Subtle perf optimizations (lighter shadows on mobile)
*/

:root {
  /* Color system */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #5b47d6 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #4facfe 100%);
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --border-color: #e5e7eb;

  /* Elevation */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Fluid typography & spacing scales */
  --step--1: clamp(0.82rem, 0.72rem + 0.4vw, 0.95rem);
  --step-0: clamp(1rem, 0.9rem + 0.5vw, 1.1rem);
  --step-1: clamp(1.125rem, 1rem + 0.8vw, 1.35rem);
  --step-2: clamp(1.4rem, 1.1rem + 2.2vw, 2rem);
  --step-3: clamp(1.9rem, 1.6rem + 2.6vw, 2.6rem);
  --step-4: clamp(2.4rem, 2rem + 3.2vw, 3.25rem);

  /* Spacing */
  --space-1: clamp(0.5rem, 0.4rem + 0.4vw, 0.75rem);
  --space-2: clamp(0.75rem, 0.6rem + 0.6vw, 1rem);
  --space-3: clamp(1rem, 0.8rem + 1vw, 1.5rem);
  --space-4: clamp(1.25rem, 1rem + 1.2vw, 2rem);
  --space-5: clamp(1.5rem, 1.2rem + 1.8vw, 2.5rem);
}

* { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: "BPG Mrgvlovani", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--primary-gradient);
  min-height: 100vh;
  min-height: 100dvh; /* modern viewport units */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  line-height: 1.6;
  color: var(--text-primary);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Enhanced Background Animation */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(120, 219, 226, 0.2) 0%, transparent 50%);
  animation: backgroundShift 15s ease-in-out infinite;
  z-index: -1;
}

@keyframes backgroundShift {
  0%, 100% { opacity: 1; transform: translateY(0) rotate(0); }
  50% { opacity: 0.85; transform: translateY(-20px) rotate(2deg); }
}

/* Main Container */
.container {
  text-align: center;
  color: white;
  z-index: 1;
  max-width: min(720px, 92vw);
  padding: var(--space-4);
}

.logo-container { margin-bottom: var(--space-3); display: grid; place-items: center; position: relative; }

.main-logo {
  max-width: min(280px, 70vw);
  max-height: 140px;
  filter: drop-shadow(0 8px 32px rgba(0,0,0,0.3));
  transition: transform .4s cubic-bezier(0.34,1.56,0.64,1), filter .4s ease;
}
.main-logo:hover { transform: scale(1.08) translateY(-8px); filter: drop-shadow(0 16px 48px rgba(0,0,0,0.4)); }

.container h1 {
  font-size: var(--step-3);
  margin-bottom: var(--space-2);
  text-shadow: 0 4px 20px rgba(0,0,0,0.3);
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, #f0f8ff 50%, #e6f3ff 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.container p { font-size: var(--step-0); opacity: 0.95; max-width: 60ch; margin: 0 auto; text-shadow: 0 2px 8px rgba(0,0,0,0.2); }

/* Floating Chat Button */
.chat-button {
  position: fixed;
  right: clamp(12px, 3vw, 32px);
  bottom: calc(clamp(12px, 3vw, 32px) + env(safe-area-inset-bottom, 0px));
  width: clamp(56px, 7vw, 72px);
  height: clamp(56px, 7vw, 72px);
  background: var(--primary-gradient);
  border: none; border-radius: 50%; color: white;
  font-size: clamp(20px, 2.8vw, 28px);
  cursor: pointer;
  box-shadow: var(--shadow-xl);
  transition: transform .35s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow .35s ease;
  z-index: 1000; display: grid; place-items: center;
  border: 3px solid rgba(255,255,255,0.3); backdrop-filter: blur(10px);
  overflow: hidden;
}
.chat-button::before { content: ''; position: absolute; inset: 0; background: var(--secondary-gradient); opacity: 0; transition: opacity .3s ease; border-radius: 50%; }
.chat-button:hover::before { opacity: 1; }
.chat-button:hover { transform: scale(1.12) translateY(-6px); box-shadow: 0 20px 60px rgba(102,126,234,0.4); }
.chat-button:active { transform: scale(0.96); }
.chat-button i { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* Chat Window */
.chat-window {
  position: fixed;
  right: clamp(8px, 2vw, 32px);
  bottom: calc(clamp(76px, 10vw, 120px) + env(safe-area-inset-bottom, 0px));
  inline-size: min(92vw, 420px);
  block-size: min(80dvh, 650px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: none; flex-direction: column; z-index: 999; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.6);
  animation: slideUpScale .5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-window.active { display: flex; }

@keyframes slideUpScale { from { opacity: 0; transform: translateY(40px) scale(0.92); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Header */
.chat-header {
  background: var(--primary-gradient);
  color: white; padding: var(--space-3);
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.chat-header::before { content: ''; position: absolute; inset: 0; background: var(--secondary-gradient); opacity: 0; transition: opacity .3s ease; }
.chat-header:hover::before { opacity: .1; }
.chat-header h3 { margin: 0; font-size: var(--step-1); font-weight: 600; display: inline-flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.header-logo { width: 28px; height: 28px; filter: brightness(0) invert(1); transition: transform .3s ease; }
.chat-header:hover .header-logo { transform: rotate(360deg); }
.close-btn {
  background: rgba(255,255,255,0.15); border: none; color: white;
  font-size: 20px; cursor: pointer; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 50%; transition: transform .3s ease, background .3s ease; backdrop-filter: blur(10px); position: relative; z-index: 1;
}
.close-btn:hover { background: rgba(255,255,255,0.25); transform: rotate(90deg) scale(1.06); }

.status-indicator {
  position: absolute; top: 18px; left: 18px; width: 14px; height: 14px;
  background: var(--success-color); border-radius: 50%; border: 3px solid white; animation: statusPulse 2s infinite; z-index: 2;
}
@keyframes statusPulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.7); } 70% { box-shadow: 0 0 0 12px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }

/* Messages */
.chat-messages {
  flex: 1; padding: clamp(16px, 3vw, 28px);
  overflow-y: auto; background: linear-gradient(to bottom, #fafbff 0%, #ffffff 100%);
  position: relative; scroll-behavior: smooth;
}

.message {
  margin-block-end: var(--space-2);
  padding: clamp(12px, 1.6vw, 18px) clamp(14px, 2vw, 24px);
  border-radius: var(--radius-lg);
  max-width: 85%; word-wrap: break-word; line-height: 1.6; font-weight: 400; position: relative;
  animation: messageSlideIn .35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  font-size: var(--step--1);
}
@keyframes messageSlideIn { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.user-message { background: var(--primary-gradient); color: white; margin-left: auto; border-bottom-right-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; }
.user-message::before { content: ''; position: absolute; inset: 0; background: var(--secondary-gradient); opacity: 0; transition: opacity .3s ease; }
.user-message:hover::before { opacity: .1; }
.user-message * { position: relative; z-index: 1; }

.bot-message {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  color: var(--text-primary); border-bottom-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); border-left: 4px solid transparent; /* improved for contrast modes */
  border-image: var(--primary-gradient) 1;
}

/* Phone Number Links */
.bot-message a[href^="tel:"] {
  display: inline-flex; align-items: center; gap: 8px; background: var(--success-color); color: white;
  text-decoration: none; padding: 10px 14px; border-radius: var(--radius-md); font-weight: 600; margin: 8px 4px; transition: transform .2s ease, box-shadow .2s ease; box-shadow: var(--shadow-sm);
}
.bot-message a[href^="tel:"]:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.bot-message a[href^="tel:"]::before { content: '\f095'; font-family: 'Font Awesome 6 Free'; font-weight: 900; animation: ring 2s infinite; }
@keyframes ring { 0%,100% { transform: rotate(0deg); } 10%,30% { transform: rotate(-15deg); } 20% { transform: rotate(15deg); } }

/* Payment Links */
.bot-message a[href^="https://codesign.ge"] {
  display: inline-flex; align-items: center; gap: 10px; background: linear-gradient(135deg, #10b981, #059669);
  color: white; text-decoration: none; padding: 12px 18px; border-radius: var(--radius-md); font-weight: 700; margin: 12px 0; transition: transform .2s ease, box-shadow .2s ease; box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.bot-message a[href^="https://codesign.ge"]::before { content: '\f09d'; font-family: 'Font Awesome 6 Free'; font-weight: 900; }
.bot-message a[href^="https://codesign.ge"]:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(16,185,129,0.3); }

/* Upload Area */
.file-upload-area { background: var(--bg-secondary); border-top: 1px solid var(--border-color); padding: var(--space-2) var(--space-3); position: relative; }
.file-upload-container { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.file-input-wrapper { position: relative; overflow: hidden; display: inline-block; }
.file-input-wrapper input[type=file] { position: absolute; left: -9999px; }
.file-upload-btn { background: var(--primary-gradient); color: white; border: none; border-radius: var(--radius-md); padding: 12px 16px; cursor: pointer; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 10px; transition: transform .2s ease, box-shadow .2s ease; box-shadow: var(--shadow-sm); font-family: inherit; }
.file-upload-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* Composer */
.chat-input {
  display: grid; grid-template-columns: 1fr auto; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: white; border-top: 1px solid var(--border-color);
}
#message-input {
  border: 2px solid var(--border-color); border-radius: var(--radius-xl);
  padding: 14px 18px; outline: none; font-size: 16px; /* prevents iOS zoom */
  font-family: inherit; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
  background: var(--bg-secondary); resize: none; min-height: 24px; max-height: 40vh; line-height: 1.5;
}
#message-input:focus { border-color: #667eea; box-shadow: 0 0 0 4px rgba(102,126,234,0.12); background: white; }

#send-message {
  background: var(--primary-gradient); color: white; border: none; border-radius: 50%;
  width: clamp(46px, 6vw, 54px); height: clamp(46px, 6vw, 54px);
  cursor: pointer; font-size: clamp(18px, 2.5vw, 20px);
  display: grid; place-items: center; transition: transform .2s cubic-bezier(0.175,0.885,0.32,1.275), box-shadow .2s ease; box-shadow: var(--shadow-lg);
}
#send-message:hover { transform: scale(1.06) translateY(-1px); box-shadow: 0 12px 30px rgba(102,126,234,0.35); }
#send-message:active { transform: scale(0.95); }

/* Typing indicator */
.typing-indicator { display: flex; align-items: center; margin-bottom: var(--space-2); animation: messageSlideIn .35s ease-out; }
.typing-dots { background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); border-radius: var(--radius-lg); padding: 14px 18px; border-bottom-left-radius: var(--radius-sm); box-shadow: var(--shadow-md); border-left: 4px solid transparent; border-image: var(--primary-gradient) 1; display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text-secondary); }
.typing-dots::before { content: '⚡'; font-size: 18px; animation: bounce 1s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.typing-dots span { display: inline-block; width: 8px; height: 8px; background: var(--primary-gradient); border-radius: 50%; animation: typingPulse 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; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }
@keyframes typingPulse { 0%,80%,100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1.2); opacity: 1; } }

/* Scrollbars */
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: linear-gradient(135deg, #cbd5e0, #a0aec0); border-radius: 10px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: linear-gradient(135deg, #a0aec0, #718096); }

/* File preview */
.file-preview { background: var(--bg-primary); border: 2px dashed var(--border-color); border-radius: var(--radius-md); padding: 12px; text-align: center; margin-bottom: 10px; display: none; transition: border-color .2s ease, background .2s ease; }
.file-preview.active { display: block; border-color: #667eea; background: #f0f4ff; }
.file-item { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 10px; background: white; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: transform .15s ease, box-shadow .15s ease; }
.file-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.file-remove-btn { background: var(--error-color); color: white; border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 14px; display: grid; place-items: center; margin-left: auto; transition: transform .15s ease, background .15s ease; }
.file-remove-btn:hover { background: #dc2626; transform: scale(1.06); }

/* === Mobile-first tweaks === */
@media (max-width: 768px) {
  .chat-window { inline-size: calc(100vw - 12px); block-size: min(86dvh, 720px); right: 6px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
  .chat-button { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .container { padding: var(--space-3); }
  .container h1 { font-size: var(--step-2); }
  .message { max-width: 92%; }
  .chat-messages { padding: var(--space-2); }
  .chat-input { padding: var(--space-2); gap: 12px; }
}

/* Extra-small phones */
@media (max-width: 380px) {
  .chat-header { padding: var(--space-2); }
  .chat-header h3 { font-size: var(--step-0); }
  .close-btn { width: 32px; height: 32px; }
  #send-message { width: 44px; height: 44px; }
  .file-upload-area { padding: var(--space-2); }
  .file-upload-btn { padding: 10px 14px; font-size: 13px; }
}

/* Landscape phones: keep the window shorter to avoid keyboard overlap */
@media (max-height: 520px) and (orientation: landscape) {
  .chat-window { block-size: calc(100dvh - 110px); }
}

/* Large screens: float the window higher and allow a wider container */
@media (min-width: 1280px) {
  .container { max-width: min(920px, 72vw); }
  .chat-window { inline-size: min(30vw, 480px); bottom: 120px; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .chat-window { background: rgba(17,24,39,0.95); border-color: rgba(75,85,99,0.3); }
  .chat-messages { background: linear-gradient(to bottom, #111827 0%, #1f2937 100%); }
  .bot-message { background: linear-gradient(135deg, #374151 0%, #4b5563 100%); color: #f9fafb; border-left-color: transparent; }
  #message-input { background: #374151; border-color: #4b5563; color: #f9fafb; }
  #message-input:focus { background: #1f2937; border-color: #667eea; }
  .file-upload-area { background: #1f2937; border-color: #374151; }
  .chat-input { background: #111827; border-color: #374151; }
}

/* High contrast users */
@media (prefers-contrast: more) {
  .bot-message, .typing-dots { border-left-width: 4px; border-left-style: solid; border-left-color: #4f46e5; }
  .chat-button, #send-message { box-shadow: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Focus visible for keyboard nav */
.chat-button:focus-visible,
.close-btn:focus-visible,
#send-message:focus-visible,
.file-upload-btn:focus-visible { outline: 3px solid rgba(102,126,234,0.5); outline-offset: 2px; }
#message-input:focus-visible { outline: none; }

/* Optional: container queries (progressive enhancement) */
@supports (container-type: inline-size) {
  .chat-window { container-type: inline-size; container-name: chat; }
  @container chat (max-width: 340px) {
    .chat-header h3 { font-size: var(--step--1); }
    #send-message { width: 42px; height: 42px; }
  }
}

/* ...existing code... */
.close-btn {
  background: rgba(255,255,255,0.15); border: none; color: white;
  font-size: 20px; cursor: pointer; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 50%; transition: transform .3s ease, background .3s ease; backdrop-filter: blur(10px); position: relative; z-index: 1;
}
.close-btn:hover { background: rgba(255,255,255,0.25); transform: rotate(90deg) scale(1.06); }

.refresh-btn {
  background: rgba(255,255,255,0.15); border: none; color: white;
  font-size: 18px; cursor: pointer; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 50%; transition: transform .3s ease, background .3s ease; backdrop-filter: blur(10px); position: relative; z-index: 1;
}
.refresh-btn:hover { background: rgba(255,255,255,0.25); transform: rotate(-360deg) scale(1.06); }
/* ...existing code... */