/* ==========================================================================
   Subscribe Widget — Floating Combo Button
   Email subscribe + Browser push notification
   ========================================================================== */

/* --- Main FAB Button --- */
.sw-fab {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: sw-fab-pulse 3s ease-in-out infinite;
}

.sw-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.5);
}

.sw-fab.active {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: rotate(90deg);
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
  animation: none;
}

.sw-fab.active:hover {
  transform: rotate(90deg) scale(1.08);
}

@keyframes sw-fab-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4); }
  50% { box-shadow: 0 4px 28px rgba(37, 99, 235, 0.6); }
}

/* --- Badge (unread indicator) --- */
.sw-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
  line-height: 1;
}

/* --- Panel --- */
.sw-panel {
  position: fixed;
  bottom: 158px;
  right: 24px;
  z-index: 998;
  width: 340px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.sw-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Panel Header --- */
.sw-panel-header {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  padding: 20px;
  border-radius: 16px 16px 0 0;
  text-align: center;
}

.sw-panel-header h3 {
  margin: 0 0 4px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.sw-panel-header p {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

/* --- Panel Body --- */
.sw-panel-body {
  padding: 20px;
}

/* --- Section Labels --- */
.sw-section-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  margin-bottom: 8px;
}

/* --- Email Subscribe Form --- */
.sw-email-section {
  margin-bottom: 20px;
}

.sw-email-form {
  display: flex;
  gap: 8px;
}

.sw-email-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.sw-email-input:focus {
  border-color: #2563eb;
}

.sw-email-input::placeholder {
  color: #9ca3af;
}

.sw-email-btn {
  padding: 10px 16px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sw-email-btn:hover {
  background: #1d4ed8;
}

.sw-email-btn:active {
  transform: scale(0.96);
}

.sw-email-btn:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.sw-email-btn .sw-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: sw-spin 0.6s linear infinite;
}

.sw-email-btn.loading .sw-spinner {
  display: block;
}

.sw-email-btn.loading .sw-btn-text {
  display: none;
}

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

/* --- Message (success / error / info) --- */
.sw-message {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: none;
}

.sw-message.show {
  display: block;
  animation: sw-slide-in 0.3s ease;
}

.sw-message.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.sw-message.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.sw-message.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

@keyframes sw-slide-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Divider --- */
.sw-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.sw-divider::before,
.sw-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.sw-divider span {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Push Notification Button --- */
.sw-push-section {
  margin-bottom: 16px;
}

.sw-push-btn {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
}

.sw-push-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.sw-push-btn i {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sw-push-btn.enabled {
  border-color: #16a34a;
  color: #16a34a;
  background: #f0fdf4;
  cursor: default;
}

.sw-push-btn.enabled:hover {
  border-color: #16a34a;
  color: #16a34a;
  background: #f0fdf4;
}

.sw-push-btn.disabled {
  border-color: #fecaca;
  color: #dc2626;
  background: #fef2f2;
  cursor: default;
}

.sw-push-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.sw-push-btn .sw-push-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(37, 99, 235, 0.2);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: sw-spin 0.6s linear infinite;
}

.sw-push-btn.loading .sw-push-spinner {
  display: block;
}

/* --- Subscriber Count --- */
.sw-subscriber-count {
  text-align: center;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
  font-size: 12px;
  color: #9ca3af;
}

.sw-subscriber-count i {
  margin-right: 4px;
}

.sw-subscriber-count strong {
  color: #6b7280;
}

/* --- Close Button (inside panel header) --- */
.sw-panel-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s;
}

.sw-panel-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sw-panel-header {
  position: relative;
}

/* --- RTL Support --- */
[dir="rtl"] .sw-fab {
  right: auto;
  left: 24px;
}

[dir="rtl"] .sw-panel {
  right: auto;
  left: 24px;
}

/* --- Mobile Responsive --- */
@media (max-width: 576px) {
  .sw-fab {
    bottom: 80px;
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .sw-panel {
    bottom: 142px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 60vh;
    border-radius: 14px;
  }

  .sw-panel-header {
    padding: 16px;
    border-radius: 14px 14px 0 0;
  }

  .sw-panel-header h3 {
    font-size: 16px;
  }

  .sw-panel-body {
    padding: 16px;
  }

  [dir="rtl"] .sw-fab {
    right: auto;
    left: 16px;
  }

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

/* --- Dark mode hint (future use) --- */
@media (prefers-color-scheme: dark) {
  .sw-panel {
    background: #1f2937;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  }

  .sw-email-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }

  .sw-email-input::placeholder {
    color: #6b7280;
  }

  .sw-push-btn {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
  }

  .sw-divider::before,
  .sw-divider::after {
    background: #4b5563;
  }
}
