/* Echo App Custom Styles */

/* Swipe gesture feedback */
.swiping-active {
    user-select: none;
    cursor: grabbing !important;
}

.swipe-right-hint {
    background-color: rgba(59, 130, 246, 0.1);
}

.swipe-left-hint {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Voice reply UI */
.voice-reply-section {
    transition: all 0.3s ease;
}

.voice-reply-section.hidden {
    display: none;
}

.reply-waveform {
    background-color: rgba(55, 65, 81, 0.5); /* gray-700 with opacity */
}

.reply-progress {
    background-color: #8b5cf6; /* purple-500 */
    transition: width 0.1s linear;
}

/* Match notification animations */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Chat list styles */
.chat-list-item {
    transition: background-color 0.2s ease;
}

.chat-list-item.active {
    background-color: #1a1a1a;
}

/* Photo reveal badges and blur effects */
.blur-sm {
  filter: blur(4px);
}

#photo-countdown-badge {
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

/* Smooth photo reveal transition */
.chat-header img {
  transition: filter 0.3s ease;
}

/* Chat module integration */
.chat-module {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: #0f0f0f;
}

.chat-module.hidden {
  display: none;
}

/* Matches screen chat button connection */
.matches-screen .chat-btn {
  background-color: #7c3aed;
  color: white;
  padding: 8px 16px;
  border-radius: 12px;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.matches-screen .chat-btn:hover {
  background-color: #6d28d9;
}

/* Navigation active state */
nav [data-route].active {
  color: #7c3aed;
  font-weight: 600;
}

/* Message bubbles */
.message-bubble {
  padding: 8px 16px;
  border-radius: 24px;
  word-wrap: break-word;
}

.message-bubble.sent {
  background-color: #7c3aed;
  color: white;
}

.message-bubble.received {
  background-color: #1a1a1a;
  color: white;
}

/* Voice message styles */
.voice-message .play-btn {
  transition: all 0.2s ease;
}

.voice-message .play-btn:hover {
  transform: scale(1.05);
}

.progress-bar {
  transition: width 0.1s linear;
}

/* ===== CHAT POLISH ===== */

/* Message bubble animations */
@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-bubble {
  animation: messageAppear 0.3s ease;
  will-change: opacity, transform;
}

/* Optimistic message styling */
.message-bubble[data-optimistic="true"] {
  opacity: 0.7;
}

/* Read receipt animation */
.status .text-blue-500 {
  animation: pulse-blue 2s infinite;
}

@keyframes pulse-blue {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Photo reveal badge animations */
#photo-countdown-badge {
  animation: badge-pulse 3s infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Voice recording button states */
#voice-record-btn:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

#voice-record-btn.recording {
  background-color: #ef4444;
  animation: recording-pulse 1s infinite;
}

@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* Loading states */
.loading-messages {
  opacity: 0.6;
  pointer-events: none;
}

/* Empty state styling */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 50vh;
  text-align: center;
}

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

/* Chat layout */
.chat-layout {
  height: 100vh;
}

.chat-sidebar {
  background-color: #0f0f0f;
}

.chat-main {
  background-color: #0f0f0f;
}

.messages-container {
  display: flex;
  flex-direction: column;
}

/* Smooth scrolling */
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: #1a1a1a;
}

.messages-container::-webkit-scrollbar-thumb {
  background: #7c3aed;
  border-radius: 3px;
}

/* Loading spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .chat-layout {
    flex-direction: column;
  }

  .chat-sidebar {
    width: 100%;
    height: 40vh;
    border-right: none;
    border-bottom: 1px solid #2d2d2d;
  }

  .chat-main {
    height: 60vh;
  }

  .message-bubble {
    max-width: 90%;
  }
}

/* Smooth transitions */
.chat-sidebar,
.chat-main,
.message-bubble,
.chat-input-wrapper {
  transition: all 0.2s ease;
}

/* Accessibility improvements */
button:focus {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

textarea:focus {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .message-bubble.sent {
    background-color: #5b21b6; /* Darker purple */
  }

  .message-bubble.received {
    background-color: #262626; /* Darker gray */
  }
}

/* ===== CHAT MESSENGER ADDITIONS ===== */

/* Message status and failure states */
.message-failed {
  opacity: 0.7;
  border: 1px solid #ef4444;
}

/* Optimistic message styling */
.message-optimistic {
  opacity: 0.8;
}

/* Polling indicator */
.polling-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  animation: pulse 2s infinite;
}

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

/* Chat input styles */
.chat-input-wrapper {
  border: 1px solid #2d2d2d;
}

#chat-text-input {
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
}

#chat-text-input:focus {
  border-color: transparent;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.voice-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Voice recording animations */
@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.5); }
}

.animate-wave {
  animation: wave 1s ease-in-out infinite;
}

.delay-75 { animation-delay: 75ms; }
.delay-150 { animation-delay: 150ms; }
.delay-225 { animation-delay: 225ms; }
.delay-300 { animation-delay: 300ms; }

/* Recording UI */
.voice-wave .wave-bar {
  transform-origin: center bottom;
}

#recording-timer.text-red-500 {
  animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7;
  }
}

/* ===== PWA STANDALONE MODE OPTIMIZATIONS ===== */

/* Adjust for iOS notch and Android status bar */
@supports (padding: max(0px)) {
    body.standalone {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Standalone-specific adjustments */
@media (display-mode: standalone) {
    /* Adjust header for standalone mode */
    header {
        padding-top: env(safe-area-inset-top, 20px);
        padding-bottom: 1rem;
    }

    /* Adjust bottom navigation for standalone mode */
    nav.fixed.bottom-0 {
        padding-bottom: env(safe-area-inset-bottom, 10px);
    }

    /* Hide install button when in standalone mode */
    #install-button {
        display: none !important;
    }

    /* Adjust offline indicator position */
    #offline-indicator {
        top: calc(env(safe-area-inset-top, 20px) + 1rem);
    }
}

/* iOS PWA specific fixes */
@supports (-webkit-touch-callout: none) {
    body.standalone {
        /* Prevent bounce effect on iOS */
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix 100vh issue on iOS */
    .min-h-screen {
        min-height: -webkit-fill-available;
    }
}

/* Android PWA specific fixes */
@supports not (-webkit-touch-callout: none) {
    body.standalone {
        /* Prevent overscroll glow on Android */
        overscroll-behavior-y: none;
    }
}

/* Install button animations */
#install-button {
    animation: slideInUp 0.3s ease-out;
}

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

/* Manual install instructions animations */
#manual-install-instructions {
    animation: fadeIn 0.3s ease-out;
}

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

/* Offline message styling */
#offline-message .bg-gray-800 {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Update notification styling */
.fixed.bottom-4.right-4.bg-primary {
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.3);
    transition: all 0.3s ease;
}

.fixed.bottom-4.right-4.bg-primary:hover {
    box-shadow: 0 15px 40px rgba(124, 58, 237, 0.4);
    transform: translateY(-2px);
}