/* ============================================
   STORIES INSTAGRAM-STYLE — Vertical Viewer
   ============================================ */

.stories-viewer-vertical {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

.story-content-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.story-content {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.story-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 12px;
  padding-top: env(safe-area-inset-top, 40px);
}

.story-progress-container {
  flex: 1;
  display: flex;
  gap: 4px;
  height: 2px;
  max-width: 200px;
}

.story-progress-segment {
  flex: 1;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
  overflow: hidden;
}

.story-progress-bar {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 1px;
  transition: width 0ms linear, background 0.2s ease;
}

.story-progress-bar.active {
  width: 100%;
}

.story-progress-bar.completed {
  width: 100%;
  background: rgba(255, 255, 255, 0.6);
}

.story-boutique-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
}

.story-boutique-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.story-boutique-avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.story-boutique-details {
  display: flex;
  flex-direction: column;
}

.story-boutique-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.story-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.story-header-actions {
  display: flex;
  gap: 8px;
  margin-right: 8px;
}

.story-action-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.story-action-icon:hover {
  background: rgba(0, 0, 0, 0.5);
}

.story-view-count {
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}

.story-text-overlay {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  font-weight: 600;
  max-width: 90%;
}

.story-products-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  padding-bottom: env(safe-area-inset-bottom, 20px);
  overflow-x: auto;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}

.story-product-card {
  flex: 0 0 80px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
}

.story-product-img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}

.story-product-info {
  padding: 6px;
}

.story-product-name {
  font-size: 11px;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-product-price {
  font-size: 10px;
  color: #059669;
  font-weight: 700;
}

.story-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 20px));
}

.story-footer-left,
.story-footer-right {
  display: flex;
  gap: 8px;
}

.story-footer-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.story-footer-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.story-footer-btn:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.05);
}

.story-footer-btn.active {
  color: #ef4444;
}

.story-footer-btn.main-action {
  width: auto;
  border-radius: 28px;
  background: #fff;
  color: #000;
  padding: 8px 24px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.story-footer-btn.main-action:hover {
  background: #f3f4f6;
}

.story-nav-zone {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  cursor: pointer;
  z-index: 10;
}

.story-nav-top {
  top: 0;
}

.story-nav-bottom {
  top: 50%;
  height: 50%;
}

.story-swipe-hint {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s;
  animation: swipeHintPulse 2s infinite;
}

@keyframes swipeHintPulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.story-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.story-modal {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.story-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.story-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #111;
}

.story-modal-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
}

.story-tab-btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.story-tab-btn.active {
  color: #111;
}

.story-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #111;
  border-radius: 1px;
}

.story-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.story-viewer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.story-viewer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.story-viewer-avatar.placeholder {
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-weight: 600;
  font-size: 14px;
}

.story-viewer-info {
  flex: 1;
  min-width: 0;
}

.story-viewer-name {
  font-size: 14px;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-viewer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.story-viewer-role {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
}

.story-viewer-role.client {
  background: #dbeafe;
  color: #1d4ed8;
}

.story-viewer-role.vendeur {
  background: #fff7ed;
  color: #ea580c;
}

.story-viewer-time {
  font-size: 11px;
  color: #9ca3af;
}

.story-empty {
  text-align: center;
  color: #9ca3af;
  padding: 40px 20px;
}

.story-loading {
  text-align: center;
  color: #9ca3af;
  padding: 20px;
}

/* Reactions modal */
.story-reactions-modal .story-reactions-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.story-reaction-type-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
  transition: all 0.2s;
}

.story-reaction-type-btn:hover {
  background: #f3f4f6;
}

.story-reaction-type-btn.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.story-reaction-emoji {
  font-size: 16px;
}

.story-reaction-count {
  font-size: 13px;
  font-weight: 600;
}

.story-reactions-by-type {
  padding: 16px 20px;
}

.story-reaction-group {
  margin-bottom: 24px;
}

.story-reaction-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.story-reaction-users {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.story-reaction-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-reaction-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.story-reaction-avatar.placeholder {
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-weight: 600;
  font-size: 12px;
}

/* Comments modal */
.story-comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.story-comment {
  display: flex;
  gap: 10px;
  padding: 10px 0;
}

.story-comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.story-comment-avatar.placeholder {
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-weight: 600;
  font-size: 12px;
}

.story-comment-content {
  flex: 1;
  background: #f3f4f6;
  border-radius: 18px;
  padding: 8px 12px;
  max-width: 80%;
}

.story-comment-author {
  font-size: 13px;
  font-weight: 600;
  color: #111;
  margin-bottom: 2px;
}

.story-comment-text {
  font-size: 13px;
  color: #374151;
}

.story-comment-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

.story-comment-input {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.story-comment-input input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.story-comment-input input:focus {
  border-color: #3b82f6;
}

.story-comment-input button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.story-comment-input button:hover {
  background: #2563eb;
}

/* Dark mode pour stories */
.dark .story-modal {
  background: #1C1B1F;
}

.dark .story-modal-header {
  border-color: #49454F;
}

.dark .story-tab-btn {
  color: #CAC4D0;
}

.dark .story-tab-btn.active {
  color: #E6E1E5;
}

.dark .story-tab-btn.active::after {
  background: #D0BCFF;
}

.dark .story-modal-content {
  background: #1C1B1F;
}

.dark .story-viewer-avatar.placeholder {
  background: #36343B;
  color: #938F99;
}

.dark .story-viewer-name {
  color: #E6E1E5;
}

.story-viewer-role.client {
  background: #1E3A5F;
  color: #93BBFC;
}

.dark .story-viewer-role.vendeur {
  background: #3D2E1A;
  color: #FDD663;
}

.dark .story-viewer-time {
  color: #938F99;
}

.dark .story-comment-avatar.placeholder {
  background: #36343B;
  color: #938F99;
}

.dark .story-comment-content {
  background: #2B2930;
}

.dark .story-comment-author {
  color: #E6E1E5;
}

.dark .story-comment-text {
  color: #CAC4D0;
}

.dark .story-comment-time {
  color: #938F99;
}

.dark .story-comment-input input {
  background: #2B2930;
  border-color: #49454F;
  color: #E6E1E5;
}

.dark .story-comment-input input:focus {
  border-color: #D0BCFF;
}

.dark .story-reaction-type-btn {
  background: #2B2930;
  border-color: #49454F;
  color: #E6E1E5;
}

.dark .story-reaction-type-btn:hover {
  background: #36343B;
}

.dark .story-reaction-type-btn.active {
  background: #E6E1E5;
  color: #1C1B1F;
  border-color: #E6E1E5;
}

.dark .story-reaction-group-header {
  border-color: #49454F;
}

.dark .story-reaction-avatar.placeholder {
  background: #36343B;
  color: #938F99;
}

/* ============================================
   CHAT — Améliorations temps réel & typing
   ============================================ */

#typing-indicator {
  display: none;
  padding: 8px 16px;
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.dark #typing-indicator {
  background: #2B2930;
  color: #938F99;
  border-color: #49454F;
}

.chat-deeplink {
  color: #3b82f6;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dark .chat-deeplink {
  color: #93c5fd;
}

.chat-variante-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.chat-variante-card img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}

.chat-variante-card .min-w-0 {
  min-width: 0;
  flex: 1;
}

/* ============================================
   NOTIFICATION CENTER — WebPush & PWA
   ============================================ */

.notification-center {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100vh;
  background: var(--bg-primary);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-center.open {
  right: 0;
}

.notification-center-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  z-index: 9997;
  transition: opacity 0.3s, visibility 0.3s;
}

.notification-center-overlay.open {
  opacity: 1;
  visibility: visible;
}

.notification-center-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.notification-center-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.notification-center-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.notification-tab-btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.notification-tab-btn.active {
  color: var(--accent-color);
}

.notification-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-color);
}

.notification-tab-badge {
  background: var(--danger-color);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
}

.notification-center-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.notification-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--card-bg);
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.2s;
  cursor: pointer;
}

.notification-item.unread {
  border-left: 3px solid var(--accent-color);
  background: var(--bg-secondary);
}

.notification-item:hover {
  box-shadow: var(--card-shadow);
}

.notification-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.notification-item-icon.commande { background: #dcfce7; color: #166534; }
.notification-item-icon.promotion { background: #fce7f3; color: #be185d; }
.notification-item-icon.follow { background: #dbeafe; color: #1e40af; }
.notification-item-icon.ia { background: #faf5ff; color: #6b21a8; }
.notification-item-icon.system { background: #f3f4f6; color: #374151; }
.notification-item-icon.chat { background: #fef3c7; color: #92400e; }

.dark .notification-item-icon.commande { background: #064e3b; color: #86efac; }
.dark .notification-item-icon.promotion { background: #500724; color: #f9a8d4; }
.dark .notification-item-icon.follow { background: #1e3a5f; color: #93c5fd; }
.dark .notification-item-icon.ia { background: #3b0764; color: #e9d5ff; }
.dark .notification-item-icon.system { background: #36343B; color: #d1d5db; }
.dark .notification-item-icon.chat { background: #422006; color: #fcd34d; }

.notification-item-content {
  flex: 1;
  min-width: 0;
}

.notification-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.notification-item-message {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 4px;
}

.notification-item-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.notification-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.notification-action-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.notification-action-btn:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.notification-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

.notification-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.notification-center-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.notification-center-footer button {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent-color);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.notification-center-footer button:hover {
  opacity: 0.9;
}

/* Badge notification dans navbar */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--danger-color);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ============================================
   PWA — Service Worker & Offline
   ============================================ */

.offline-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #f59e0b;
  color: #1f2937;
  text-align: center;
  padding: 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.offline-banner.show {
  transform: translateY(0);
}

.offline-banner button {
  background: #1f2937;
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 20px;
  margin-left: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Install prompt */
.install-prompt {
  position: fixed;
  bottom: 100px;
  left: 20px;
  right: 20px;
  max-width: 400px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 20px;
  z-index: 9999;
  animation: installSlideUp 0.3s ease-out;
}

@keyframes installSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.install-prompt-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.install-prompt-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
}

.install-prompt-text {
  flex: 1;
}

.install-prompt-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.install-prompt-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.install-prompt-actions {
  display: flex;
  gap: 8px;
}

.install-prompt-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.install-prompt-btn.primary {
  background: var(--accent-color);
  color: white;
}

.install-prompt-btn.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ============================================
   RESPONSIVE STORIES
   ============================================ */

@media (max-width: 480px) {
  .story-progress-container {
    max-width: 100%;
  }
  
  .story-footer-btn.main-action {
    padding: 8px 16px;
    font-size: 12px;
  }
  
  .story-product-card {
    flex: 0 0 70px;
  }
  
  .story-product-img {
    height: 70px;
  }
}

@media (min-width: 768px) {
  .story-content-wrapper {
    max-width: 480px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-top: 20px;
    margin-bottom: 20px;
  }
  
  .stories-viewer-vertical {
    background: rgba(0, 0, 0, 0.9);
  }
}

/* ============================================
   UTILITAIRES STORIES
   ============================================ */

.animate-pulse-slow {
  animation: pulse 3s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.story-enter {
  animation: storyEnter 0.3s ease-out;
}

@keyframes storyEnter {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.story-exit {
  animation: storyExit 0.3s ease-in;
}

@keyframes storyExit {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(1.05);
  }
}