/* ==========================================================================
   Boghcheh - Instagram-Style Story Viewers & Insights Component
   Includes: Owner Story Footer, Viewers Stack, Reactions, Bottom Sheet Modal
   ========================================================================== */

/* 1. Story Owner Bottom Bar */
.story-owner-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.8) 70%, rgba(0, 0, 0, 0.6) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  direction: rtl;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.story-owner-insights-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.2s ease;
  user-select: none;
}

.story-owner-insights-trigger:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.story-owner-insights-trigger:active {
  transform: scale(0.97);
}

/* Overlapping Avatar Stack */
.story-viewers-stack {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
}

.story-stack-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #000;
  object-fit: cover;
  margin-left: -8px;
  background: #262626;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.story-stack-avatar:last-child {
  margin-left: 0;
}

.story-stack-avatar--initial {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  text-transform: uppercase;
}

.story-stack-empty-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #ffffff;
}

/* Views & Reactions Labels */
.story-views-text-group {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
}

.story-views-count-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.story-likes-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(255, 43, 84, 0.15);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 43, 84, 0.25);
}

.story-likes-heart-icon {
  color: #ff2b54;
  font-size: 12px;
  animation: heartPulse 2s infinite ease-in-out;
}

.story-insights-swipe-hint {
  font-size: 11px;
  opacity: 0.7;
  display: flex;
  align-items: center;
  margin-right: 2px;
  animation: bounceHint 1.8s infinite ease-in-out;
}

/* Owner Delete Story Button */
.story-owner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.story-delete-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ff4757;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.story-delete-btn:hover {
  background: rgba(255, 71, 87, 0.2);
  border-color: rgba(255, 71, 87, 0.4);
  transform: scale(1.08);
}

.story-delete-btn:active {
  transform: scale(0.95);
}

/* 2. Regular Viewer Reaction Heart Button */
.story-reaction-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(10px);
  position: relative;
  flex-shrink: 0;
}

.story-reaction-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.08);
}

.story-reaction-btn.is-active {
  color: #ff2b54;
  border-color: rgba(255, 43, 84, 0.4);
  background: rgba(255, 43, 84, 0.18);
  animation: heartBounce 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.story-reaction-btn.is-active i {
  font-weight: 900;
}

/* Floating Heart Particle */
.story-floating-heart {
  position: absolute;
  pointer-events: none;
  font-size: 26px;
  color: #ff2b54;
  animation: floatHeart 1s forwards cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 999;
}

@keyframes floatHeart {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.6) rotate(0deg);
  }
  50% {
    opacity: 0.9;
    transform: translateY(-50px) scale(1.3) rotate(-10deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-110px) scale(1.5) rotate(15deg);
  }
}

/* 3. Instagram Story Viewers & Insights Sheet / Modal (Image 2) */
.story-viewers-sheet {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  direction: rtl;
}

.story-viewers-sheet.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.story-viewers-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1;
  transition: opacity 0.3s ease;
}

.story-viewers-sheet-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-height: 86vh;
  height: 82vh;
  background: #121212;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.story-viewers-sheet.is-open .story-viewers-sheet-container {
  transform: translateY(0);
}

/* Top Header & Drag Handle */
.story-viewers-sheet-handle-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px 8px;
  cursor: grab;
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.story-viewers-sheet-pill {
  width: 42px;
  height: 4.5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.2s ease;
}

.story-viewers-sheet-handle-zone:hover .story-viewers-sheet-pill {
  background: rgba(255, 255, 255, 0.5);
}

.story-viewers-sheet-close {
  position: absolute;
  left: 16px;
  top: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.story-viewers-sheet-close:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.08);
}

/* Sheet Body */
.story-viewers-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
}

/* Story Preview Card (Thumbnail from Image 2) */
.story-preview-card-wrapper {
  display: flex;
  justify-content: center;
  padding: 4px 16px 14px;
}

.story-preview-card {
  position: relative;
  width: 96px;
  height: 164px;
  border-radius: 14px;
  overflow: hidden;
  background: #1f1f1f;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
}

.story-preview-card img,
.story-preview-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-preview-stats-overlay {
  position: absolute;
  bottom: 8px;
  left: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  direction: ltr;
}

.story-preview-stats-overlay .stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.story-preview-stats-overlay .stat-heart {
  color: #ff2b54;
}

/* Section Header (18 Viewers) */
.story-viewers-section-header {
  padding: 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.story-viewers-count-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.2px;
}

/* Viewers List Container */
.story-viewers-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 20px;
}

.story-viewers-list::-webkit-scrollbar {
  width: 5px;
}

.story-viewers-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* Single Viewer Item (Row matching Image 2) */
.story-viewer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  transition: background 0.15s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.story-viewer-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.story-viewer-item-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

/* 44px Circular Avatar */
.story-viewer-avatar-box {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background: #2c2c2c;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.story-viewer-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-viewer-avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  text-transform: uppercase;
}

/* User Text Metadata */
.story-viewer-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.story-viewer-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-viewer-time-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.55);
  direction: rtl;
}

.story-viewer-checkmarks {
  color: #888888;
  font-size: 11px;
}

/* Right Reaction Slot */
.story-viewer-reaction-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.story-viewer-heart-icon {
  color: #ff2b54;
  font-size: 20px;
  filter: drop-shadow(0 0 8px rgba(255, 43, 84, 0.4));
  animation: heartPop 0.3s ease-out;
}

/* Empty State */
.story-viewers-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
}

.story-viewers-empty-icon {
  font-size: 38px;
  color: rgba(255, 255, 255, 0.25);
  margin-bottom: 12px;
}

.story-viewers-empty-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.story-viewers-empty-desc {
  font-size: 12px;
  line-height: 1.6;
  max-width: 240px;
}

/* Skeleton Loading */
.story-viewer-skeleton {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.story-skeleton-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.story-skeleton-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  margin-right: 12px;
}

.story-skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.story-skeleton-line--short {
  width: 40%;
}

.story-skeleton-line--medium {
  width: 65%;
}

.story-shimmer {
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* 4. Delete Confirmation Modal */
.story-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 20px;
  direction: rtl;
  animation: fadeIn 0.2s ease-out;
}

.story-confirm-box {
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  max-width: 320px;
  width: 100%;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  animation: scaleUp 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.story-confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 71, 87, 0.15);
  color: #ff4757;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto 16px;
}

.story-confirm-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
}

.story-confirm-desc {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
  margin-bottom: 20px;
}

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

.story-confirm-btn {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.story-confirm-btn--delete {
  background: #ff4757;
  color: #ffffff;
}

.story-confirm-btn--delete:hover {
  background: #ff2e44;
  transform: translateY(-1px);
}

.story-confirm-btn--cancel {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.story-confirm-btn--cancel:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Animations */
@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes bounceHint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes heartBounce {
  0% { transform: scale(0.6); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes heartPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Desktop Media Query */
@media (min-width: 768px) {
  .story-viewers-sheet-container {
    max-width: 430px;
    margin: 0 auto;
    border-radius: 18px 18px 0 0;
  }
}

/* ==========================================================================
   Story Reply & Quick Reactions (Instagram Style)
   ========================================================================== */
.story-quick-reactions {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 12px;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.4) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 6;
  direction: ltr;
}

.story-quick-emoji {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.story-quick-emoji:hover {
  transform: scale(1.35);
  background: rgba(255, 255, 255, 0.12);
}

.story-quick-emoji:active {
  transform: scale(0.9);
}

/* Floating Emoji Reaction Animation */
.story-floating-emoji {
  position: fixed;
  font-size: 38px;
  line-height: 1;
  pointer-events: none;
  z-index: 999999;
  user-select: none;
  animation: storyEmojiFloat 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes storyEmojiFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.6) rotate(0deg);
  }
  50% {
    opacity: 0.95;
    transform: translateY(-90px) scale(1.4) rotate(-10deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-200px) scale(1.8) rotate(15deg);
  }
}

.story-reply-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.story-reply-input {
  width: 100%;
  height: 44px;
  padding: 0 46px 0 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  outline: none;
  font-size: 13.5px;
  transition: all 0.25s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-align: right;
  box-sizing: border-box;
}

.story-reply-input::placeholder {
  color: rgba(255, 255, 255, 0.65);
}

.story-reply-input:focus {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.story-reply-btn {
  position: absolute;
  left: 5px;
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  background: var(--primary, #8b5e3c);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6);
  flex-shrink: 0;
}

.story-reply-wrapper.has-text .story-reply-btn {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.story-reply-btn:hover {
  filter: brightness(1.15);
  transform: scale(1.08);
}

