/* SiloKala Live Chat Widget — enterprise frontend styles */

#sk-chat-widget-container {
  --sk-chat-navy: #1b3a6b;
  --sk-chat-navy-deep: #15315c;
  --sk-chat-accent: #f5a623;
  --sk-chat-danger: #d63638;
  --sk-chat-surface: #ffffff;
  --sk-chat-muted: #f5f7fa;
  --sk-chat-border: #e2e8f0;
  --sk-chat-text: #2d3748;
  --sk-chat-text-soft: #4a5568;
  --sk-chat-radius: 16px;
  --sk-chat-fab-size: 56px;
  --sk-chat-nav-clearance: 0px;

  position: fixed !important;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  right: 24px !important;
  left: auto !important;
  top: auto !important;
  z-index: 2147483646 !important;
  font-family: var(--font-base, "IranYekan", Tahoma, Arial, sans-serif);
  direction: rtl !important;
  text-align: right;
  box-sizing: border-box;
  pointer-events: none !important;
}

#sk-chat-widget-container * {
  box-sizing: border-box;
}

/* ── Floating launcher ─────────────────────────────────────── */

.sk-chat-trigger {
  position: relative !important;
  background: var(--sk-chat-navy);
  color: #ffffff;
  border-radius: 999px;
  padding: 12px 20px 12px 16px;
  min-height: 48px;
  box-shadow:
    0 4px 14px rgba(27, 58, 107, 0.28),
    0 1px 3px rgba(27, 58, 107, 0.12);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.3;
  transition:
    transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    background-color 0.2s,
    box-shadow 0.2s;
  pointer-events: auto !important;
  -webkit-tap-highlight-color: transparent;
}

.sk-chat-trigger:hover {
  background: var(--sk-chat-navy-deep);
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px rgba(27, 58, 107, 0.32),
    0 2px 6px rgba(27, 58, 107, 0.14);
}

.sk-chat-trigger:focus-visible {
  outline: 3px solid rgba(245, 166, 35, 0.55);
  outline-offset: 2px;
}

.sk-chat-trigger:active {
  transform: translateY(0) scale(0.98);
}

.sk-chat-trigger-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: #ffffff;
}

.sk-chat-trigger-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.sk-chat-trigger-status {
  position: absolute;
  bottom: -1px;
  left: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--sk-chat-navy);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.sk-chat-trigger.is-offline .sk-chat-trigger-status {
  background: #94a3b8;
}

.sk-chat-trigger-label {
  color: #ffffff;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sk-chat-trigger-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--sk-chat-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  line-height: 1;
}

/* ── Chat panel ────────────────────────────────────────────── */

.sk-chat-box {
  position: absolute !important;
  bottom: calc(100% + 12px) !important;
  right: 0 !important;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--sk-chat-surface);
  border-radius: var(--sk-chat-radius);
  box-shadow:
    0 16px 40px rgba(15, 23, 42, 0.18),
    0 4px 12px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--sk-chat-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(12px);
  opacity: 0;
  visibility: hidden !important;
  pointer-events: none !important;
  transition:
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s,
    visibility 0.25s;
  transform-origin: bottom right;
}

.sk-chat-box.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible !important;
  pointer-events: auto !important;
}

.sk-chat-header {
  background: linear-gradient(135deg, var(--sk-chat-navy) 0%, #244a82 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid var(--sk-chat-accent);
  flex-shrink: 0;
}

.sk-chat-header-title {
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sk-chat-header-title-icon {
  display: flex;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #ffffff;
}

.sk-chat-header-title-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.sk-chat-header-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sk-chat-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.sk-chat-header-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #ffffff;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.15s, background 0.15s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-family: inherit;
  line-height: 1;
  padding: 0;
}

.sk-chat-header-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.18);
}

.sk-chat-header-btn:focus-visible {
  outline: 2px solid var(--sk-chat-accent);
  outline-offset: 1px;
}

.sk-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--sk-chat-muted);
  position: relative;
  min-height: 0;
}

.sk-chat-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.sk-chat-screen.active {
  opacity: 1;
  pointer-events: auto;
}

#sk-chat-preform-screen {
  padding: 20px;
  overflow-y: auto;
  gap: 12px;
  background: #ffffff;
}

.sk-chat-preform-intro {
  margin: 0 0 4px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--sk-chat-text-soft);
}

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

.sk-chat-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--sk-chat-text-soft);
}

.sk-chat-field input[type="text"],
.sk-chat-field input[type="email"],
.sk-chat-field input[type="tel"],
.sk-chat-field input[type="number"],
.sk-chat-field select,
.sk-chat-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #cbd5e0;
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #ffffff;
  color: var(--sk-chat-text);
}

.sk-chat-field input:focus,
.sk-chat-field select:focus,
.sk-chat-field textarea:focus {
  outline: none;
  border-color: var(--sk-chat-navy);
  box-shadow: 0 0 0 3px rgba(27, 58, 107, 0.12);
}

.sk-chat-submit-btn {
  background: var(--sk-chat-navy);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sk-chat-submit-btn:hover {
  background: var(--sk-chat-navy-deep);
}

.sk-chat-submit-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.sk-chat-offline-notice {
  background: #fffaf0;
  border: 1px solid #feebc8;
  color: #c05621;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.7;
  text-align: justify;
}

.sk-chat-goodbye-banner,
.sk-chat-error-banner {
  padding: 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 4px;
  text-align: justify;
  font-weight: 700;
}

.sk-chat-goodbye-banner {
  background: #e6fffa;
  border: 1px solid #b2f5ea;
  color: #234e52;
}

.sk-chat-error-banner {
  background: #fff5f5;
  border: 1px solid #feb2b2;
  color: #c53030;
}

#sk-chat-waiting-screen {
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  gap: 16px;
  background: #ffffff;
}

.sk-chat-spinner {
  width: 40px;
  height: 40px;
  border: 3.5px solid rgba(27, 58, 107, 0.12);
  border-top-color: var(--sk-chat-navy);
  border-radius: 50%;
  animation: sk-spin 0.8s linear infinite;
}

.sk-chat-waiting-text {
  font-size: 12.5px;
  color: var(--sk-chat-text-soft);
  line-height: 1.7;
}

#sk-chat-conversation-screen {
  min-height: 0;
}

.sk-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.sk-chat-msg-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  word-break: break-word;
}

.sk-chat-msg-bubble-customer {
  align-self: flex-start;
  background: var(--sk-chat-navy);
  color: #ffffff;
  border-top-right-radius: 4px;
}

.sk-chat-msg-bubble-agent {
  align-self: flex-end;
  background: #ffffff;
  color: var(--sk-chat-text);
  border-top-left-radius: 4px;
  border: 1px solid var(--sk-chat-border);
}

.sk-chat-msg-bubble-system {
  align-self: center;
  background: #e2e8f0;
  color: var(--sk-chat-text-soft);
  font-size: 10.5px;
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: none;
  max-width: 92%;
  text-align: center;
}

.sk-chat-msg-time {
  display: block;
  font-size: 8.5px;
  margin-top: 4px;
  text-align: left;
  opacity: 0.7;
}

.sk-chat-input-bar {
  background: #ffffff;
  border-top: 1px solid var(--sk-chat-border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.sk-chat-inputs {
  display: flex;
  gap: 8px;
}

.sk-chat-inputs textarea {
  flex: 1;
  height: 40px;
  border: 1.5px solid #cbd5e0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  resize: none;
  font-family: inherit;
}

.sk-chat-inputs textarea:focus {
  outline: none;
  border-color: var(--sk-chat-navy);
  box-shadow: 0 0 0 3px rgba(27, 58, 107, 0.1);
}

.sk-chat-inputs button {
  background: var(--sk-chat-navy);
  color: #fff;
  border: none;
  padding: 0 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.sk-chat-inputs button:hover:not(:disabled) {
  background: var(--sk-chat-navy-deep);
}

.sk-chat-inputs button:disabled,
.sk-chat-inputs textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sk-chat-attachment-row {
  font-size: 10px;
  color: #718096;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sk-chat-attachment-row input[type="file"] {
  font-size: 9.5px;
  max-width: 100%;
}

/* Confirm overlay */
.sk-chat-confirm-modal {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  z-index: 20;
  justify-content: center;
  align-items: center;
  border-radius: inherit;
  padding: 16px;
}

.sk-chat-confirm-modal.is-visible {
  display: flex;
}

.sk-chat-confirm-card {
  background: #fff;
  width: 100%;
  max-width: 300px;
  padding: 20px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  direction: rtl;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sk-chat-confirm-card p {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--sk-chat-text);
  line-height: 1.7;
}

.sk-chat-confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.sk-chat-confirm-actions button {
  border: none;
  padding: 11px 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  flex: 1;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}

.sk-btn-confirm-yes {
  background: var(--sk-chat-accent);
  color: #fff;
}

.sk-btn-confirm-yes:hover {
  background: #e0951a;
}

.sk-btn-confirm-no {
  background: var(--sk-chat-navy);
  color: #fff;
}

.sk-btn-confirm-no:hover {
  background: var(--sk-chat-navy-deep);
}

@keyframes sk-spin {
  to {
    transform: rotate(-360deg);
  }
}

.sk-chat-msg-bubble.sk-msg-sending,
.sk-chat-bubble.sk-msg-sending {
  opacity: 0.6 !important;
}

.sk-chat-msg-bubble.sk-msg-sending .sk-chat-msg-time::before,
.sk-chat-bubble.sk-msg-sending .sk-chat-bubble-time::before {
  content: "⏱ در حال ارسال... ";
  font-weight: bold;
}

/* ── Mobile: logo-only FAB above bottom navigation ─────────── */

@media (max-width: 768px) {
  #sk-chat-widget-container {
    /* Clear theme bottom nav (~64px) + safe area */
    --sk-chat-nav-clearance: 72px;
    bottom: calc(var(--sk-chat-nav-clearance) + env(safe-area-inset-bottom, 0px)) !important;
    right: 14px !important;
    left: auto !important;
  }

  .sk-chat-trigger {
    width: var(--sk-chat-fab-size);
    height: var(--sk-chat-fab-size);
    min-height: var(--sk-chat-fab-size);
    padding: 0;
    border-radius: 50%;
    gap: 0;
    box-shadow:
      0 6px 18px rgba(27, 58, 107, 0.34),
      0 2px 6px rgba(27, 58, 107, 0.16);
  }

  .sk-chat-trigger:hover {
    transform: translateY(-1px) scale(1.03);
  }

  /* Logo / icon only — no teaser text on mobile */
  .sk-chat-trigger-label {
    display: none !important;
  }

  .sk-chat-trigger-icon {
    width: 28px;
    height: 28px;
  }

  .sk-chat-trigger-icon svg {
    width: 26px;
    height: 26px;
  }

  .sk-chat-trigger-badge {
    top: 2px;
    left: 2px;
  }

  .sk-chat-box {
    position: fixed !important;
    right: 10px !important;
    left: 10px !important;
    width: auto !important;
    bottom: calc(var(--sk-chat-nav-clearance) + env(safe-area-inset-bottom, 0px) + 68px) !important;
    height: min(72vh, calc(100dvh - var(--sk-chat-nav-clearance) - env(safe-area-inset-bottom, 0px) - 96px));
    max-height: min(72vh, calc(100dvh - var(--sk-chat-nav-clearance) - env(safe-area-inset-bottom, 0px) - 96px));
    border-radius: 14px;
    transform-origin: bottom right;
  }
}

@media (max-width: 380px) {
  #sk-chat-widget-container {
    --sk-chat-nav-clearance: 68px;
    right: 12px !important;
  }

  .sk-chat-trigger {
    --sk-chat-fab-size: 52px;
    width: var(--sk-chat-fab-size);
    height: var(--sk-chat-fab-size);
    min-height: var(--sk-chat-fab-size);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sk-chat-trigger,
  .sk-chat-box,
  .sk-chat-screen,
  .sk-chat-spinner {
    transition: none !important;
    animation: none !important;
  }
}
