/**
 * Voice Message UI Styles
 * Styling for VoiceRecorder and VoicePlayer components
 * Matches the Community platform design system
 */

/* ============================================================================
   VOICE RECORDER STYLES
   ============================================================================ */

.voice-recorder {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.voice-recorder-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary-600);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
  touch-action: none;
}

.voice-recorder-button:hover:not(:disabled) {
  background-color: var(--color-primary-700);
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.voice-recorder-button:active:not(:disabled) {
  transform: scale(0.95);
}

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

.voice-recorder-button:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

.voice-recorder-button.recording {
  background-color: var(--color-error-600);
  animation: pulse-recording 1.5s infinite;
}

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

.voice-icon {
  width: 24px;
  height: 24px;
}

/* Recording Overlay */

.voice-recording-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-base);
  touch-action: none;
}

.voice-recording-panel {
  background-color: var(--color-bg-primary);
  border-radius: var(--radius-xl);
  padding: var(--spacing-8);
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-xl);
  animation: slideUp var(--transition-base);
}

.voice-recording-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-6);
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
}

.recording-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background-color: var(--color-error-600);
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.recording-text {
  font-size: var(--text-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.recording-duration {
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  transition: color var(--transition-base);
}

.recording-duration.warning {
  color: var(--color-error-600);
  animation: blink 0.5s infinite;
}

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

/* Waveform Canvas */

.voice-waveform-canvas {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary-50) 0%, var(--color-secondary-50) 100%);
  margin-bottom: var(--spacing-6);
}

.voice-recording-footer {
  text-align: center;
}

.cancel-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  opacity: 0.5;
  transition: opacity var(--transition-base);
}

.cancel-hint svg {
  width: 16px;
  height: 16px;
  animation: bounce 1.5s infinite;
}

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

/* ============================================================================
   VOICE PLAYER STYLES
   ============================================================================ */

.voice-player {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
  padding: var(--spacing-4);
  background-color: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  max-width: 400px;
}

.voice-player-main {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

/* Play Button */

.voice-play-button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary-600);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.voice-play-button:hover:not(:disabled) {
  background-color: var(--color-primary-700);
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.voice-play-button:active:not(:disabled) {
  transform: scale(0.95);
}

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

.voice-play-button:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

.voice-play-button svg {
  width: 24px;
  height: 24px;
}

/* Loading Spinner */

.loading-spinner {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--color-white);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

/* Player Content */

.voice-player-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  min-width: 0;
}

/* Waveform Container */

.voice-waveform-container {
  position: relative;
  width: 100%;
  height: 40px;
}

.voice-waveform-static {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
}

/* Progress Bar */

.voice-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.voice-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-sm);
  pointer-events: none;
  transition: width 0.1s linear;
}

.voice-progress-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background-color: var(--color-primary-600);
  border: 2px solid var(--color-white);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.voice-progress-bar:hover .voice-progress-handle {
  opacity: 1;
}

/* Player Controls */

.voice-player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-2);
}

.voice-time-display {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

.voice-speed-button {
  padding: var(--spacing-1) var(--spacing-2);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background-color: transparent;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 36px;
}

.voice-speed-button:hover {
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  border-color: var(--color-primary-500);
}

.voice-speed-button:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 1px;
}

/* Warning Message */

.voice-warning {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  background-color: var(--color-warning-50);
  border-left: 3px solid var(--color-warning-500);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-warning-700);
}

.voice-warning svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Transcription Toggle */

.voice-transcription-toggle {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  width: 100%;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-primary-600);
  background-color: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.voice-transcription-toggle:hover {
  background-color: var(--color-primary-50);
}

.voice-transcription-toggle:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 1px;
}

.voice-transcription-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-base);
}

/* Transcription Panel */

.voice-transcription-panel {
  padding: var(--spacing-3);
  background-color: var(--color-bg-primary);
  border-radius: var(--radius-md);
  animation: slideDown var(--transition-base);
}

.voice-transcription-content {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-2);
}

.voice-transcription-meta {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  padding-top: var(--spacing-2);
  border-top: 1px solid var(--color-border-subtle);
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
  /* Larger touch targets on mobile */
  .voice-recorder-button {
    width: 52px;
    height: 52px;
  }

  .voice-play-button {
    width: 52px;
    height: 52px;
  }

  .voice-icon {
    width: 28px;
    height: 28px;
  }

  .voice-recording-panel {
    width: 95%;
    padding: var(--spacing-6);
  }

  .voice-waveform-canvas {
    height: 60px;
  }

  .voice-player {
    max-width: 100%;
  }

  /* Make progress bar easier to tap */
  .voice-progress-bar {
    padding: var(--spacing-2) 0;
  }

  .voice-progress-handle {
    width: 16px;
    height: 16px;
    opacity: 1;
  }
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  .voice-waveform-canvas {
    background: linear-gradient(135deg, var(--color-primary-900) 0%, var(--color-secondary-900) 100%);
  }

  .voice-player {
    background-color: var(--color-gray-800);
  }

  .voice-transcription-panel {
    background-color: var(--color-gray-800);
  }

  .voice-warning {
    background-color: rgba(251, 191, 36, 0.1);
  }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Ensure focus indicators are visible */
*:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .voice-recorder-button.recording,
  .recording-dot,
  .recording-duration.warning,
  .cancel-hint svg,
  .spinner {
    animation: none;
  }

  .voice-progress-fill {
    transition: none;
  }

  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .voice-recorder-button,
  .voice-play-button {
    border: 2px solid currentColor;
  }

  .voice-progress-handle {
    border-width: 3px;
  }
}

/* ============================================================================
   INTEGRATION WITH CHAT MESSAGE STYLES
   ============================================================================ */

/* Voice player in message bubble */
.message-bubble .voice-player {
  margin: var(--spacing-2) 0;
  max-width: 100%;
}

.message-own .voice-player {
  background-color: rgba(255, 255, 255, 0.1);
}

.message-own .voice-player .voice-time-display {
  color: rgba(255, 255, 255, 0.8);
}

.message-own .voice-player .voice-speed-button {
  color: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.3);
}

.message-own .voice-player .voice-speed-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--color-white);
}

/* Voice recorder in message input */
.message-input-wrapper .voice-recorder {
  margin-left: var(--spacing-2);
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.voice-player--compact {
  padding: var(--spacing-2);
  max-width: 300px;
}

.voice-player--compact .voice-play-button {
  width: 40px;
  height: 40px;
}

.voice-player--compact .voice-play-button svg {
  width: 20px;
  height: 20px;
}

/* ============================================================================
   VOICE STORY RECORDER MODAL
   ============================================================================ */

.voice-story-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease-out;
}

.voice-story-modal {
  background: var(--color-bg-primary, #fff);
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.voice-story-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.voice-story-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.voice-story-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary, #6b7280);
  line-height: 1;
  padding: 0.25rem;
}

.voice-story-body {
  padding: 2rem 1.5rem;
}

.voice-story-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.voice-story-mic-icon {
  font-size: 3rem;
}

.voice-story-hint {
  font-size: 0.75rem;
  color: var(--color-text-secondary, #6b7280);
}

.voice-story-record-btn,
.voice-story-stop-btn,
.voice-story-retry-btn,
.voice-story-another-btn {
  padding: 0.75rem 2rem;
  border-radius: 9999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.voice-story-record-btn {
  background: var(--color-primary, #14b8a6);
  color: #fff;
}

.voice-story-record-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

.voice-story-stop-btn {
  background: #ef4444;
  color: #fff;
}

.voice-story-stop-btn:hover {
  background: #dc2626;
}

.voice-story-retry-btn,
.voice-story-another-btn {
  background: var(--color-bg-secondary, #f3f4f6);
  color: var(--color-text-primary, #1f2937);
}

/* Recording state */
.voice-story-recording-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: #ef4444;
}

.voice-story-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.voice-story-waveform {
  width: 100%;
  max-width: 320px;
  height: 64px;
  border-radius: 8px;
  background: var(--color-bg-secondary, #f3f4f6);
}

.voice-story-timer {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-primary, #1f2937);
}

.voice-story-remaining {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
  min-height: 1.25rem;
}

.voice-story-warning {
  color: #ef4444;
  font-weight: 600;
}

/* Uploading state */
.voice-story-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border, #e5e7eb);
  border-top-color: var(--color-primary, #14b8a6);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Complete state */
.voice-story-success-icon {
  font-size: 3rem;
}

.voice-story-result-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.voice-story-result-excerpt {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
  max-height: 4.5rem;
  overflow: hidden;
}

.voice-story-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.voice-story-edit-btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  border-radius: 9999px;
  background: var(--color-primary, #14b8a6);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
}

.voice-story-edit-btn:hover {
  filter: brightness(1.1);
}

/* Error state */
.voice-story-error-icon {
  font-size: 3rem;
}

.voice-story-error-msg {
  color: #ef4444;
}

/* Village AI awareness card */
.awareness-card-ai {
  background: linear-gradient(135deg, var(--color-bg-primary, #fff), rgba(20, 184, 166, 0.05));
  border-color: rgba(20, 184, 166, 0.2);
}

.awareness-card-ai:hover {
  border-color: var(--color-primary, #14b8a6);
}

.awareness-card-ai .awareness-action {
  color: var(--color-primary, #14b8a6);
  font-weight: 600;
  font-size: 0.8rem;
}

/* Voice awareness cards */
.awareness-card-voice {
  background: linear-gradient(135deg, var(--color-bg-primary, #fff), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.15);
}

.awareness-card-voice:hover {
  border-color: rgba(239, 68, 68, 0.4);
}

/* ============================================================================
   POSTCARD COMPOSER MODAL
   ============================================================================ */

.postcard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.postcard-modal {
  background: var(--color-bg-primary, #fff);
  border-radius: 1rem;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.postcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.postcard-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-text-primary, #1f2937);
}

.postcard-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary, #6b7280);
  padding: 0.25rem;
  line-height: 1;
}

.postcard-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.postcard-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary, #6b7280);
  margin: 0 0 0.75rem 0;
}

/* Recipient selection */
.postcard-selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.postcard-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 1rem;
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-text-primary, #1f2937);
  font-size: 0.8rem;
  cursor: pointer;
}

.postcard-chip:hover {
  background: rgba(239, 68, 68, 0.2);
}

.postcard-chip-x {
  font-weight: bold;
  opacity: 0.5;
}

.postcard-search {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1f2937);
}

.postcard-member-list {
  max-height: 350px;
  overflow-y: auto;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.postcard-member {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text-primary, #1f2937);
  text-align: left;
}

.postcard-member:hover {
  background: var(--color-bg-secondary, #f9fafb);
}

.postcard-member.selected {
  background: rgba(239, 68, 68, 0.05);
}

.postcard-member + .postcard-member {
  border-top: 1px solid var(--color-border, #e5e7eb);
}

.postcard-member-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-primary, #14b8a6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

.postcard-member-name {
  flex: 1;
}

.postcard-check {
  color: #ef4444;
  font-weight: bold;
}

.postcard-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-secondary, #6b7280);
  font-size: 0.875rem;
}

/* Recording state */
.postcard-recorder {
  text-align: center;
}

.postcard-waveform {
  width: 100%;
  height: 60px;
  border-radius: 0.5rem;
  background: rgba(239, 68, 68, 0.05);
  margin-bottom: 0.75rem;
}

.postcard-timer {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ef4444;
  margin-bottom: 0.25rem;
}

.postcard-remaining {
  font-size: 0.8rem;
  color: var(--color-text-secondary, #6b7280);
  margin-bottom: 1.25rem;
}

.postcard-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* Footer / buttons */
.postcard-footer {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

.postcard-btn {
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--color-border, #e5e7eb);
  cursor: pointer;
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1f2937);
}

.postcard-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.postcard-btn-primary {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.postcard-btn-primary:hover:not(:disabled) {
  background: #dc2626;
}

.postcard-btn-stop {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
}

.postcard-btn-cancel {
  background: none;
}

/* Review state */
.postcard-review {
  text-align: center;
}

.postcard-preview-audio {
  width: 100%;
  margin-bottom: 1rem;
}

.postcard-photo-attach {
  margin-bottom: 1.25rem;
}

.postcard-photo-label {
  font-size: 0.85rem;
  color: var(--color-text-secondary, #6b7280);
  margin-bottom: 0.5rem;
}

.postcard-btn-secondary {
  background: var(--color-surface-elevated, #f3f4f6);
  color: var(--color-text-primary, #1f2937);
  border: 1px solid var(--color-border, #e5e7eb);
  cursor: pointer;
}

.postcard-btn-secondary:hover {
  background: var(--color-surface-hover, #e5e7eb);
}

.postcard-photo-preview {
  position: relative;
  display: inline-block;
  max-width: 200px;
  margin: 0 auto;
}

.postcard-photo-preview img {
  width: 100%;
  border-radius: 0.5rem;
  max-height: 150px;
  object-fit: cover;
}

.postcard-photo-remove {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  border: none;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Photo upload progress indicator */
.postcard-photo-uploading {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  text-align: center;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.postcard-photo-uploading span {
  animation: pulse-opacity 1.2s ease-in-out infinite;
}

.postcard-upload-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  margin-top: 0.25rem;
  overflow: hidden;
}

.postcard-upload-bar-fill {
  height: 100%;
  width: 40%;
  background: #fff;
  border-radius: 2px;
  animation: upload-indeterminate 1.2s ease-in-out infinite;
}

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

@keyframes upload-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Status states */
.postcard-status {
  text-align: center;
  padding: 2rem 1rem;
}

.postcard-status p {
  font-size: 1rem;
  font-weight: 500;
  margin: 0.5rem 0;
}

.postcard-status-detail {
  font-size: 0.8rem !important;
  font-weight: 400 !important;
  color: var(--color-text-secondary, #6b7280);
}

.postcard-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--color-border, #e5e7eb);
  border-top-color: #ef4444;
  border-radius: 50%;
  animation: postcard-spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.postcard-success-icon {
  display: inline-flex;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: #22c55e;
  color: white;
  font-size: 1.5rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.postcard-error p:first-of-type {
  color: #ef4444;
}

/* ============================================================================
   POSTCARDS PAGE (postcards.html)
   ============================================================================ */

.postcards-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.postcards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.postcards-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-text-primary, #1f2937);
}

.postcards-send-btn {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: #ef4444;
  color: white;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.postcards-send-btn:hover {
  background: #dc2626;
}

.postcards-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border, #e5e7eb);
  margin-bottom: 1rem;
}

.postcards-tab {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-secondary, #6b7280);
  cursor: pointer;
  position: relative;
}

.postcards-tab.active {
  color: #ef4444;
  border-bottom-color: #ef4444;
}

.postcards-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 1rem;
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.375rem;
}

.postcards-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.postcards-loading,
.postcards-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-secondary, #6b7280);
}

.postcards-empty-hint {
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.postcard-item {
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 0.75rem;
  padding: 1rem;
}

.postcard-item.postcard-unlistened {
  border-left: 3px solid #ef4444;
  background: rgba(239, 68, 68, 0.02);
}

.postcard-item-sender {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.postcard-item-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--color-primary, #14b8a6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.postcard-item-time {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-secondary, #6b7280);
}

.postcard-audio {
  width: 100%;
  height: 2.25rem;
  margin-bottom: 0.5rem;
}

.postcard-transcript {
  font-size: 0.8rem;
  color: var(--color-text-secondary, #6b7280);
  font-style: italic;
  margin: 0;
  line-height: 1.4;
}

.postcard-item-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.postcard-recipient-status {
  font-size: 0.75rem;
  color: var(--color-text-secondary, #6b7280);
}

.postcard-recipient-status.listened {
  color: #22c55e;
}

.postcard-item-photo {
  max-width: 200px;
  max-height: 150px;
  border-radius: 0.5rem;
  object-fit: cover;
  margin-top: 0.5rem;
}
