/* ============================================================
   Avangard Fiber Tech — Floating Widget Styles
   widget.css
   ============================================================ */

/* ----------------------------------------------------------
   Root positioning
   ---------------------------------------------------------- */
#avw-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

[dir="rtl"] #avw-root {
  right: auto;
  left: 24px;
  align-items: flex-start;
}

/* ----------------------------------------------------------
   Button stack
   ---------------------------------------------------------- */
.avw-btn-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* ----------------------------------------------------------
   FABs — 52px circles
   ---------------------------------------------------------- */
.avw-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.avw-fab:hover {
  transform: translateY(-2px);
}

.avw-fab-contacts:hover {
  transform: none;
}

.avw-fab-chat {
  background: var(--color-orange);
  color: #fff;
  box-shadow: 0 4px 16px rgba(232, 82, 10, 0.45);
}

.avw-fab-contacts {
  background: var(--color-black);
  color: #fff;
  border: 2px solid #333;
}

[data-theme="dark"] .avw-fab-contacts {
  background: #1c1c1c;
  border-color: #3a3a3a;
}

/* SVG icon classes inside FABs (sizing handled by inline SVG attributes) */
.avw-icon-chat,
.avw-icon-close,
.avw-icon-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ----------------------------------------------------------
   Contacts row — pill expands to the left of the button
   ---------------------------------------------------------- */
.avw-contacts-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ----------------------------------------------------------
   Contact pill
   ---------------------------------------------------------- */
.avw-contact-pill {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 40px;
  padding: 10px 14px;
  box-shadow: var(--shadow-hover);
  animation: avw-pill-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#avw-contact-pill[hidden] {
  display: none;
}

@keyframes avw-pill-in {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

[dir="rtl"] .avw-contacts-row {
  flex-direction: row-reverse;
}

[dir="rtl"] .avw-contact-pill {
  animation: avw-pill-in-rtl 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes avw-pill-in-rtl {
  from {
    opacity: 0;
    transform: translateX(-20px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Sub-icons */
.avw-sub-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.avw-sub-icon:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.avw-sub-whatsapp {
  background: #25D366;
}

.avw-sub-phone {
  background: #4CAF50;
}

.avw-sub-email {
  background: var(--color-orange);
}

.avw-sub-contact {
  background: #2196F3;
}

/* ----------------------------------------------------------
   Panel
   ---------------------------------------------------------- */
.avw-panel {
  position: absolute;
  bottom: calc(52px + 10px + 52px + 16px);
  right: 0;
  width: 320px;
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: var(--shadow-hover);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 480px;
  animation: avw-panel-in 0.25s ease;
}

[dir="rtl"] .avw-panel {
  right: auto;
  left: 0;
}

#avw-panel[hidden] {
  display: none;
}

@keyframes avw-panel-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.avw-panel.avw-expanded {
  position: fixed;
  inset: 0;
  width: 100%;
  max-height: 100%;
  border-radius: 0;
  z-index: 10000;
}

/* ----------------------------------------------------------
   Panel header
   ---------------------------------------------------------- */
.avw-panel-header {
  background: var(--color-orange);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.avw-panel-title {
  font-weight: 700;
  font-size: var(--text-sm);
  font-family: var(--font-heading);
}

.avw-panel-actions {
  display: flex;
  gap: 4px;
}

.avw-icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.avw-icon-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ----------------------------------------------------------
   Tabs
   ---------------------------------------------------------- */
.avw-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.avw-tab {
  flex: 1;
  padding: 11px 8px;
  background: none;
  border: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font-sans);
}

.avw-tab--active {
  color: var(--color-orange);
  border-bottom-color: var(--color-orange);
}

/* ----------------------------------------------------------
   Pane
   ---------------------------------------------------------- */
.avw-pane {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.avw-pane[hidden] {
  display: none;
}

/* ----------------------------------------------------------
   Away / contact form
   ---------------------------------------------------------- */
.avw-form-header {
  background: var(--bg-secondary);
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-color);
}

.avw-form-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.avw-form-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin: 0;
}

#avw-contact-form {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.avw-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.avw-field label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
}

.avw-field input {
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 8px 10px;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.avw-field input:focus {
  border-color: var(--color-orange);
}

.avw-field input.avw-error {
  border-color: #e53935;
}

.avw-phone-row {
  display: flex;
  gap: 6px;
}

.avw-flag-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 8px;
  background: var(--bg-primary);
  cursor: pointer;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: border-color 0.15s;
}

.avw-flag-selector:focus-within {
  border-color: var(--color-orange);
}

.avw-flag-selector select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}

.avw-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  pointer-events: none;
}

.avw-phone-row input {
  flex: 1;
}

.avw-submit-btn {
  background: var(--color-orange);
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  padding: 11px 16px;
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.15s, transform 0.15s;
}

.avw-submit-btn:hover {
  background: var(--color-orange-hover);
  transform: translateY(-1px);
}

/* ----------------------------------------------------------
   Chat — topbar
   ---------------------------------------------------------- */
.avw-chat-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.avw-chat-topbar .avw-icon-btn {
  background: none;
  color: var(--text-secondary);
}

.avw-chat-topbar .avw-icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--color-orange);
}

.avw-chat-topbar-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

/* ----------------------------------------------------------
   Messages
   ---------------------------------------------------------- */
#avw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  max-height: 280px;
}

.avw-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 85%;
}

.avw-msg-bot {
  align-self: flex-start;
}

.avw-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avw-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.avw-msg-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-primary);
}

.avw-msg-bot .avw-msg-bubble {
  background: var(--bg-secondary);
  border-bottom-left-radius: 4px;
}

.avw-msg-user .avw-msg-bubble {
  background: var(--color-orange);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.avw-msg-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 3px;
  text-align: right;
}

.avw-msg-user .avw-msg-time {
  color: rgba(255, 255, 255, 0.7);
}

/* ----------------------------------------------------------
   Typing indicator
   ---------------------------------------------------------- */
.avw-typing .avw-msg-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}

.avw-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: avw-bounce 1.2s infinite;
}

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

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

@keyframes avw-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-5px);
  }
}

/* ----------------------------------------------------------
   Input bar
   ---------------------------------------------------------- */
.avw-input-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.avw-input-bar textarea {
  flex: 1;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 100px;
  transition: border-color 0.15s;
  line-height: 1.4;
}

.avw-input-bar textarea:focus {
  border-color: var(--color-orange);
}

.avw-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--color-orange);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}

.avw-send-btn:hover {
  background: var(--color-orange-hover);
  transform: translateY(-1px);
}

/* ----------------------------------------------------------
   FAQ
   ---------------------------------------------------------- */
.avw-faq-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
  flex-shrink: 0;
}

.avw-faq-list {
  /* accordion container */
}

.avw-faq-item {
  border-bottom: 1px solid var(--border-color);
}

.avw-faq-item:last-child {
  border-bottom: none;
}

.avw-faq-q {
  width: 100%;
  background: none;
  border: none;
  padding: 13px 16px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.15s;
}

[dir="rtl"] .avw-faq-q {
  text-align: right;
}

.avw-faq-q:hover,
.avw-faq-q[aria-expanded="true"] {
  color: var(--color-orange);
}

.avw-faq-chevron {
  flex-shrink: 0;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.avw-faq-q[aria-expanded="true"] .avw-faq-chevron {
  transform: rotate(180deg);
  color: var(--color-orange);
}

.avw-faq-a {
  padding: 0 16px;
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease, padding 0.28s ease;
}

.avw-faq-a.open {
  max-height: 300px;
  padding: 0 16px 13px;
}

/* ----------------------------------------------------------
   Mobile responsive
   ---------------------------------------------------------- */
@media (max-width: 480px) {
  #avw-root {
    bottom: 16px;
    right: 16px;
  }

  [dir="rtl"] #avw-root {
    right: auto;
    left: 16px;
  }

  .avw-panel {
    position: fixed;
    bottom: 80px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: 70vh;
    border-radius: 16px;
  }

  [dir="rtl"] .avw-panel {
    right: 8px;
    left: 8px;
  }
}

/* ----------------------------------------------------------
   Lang row & globe FAB
   ---------------------------------------------------------- */
.avw-lang-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.avw-fab-lang {
  background: var(--color-black);
  color: #fff;
  border: 2px solid #333;
}

[data-theme="dark"] .avw-fab-lang {
  background: #1c1c1c;
  border-color: #3a3a3a;
}

.avw-fab-lang:hover {
  border-color: var(--color-orange);
  color: var(--color-orange);
  transform: none;
}

/* Language pill */
.avw-lang-pill {
  display: flex;
  flex-direction: row;
  gap: 2px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 40px;
  padding: 6px 10px;
  box-shadow: var(--shadow-hover);
  animation: avw-pill-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#avw-lang-pill[hidden] {
  display: none;
}

.avw-lang-opt {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-radius: 999px;
  transition: background var(--transition), color var(--transition);
}

.avw-lang-opt:hover,
.avw-lang-opt[data-active="true"] {
  background: var(--color-orange-glow);
  color: var(--color-orange);
}

[dir="rtl"] .avw-lang-row {
  flex-direction: row-reverse;
}
