/* ==========================================================
   RB Contact Widget — assets/css/style.css
   Prefix: rb-cw-
   ========================================================== */

/* ──────────────────────────────────────────────────────────
   0-A. Theme Isolation (WoodMart & other aggressive themes)
   Use a scoping selector + !important to prevent theme CSS
   from collapsing, repositioning, or otherwise breaking the
   fixed-position widget elements.
────────────────────────────────────────────────────────── */
#rb-contact-widget-container {
    all: initial;   /* Hard reset: neutralise any inherited theme styles */
    font-family: inherit !important;
    direction: rtl !important;
    line-height: 1.6 !important;
    color: #313131 !important;
}

/* Re-apply box-sizing to all descendants */
#rb-contact-widget-container *,
#rb-contact-widget-container *::before,
#rb-contact-widget-container *::after {
    box-sizing: border-box !important;
}

/* ──────────────────────────────────────────────────────────
   0-B. Critical Fixed-Position overrides
   WoodMart and some page-builders use transforms on wrappers
   which creates a new stacking context and breaks
   position:fixed. We anchor directly to the viewport with
   !important to ensure the FAB and overlay always escape.
────────────────────────────────────────────────────────── */
#rb-cw-fab-open {
    position: fixed !important;
    z-index: 9998 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    outline: none !important;
    /* margin / padding injected via inline style or JS */
    padding: 0 !important;
    margin: 0 !important;
    /* transition preserved for animation */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

#rb-cw-fab-open:hover {
    transform: scale(1.07) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35) !important;
}

#rb-cw-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
}

#rb-cw-drawer-contact {
    position: fixed !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    z-index: 10000 !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    height: auto !important;
    max-height: 85vh !important;
}


/* ──────────────────────────────────────────────────────────
   1. FAB Button
   Note: background-color, width, height, border-radius are
   injected via inline styles from PHP settings.
   The pulse keyframe is also injected inline by PHP so its
   colour automatically matches the FAB background colour.
────────────────────────────────────────────────────────── */
.rb-cw-fab-btn {
  position: fixed;
  /* position / margin injected by JS via rbCwData */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  z-index: 9998;
  border: none;
  outline: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 0;
}

.rb-cw-fab-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* Pulse is applied only when the .rb-cw-pulse-active class is present */
.rb-cw-fab-contact.rb-cw-pulse-active {
  animation: rb-cw-pulse 2.5s infinite;
}

.rb-cw-fab-contact img {
  display: block;
  pointer-events: none;
}

/* ──────────────────────────────────────────────────────────
   2. Pulse keyframe placeholder
   The actual @keyframes rb-cw-pulse block with the correct
   colour is injected as an inline <style> by PHP (render).
   This empty rule prevents a "not defined" flash if CSS
   loads before the inline block.
────────────────────────────────────────────────────────── */
@keyframes rb-cw-pulse {
  0%   { box-shadow: 0 4px 15px rgba(0,0,0,.28), 0 0 0 0   rgba(56,189,248,.7); }
  70%  { box-shadow: 0 4px 15px rgba(0,0,0,.28), 0 0 0 18px rgba(56,189,248,0); }
  100% { box-shadow: 0 4px 15px rgba(0,0,0,.28), 0 0 0 0   rgba(56,189,248,0); }
}

/* ──────────────────────────────────────────────────────────
   3. Backdrop
────────────────────────────────────────────────────────── */
.rb-cw-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.rb-cw-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* ──────────────────────────────────────────────────────────
   4. Drawer / Modal
────────────────────────────────────────────────────────── */
.rb-cw-drawer {
  position: fixed;
  bottom: -100%;
  left: 0;
  width: 100%;
  max-width: 100vw;
  background-color: #ffffff;
  box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-sizing: border-box;
  height: auto;
  max-height: 85vh;
  border-radius: 25px 25px 0 0;
  padding: 0 20px 40px 20px;
}

.rb-cw-drawer.active {
  bottom: 0;
}

/* ──────────────────────────────────────────────────────────
   5. Drawer Handle
────────────────────────────────────────────────────────── */
.rb-cw-drawer-handle {
  width: 50px;
  height: 5px;
  background-color: #ddd;
  border-radius: 10px;
  margin: 10px auto 5px;
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
}

/* ──────────────────────────────────────────────────────────
   6. Drawer Header
────────────────────────────────────────────────────────── */
.rb-cw-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
  width: 100%;
}

.rb-cw-drawer-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #313131;
}

.rb-cw-drawer-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ──────────────────────────────────────────────────────────
   7. Live Status Badge
────────────────────────────────────────────────────────── */
.rb-cw-live-status {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #e6f6e6;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #c3e6c3;
  white-space: nowrap;
}

.rb-cw-live-dot {
  width: 8px;
  height: 8px;
  background-color: #28a745;
  border-radius: 50%;
  animation: rb-cw-live-pulse 1.5s infinite;
  flex-shrink: 0;
}

.rb-cw-live-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: #28a745;
}

@keyframes rb-cw-live-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(40, 167, 69, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
  }
}

/* ──────────────────────────────────────────────────────────
   8. Close Button
────────────────────────────────────────────────────────── */
.rb-cw-close-btn {
  background: #f5f5f5;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 1.5rem;
  transition: background 0.2s;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}

.rb-cw-close-btn:hover {
  background: #e0e0e0;
  color: #313131;
}

/* ──────────────────────────────────────────────────────────
   9. Drawer Content
────────────────────────────────────────────────────────── */
.rb-cw-drawer-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 20px;
}

/* ──────────────────────────────────────────────────────────
   10. Section Label
────────────────────────────────────────────────────────── */
.rb-cw-section-label {
  font-size: 0.85rem;
  color: #999;
  margin-top: 6px;
  margin-bottom: -5px;
  font-weight: 600;
  border-right: 3px solid #efae1c;
  padding-right: 8px;
}

/* ──────────────────────────────────────────────────────────
   11. Phone Button (full-width, above messengers)
────────────────────────────────────────────────────────── */
.rb-cw-phone-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  text-decoration: none;
  /* background-color injected via inline style from PHP */
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  direction: rtl;
  position: relative;
  overflow: hidden;
}

.rb-cw-phone-btn:hover {
  filter: brightness(0.96);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.rb-cw-phone-btn:active {
  transform: translateY(0);
  filter: brightness(0.92);
}

.rb-cw-phone-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.rb-cw-phone-text {
  font-size: 0.85rem;
  color: #777;
  flex-shrink: 0;
}

.rb-cw-phone-number {
  font-size: 1.05rem;
  font-weight: 800;
  color: #313131;
  letter-spacing: 0.5px;
  margin-right: auto;
}

/* ──────────────────────────────────────────────────────────
   12. Messenger Grid
────────────────────────────────────────────────────────── */
.rb-cw-messenger-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  width: 100%;
}

/* 3-column when exactly 3 items */
.rb-cw-messenger-grid:has(> :nth-child(3):last-child) {
  grid-template-columns: 1fr 1fr 1fr;
}

/* آخرین آیتم تمام عرض: وقتی تعداد زوج باشه و آخرین عضو ردیف تنها بمونه */
.rb-cw-messenger-grid.rb-cw-grid-last-full > a:last-child {
  grid-column: 1 / -1;
}

/* حالت یکپارچه: ۳ ستون */
.rb-cw-messenger-grid-unified {
  grid-template-columns: repeat(3, 1fr) !important;
}

.rb-cw-messenger-grid-unified.rb-cw-grid-last-full > a:last-child {
  grid-column: 1 / -1;
}

/* ──────────────────────────────────────────────────────────
   13. Action Box (Messenger Card)
────────────────────────────────────────────────────────── */
.rb-cw-action-box {
  padding: 15px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.rb-cw-action-box.rb-cw-vertical {
  flex-direction: column;
  text-align: center;
  padding: 20px 10px;
}

.rb-cw-action-box:hover {
  transform: translateY(-3px);
}

/* ── Per-messenger colours */
/* .box-telegram  { border: 1px solid rgba(50,  170, 223, 0.3); }
.box-telegram:hover  { background-color: #f2fbff; box-shadow: 0 8px 15px rgba(50,  170, 223, 0.2); }

.box-whatsapp  { border: 1px solid rgba(103, 193,  94, 0.3); }
.box-whatsapp:hover  { background-color: #f0fdf2; box-shadow: 0 8px 15px rgba(103, 193,  94, 0.2); }

.box-instagram { border: 1px solid rgba(193,  53, 132, 0.3); }
.box-instagram:hover { background-color: #fff0f8; box-shadow: 0 8px 15px rgba(193,  53, 132, 0.2); }

.box-eitaa     { border: 1px solid rgba(227, 118,   0, 0.3); }
.box-eitaa:hover     { background-color: #fff8f0; box-shadow: 0 8px 15px rgba(227, 118,   0, 0.2); }

.box-rubika    { border: 1px solid rgba(122,  69, 135, 0.3); }
.box-rubika:hover    { background-color: #fbf5fc; box-shadow: 0 8px 15px rgba(122,  69, 135, 0.2); }

.box-bale      { border: 1px solid rgba(  0, 122, 200, 0.3); }
.box-bale:hover      { background-color: #f0f8ff; box-shadow: 0 8px 15px rgba(  0, 122, 200, 0.2); } */

/* ── Text colour helpers */
/* .text-telegram  { color: #32aadf !important; }
.text-whatsapp  { color: #67c15e !important; }
.text-instagram { color: #c13584 !important; }
.text-eitaa     { color: #e37600 !important; }
.text-rubika    { color: #7a4587 !important; }
.text-bale      { color: #007ac8 !important; } */

/* ──────────────────────────────────────────────────────────
   14. App Logo Image
────────────────────────────────────────────────────────── */
.rb-cw-app-logo {
  width: 45px;
  height: 45px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────
   15. Action Text
────────────────────────────────────────────────────────── */
.rb-cw-action-text {
  display: flex;
  flex-direction: column;
}

.rb-cw-action-label {
  font-size: 0.8rem;
  color: #777;
  margin-bottom: 2px;
}

.rb-cw-action-value {
  font-size: 1rem;
  font-weight: 700;
  color: #313131;
}

/* ──────────────────────────────────────────────────────────
   16. Announcement Banner
────────────────────────────────────────────────────────── */
.rb-cw-announcement {
  width: 100%;
  background: #fffbea;
  border: 1px solid #f5e07a;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.9rem;
  color: #555;
  line-height: 1.7;
  margin-top: 5px;
  text-align: right;
}

/* ──────────────────────────────────────────────────────────
   17. Responsive
────────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .rb-cw-drawer {
    padding-left: 15px;
    padding-right: 15px;
  }
  .rb-cw-messenger-grid {
    gap: 10px;
  }
  .rb-cw-phone-btn {
    padding: 12px 14px;
  }
}