/*
  Cristina - Chat UI Flota Curieri Romania
  Tema dark glassmorphism asortata cu site-ul principal (verde-turcoaz HSL 165 70% 42%)
*/

:root {
  --background: hsl(220 20% 6%);
  --background-secondary: hsl(220 18% 9%);
  --background-elevated: hsl(220 16% 12%);
  --foreground: hsl(210 20% 98%);
  --foreground-muted: hsl(215 16% 65%);
  --card: hsl(220 16% 10%);
  --card-border: hsl(215 20% 18%);
  --primary: hsl(165 70% 42%);
  --primary-hover: hsl(165 70% 48%);
  --primary-foreground: hsl(220 20% 6%);
  --accent-turquoise: hsl(175 70% 45%);
  --border: hsl(215 20% 18%);
  --glass-bg: hsl(220 16% 12% / 0.6);
  --glass-border: hsl(215 20% 25% / 0.5);
  --gradient-primary: linear-gradient(135deg, hsl(165 70% 42%), hsl(175 70% 45%));
  --shadow-card: 0 4px 24px -4px hsl(220 20% 2% / 0.5), 0 0 0 1px hsl(215 20% 18% / 0.5);
  --shadow-glow: 0 0 60px -16px hsl(165 70% 42% / 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--background);
  color: var(--foreground);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Ambient glow background */
.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 15% 15%, hsl(165 70% 42% / 0.16) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, hsl(175 70% 45% / 0.12) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, hsl(220 20% 6%) 0%, hsl(220 20% 4%) 100%);
}

/* ===== CONSENT MODAL ===== */
.consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: hsl(220 20% 4% / 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.3s ease;
}

.consent-overlay[hidden] {
  display: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.consent-card {
  max-width: 480px;
  width: 100%;
  background: linear-gradient(180deg, hsl(220 18% 11%), hsl(220 18% 8%));
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow-card), 0 0 80px -10px hsl(165 70% 42% / 0.3);
  animation: slide-up-modal 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slide-up-modal {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.consent-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 0 24px hsl(165 70% 42% / 0.4);
}

.consent-card h2 {
  font-size: 19px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  color: var(--foreground);
}

.consent-intro {
  font-size: 13.5px;
  color: var(--foreground-muted);
  text-align: center;
  margin-bottom: 22px;
  line-height: 1.55;
}

.consent-intro strong {
  color: var(--foreground);
  font-weight: 600;
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: hsl(220 16% 14% / 0.6);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  margin-bottom: 16px;
}

.consent-check:hover {
  border-color: hsl(215 20% 28%);
}

.consent-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.consent-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid hsl(215 20% 35%);
  background: hsl(220 16% 12%);
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
  transition: all 0.2s ease;
}

.consent-check input[type="checkbox"]:checked ~ .consent-box {
  background: var(--gradient-primary);
  border-color: var(--primary);
}

.consent-check input[type="checkbox"]:checked ~ .consent-box::after {
  content: '';
  position: absolute;
  inset: 2px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.consent-check input[type="checkbox"]:focus-visible ~ .consent-box {
  box-shadow: 0 0 0 3px hsl(165 70% 42% / 0.3);
}

.consent-text {
  font-size: 13.5px;
  color: var(--foreground);
  line-height: 1.5;
}

.consent-text a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.consent-text a:hover {
  color: var(--primary-hover);
}

.consent-warning {
  padding: 12px 14px;
  background: hsl(38 92% 50% / 0.08);
  border: 1px solid hsl(38 92% 50% / 0.25);
  border-radius: 10px;
  font-size: 12.5px;
  color: hsl(38 92% 80%);
  margin-bottom: 20px;
  line-height: 1.5;
}

.consent-warning strong {
  color: hsl(38 92% 90%);
  font-weight: 600;
}

.consent-btn {
  width: 100%;
  padding: 13px 20px;
  border-radius: 12px;
  background: var(--gradient-primary);
  color: var(--primary-foreground);
  border: none;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 16px -6px hsl(165 70% 42% / 0.6);
}

.consent-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -6px hsl(165 70% 42% / 0.8);
}

.consent-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.consent-foot {
  font-size: 12px;
  color: var(--foreground-muted);
  text-align: center;
  margin-top: 14px;
  line-height: 1.5;
}

.consent-foot a {
  color: hsl(142 71% 70%);
  text-decoration: none;
}

.consent-foot a:hover {
  text-decoration: underline;
}

/* ===== TOPBAR ===== */
.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: hsl(220 18% 8% / 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--foreground);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: 0 0 12px hsl(165 70% 42% / 0.6);
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.topbar-links a {
  color: var(--foreground-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.topbar-links a:hover {
  color: var(--foreground);
}

.topbar-whatsapp {
  padding: 7px 14px;
  border-radius: 8px;
  background: hsl(142 71% 45% / 0.15);
  border: 1px solid hsl(142 71% 45% / 0.35);
  color: hsl(142 71% 70%) !important;
}

.topbar-whatsapp:hover {
  background: hsl(142 71% 45% / 0.25);
  color: hsl(142 71% 80%) !important;
}

/* ===== PAGE LAYOUT ===== */
.page {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 28px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ===== CHAT SHELL ===== */
.chat-shell {
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  min-height: 600px;
}

.chat-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: linear-gradient(135deg, hsl(165 70% 42% / 0.08), hsl(175 70% 45% / 0.06));
  border-bottom: 1px solid var(--glass-border);
}

.avatar-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.avatar {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--gradient-primary);
  overflow: hidden;
  box-shadow:
    0 0 0 2px hsl(165 70% 42% / 0.4),
    0 0 24px hsl(165 70% 42% / 0.45);
}

.avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
  display: block;
  z-index: 2;
}

.avatar-initial {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  color: var(--primary-foreground);
  background: var(--gradient-primary);
  z-index: 1;
}

.avatar-online {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: hsl(142 71% 50%);
  border: 2.5px solid hsl(220 18% 11%);
  box-shadow: 0 0 8px hsl(142 71% 50% / 0.7);
  animation: pulse-online 2.5s ease-in-out infinite;
  z-index: 10;
  pointer-events: none;
}

@keyframes pulse-online {
  0%, 100% { box-shadow: 0 0 8px hsl(142 71% 50% / 0.6); }
  50% { box-shadow: 0 0 14px hsl(142 71% 50% / 0.9); }
}

.hero-meta h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.hero-meta p {
  font-size: 13px;
  color: var(--foreground-muted);
  margin-top: 2px;
}

/* ===== CHAT WINDOW ===== */
.chat-window {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  min-height: 360px;
  max-height: calc(100vh - 380px);
}

.chat-window::-webkit-scrollbar {
  width: 8px;
}
.chat-window::-webkit-scrollbar-track {
  background: transparent;
}
.chat-window::-webkit-scrollbar-thumb {
  background: hsl(215 20% 25%);
  border-radius: 4px;
}
.chat-window::-webkit-scrollbar-thumb:hover {
  background: hsl(215 20% 35%);
}

.message {
  display: flex;
  max-width: 100%;
  animation: slide-up 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  word-wrap: break-word;
}

.message.bot .bubble {
  background: hsl(220 16% 14% / 0.7);
  border: 1px solid hsl(215 20% 22% / 0.6);
  color: var(--foreground);
  border-bottom-left-radius: 4px;
}

.message.user .bubble {
  background: var(--gradient-primary);
  color: var(--primary-foreground);
  font-weight: 500;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px -6px hsl(165 70% 42% / 0.6);
}

.bubble p + p {
  margin-top: 8px;
}

.bubble a {
  color: var(--accent-turquoise);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message.user .bubble a {
  color: var(--primary-foreground);
  text-decoration: underline;
}

.bubble ul, .bubble ol {
  margin: 6px 0 0 18px;
}

.bubble li + li {
  margin-top: 4px;
}

.bubble strong {
  font-weight: 700;
}

/* Typing indicator */
.message.typing .bubble {
  background: hsl(220 16% 14% / 0.7);
  border: 1px solid hsl(215 20% 22% / 0.6);
  padding: 14px 18px;
}

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

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: typing 1.4s ease-in-out infinite;
}

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

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* System notices (errors, limits) */
.message.notice .bubble {
  background: hsl(38 92% 50% / 0.1);
  border: 1px solid hsl(38 92% 50% / 0.35);
  color: hsl(38 92% 75%);
}

/* ===== QUICK REPLIES ===== */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px 16px;
}

.quick-replies.hidden {
  display: none;
}

.quick {
  padding: 8px 14px;
  background: hsl(220 16% 14% / 0.6);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--foreground-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick:hover {
  background: hsl(165 70% 42% / 0.15);
  border-color: hsl(165 70% 42% / 0.5);
  color: var(--foreground);
}

/* ===== CHAT FORM ===== */
.chat-form {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--glass-border);
  background: hsl(220 18% 8% / 0.4);
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: hsl(220 16% 12% / 0.8);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 4px 4px 4px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px hsl(165 70% 42% / 0.15);
}

textarea#chatInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--foreground);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  padding: 10px 0;
  resize: none;
  max-height: 140px;
  overflow-y: auto;
}

textarea#chatInput::placeholder {
  color: var(--foreground-muted);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--gradient-primary);
  color: var(--primary-foreground);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

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

.send-btn:active {
  transform: scale(0.97);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.hint {
  font-size: 11.5px;
  color: var(--foreground-muted);
  margin-top: 10px;
  text-align: center;
  opacity: 0.7;
}

/* ===== SIDE CARD ===== */
.side-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow-card);
  height: fit-content;
  position: sticky;
  top: 28px;
}

.side-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-btn {
  padding: 11px 16px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.side-btn.primary {
  background: var(--gradient-primary);
  color: var(--primary-foreground);
  box-shadow: 0 4px 16px -6px hsl(165 70% 42% / 0.6);
}

.side-btn.primary:hover {
  transform: translateY(-1px);
}

.side-btn.secondary {
  background: hsl(142 71% 45% / 0.12);
  color: hsl(142 71% 75%);
  border: 1px solid hsl(142 71% 45% / 0.35);
}

.side-btn.secondary:hover {
  background: hsl(142 71% 45% / 0.2);
}

/* ===== FOOTER ===== */
.footer {
  position: relative;
  z-index: 1;
  padding: 20px 28px;
  text-align: center;
  font-size: 12.5px;
  color: var(--foreground-muted);
  border-top: 1px solid var(--border);
  background: hsl(220 18% 7% / 0.5);
}

.footer a {
  color: var(--foreground-muted);
  text-decoration: none;
  margin: 0 4px;
}

.footer a:hover {
  color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .page {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 14px;
  }
  .side-card {
    position: static;
    order: 2;
  }
  .topbar {
    padding: 12px 16px;
  }
  .topbar-links {
    gap: 14px;
  }
  .topbar-links a {
    font-size: 13px;
  }
  .chat-window {
    max-height: calc(100vh - 280px);
    padding: 16px;
  }
  .chat-hero {
    padding: 14px 16px;
  }
  .chat-form {
    padding: 12px 16px 16px;
  }
  .quick-replies {
    padding: 0 16px 12px;
  }
  .bubble {
    max-width: 88%;
  }
}

@media (max-width: 560px) {
  /* Topbar */
  .topbar {
    padding: 11px 14px;
  }
  .brand-text {
    font-size: 13.5px;
  }
  .topbar-links {
    gap: 10px;
  }
  .topbar-links a {
    font-size: 12.5px;
  }

  /* Page - mai compact */
  .page {
    padding: 10px;
    gap: 10px;
  }

  /* Chat shell - rotunjire mai mica + spacing strans */
  .chat-shell {
    border-radius: 18px;
    min-height: 520px;
  }
  .chat-hero {
    padding: 12px 14px;
    gap: 12px;
  }
  .avatar-wrap {
    width: 48px;
    height: 48px;
  }
  .avatar-online {
    width: 12px;
    height: 12px;
    border-width: 2px;
  }
  .hero-meta h1 {
    font-size: 16px;
  }
  .hero-meta p {
    font-size: 12px;
  }

  /* Chat window */
  .chat-window {
    padding: 14px;
    gap: 12px;
    max-height: calc(100vh - 260px);
  }
  .bubble {
    max-width: 90%;
    font-size: 14px;
    padding: 11px 14px;
  }

  /* Quick replies - touch target marit */
  .quick-replies {
    padding: 0 14px 10px;
    gap: 6px;
  }
  .quick {
    font-size: 12.5px;
    padding: 9px 13px;
  }

  /* Form - touch friendly */
  .chat-form {
    padding: 10px 14px 14px;
  }
  .input-wrap {
    padding: 3px 3px 3px 12px;
    border-radius: 12px;
  }
  textarea#chatInput {
    font-size: 16px; /* 16px previne zoom-in pe iOS la focus */
    padding: 9px 0;
  }
  .send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }
  .hint {
    font-size: 11px;
  }

  /* Side card mai mic */
  .side-card {
    padding: 14px;
    border-radius: 18px;
  }
  .side-btn {
    padding: 12px 14px;
    font-size: 14px;
  }

  /* Footer */
  .footer {
    padding: 14px 14px 18px;
    font-size: 11.5px;
  }
  .footer-links {
    line-height: 1.8;
  }

  /* Modal pe mobil */
  .consent-overlay {
    padding: 14px;
  }
  .consent-card {
    padding: 24px 20px 20px;
    border-radius: 18px;
  }
  .consent-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 14px;
  }
  .consent-card h2 {
    font-size: 17px;
  }
  .consent-intro {
    font-size: 13px;
    margin-bottom: 16px;
  }
  .consent-check {
    padding: 12px 14px;
  }
  .consent-text {
    font-size: 13px;
  }
  .consent-warning {
    font-size: 12px;
    padding: 10px 12px;
  }
  .consent-btn {
    padding: 14px 18px;
    font-size: 14.5px;
  }
  .consent-foot {
    font-size: 11.5px;
  }
}

/* Pentru ecrane foarte mici (sub 380px) */
@media (max-width: 380px) {
  .brand-text {
    display: none;
  }
  .topbar-links a:nth-child(2),
  .topbar-links a:nth-child(3) {
    display: none;
  }
  .topbar-links a:first-child {
    padding: 6px 12px;
    background: var(--gradient-primary);
    color: var(--primary-foreground);
    border-radius: 8px;
    font-weight: 600;
  }
}
