/**
 * ═══════════════════════════════════════════════════════════════
 * VOICE CHAT STYLES - Patark.lt
 * ═══════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════
   VOICE MODE BUTTON (next to send button)
   ═══════════════════════════════════════════════════ */

.voice-mode-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(245, 240, 232, 0.12);
  background: linear-gradient(135deg, rgba(15, 27, 45, 0.98), rgba(28, 22, 56, 0.96));
  color: #f5f0e8;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  flex-shrink: 0;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.voice-mode-btn:hover {
  background: linear-gradient(135deg, rgba(32, 26, 68, 0.98), rgba(15, 27, 45, 0.98));
  border-color: rgba(124, 58, 237, 0.42);
  transform: scale(1.05);
}

.voice-mode-btn.active {
  background: linear-gradient(135deg, #D4A853, #B88C32);
  border-color: rgba(212, 168, 83, 0.55);
  color: #0f1b2d;
  box-shadow: 0 0 22px rgba(212, 168, 83, 0.24);
  animation: pulse-voice 2s ease-in-out infinite;
}

@keyframes pulse-voice {
  0%, 100% { 
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.25);
  }
  50% { 
    box-shadow: 0 0 30px rgba(212, 168, 83, 0.4);
  }
}

/* Mobile adjustment */
@media (max-width: 768px) {
  .voice-mode-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
    margin-right: 6px;
  }
}

/* ═══════════════════════════════════════════════════
   VOICE INTERFACE (inside chat input wrapper)
   ═══════════════════════════════════════════════════ */

.voice-interface {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at top center, rgba(212, 168, 83, 0.16), transparent 32%),
    radial-gradient(circle at bottom center, rgba(212, 168, 83, 0.1), transparent 35%),
    linear-gradient(180deg, rgba(15, 27, 45, 0.96) 0%, rgba(10, 18, 32, 0.98) 100%);
  border: 1px solid rgba(245, 240, 232, 0.08);
  border-radius: 22px;
  width: 100%;
  min-height: 120px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.voice-interface-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.voice-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: rgba(245, 240, 232, 0.88);
}

.voice-status .status-icon {
  font-size: 20px;
}

.voice-status .status-icon.recording {
  animation: pulse-red 1s ease-in-out infinite;
}

.voice-status .status-icon.processing {
  animation: spin 1s linear infinite;
}

.voice-status .status-icon.error {
  color: #EF4444;
}

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

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

/* ═══════════════════════════════════════════════════
   RECORD BUTTON
   ═══════════════════════════════════════════════════ */

.voice-record-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid rgba(212, 168, 83, 0.46);
  background:
    radial-gradient(circle at top, rgba(212, 168, 83, 0.24), transparent 38%),
    linear-gradient(135deg, #0f1b2d, #17304a);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 14px 8px;
  box-sizing: border-box;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  
  /* Prevent iOS text selection and callout */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

.voice-record-btn:hover {
  transform: scale(1.05);
  border-color: rgba(212, 168, 83, 0.72);
  box-shadow: 0 8px 30px rgba(212, 168, 83, 0.22);
}

.voice-record-btn:active,
.voice-record-btn.recording {
  transform: scale(0.95);
  background: linear-gradient(135deg, #D4A853, #B88C32);
  border-color: rgba(212, 168, 83, 0.9);
  color: #0f1b2d;
  box-shadow: 0 0 34px rgba(212, 168, 83, 0.34);
}

.voice-record-btn.processing {
  opacity: 0.72;
  cursor: not-allowed;
}

.voice-record-btn .record-icon {
  font-size: 32px;
  line-height: 1;
}

.voice-record-btn .record-text {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.1;
  max-width: 100%;
  padding: 0 1px;
}

/* ═══════════════════════════════════════════════════
   TIMER & WAVEFORM
   ═══════════════════════════════════════════════════ */

.voice-timer {
  font-size: 24px;
  font-weight: 700;
  color: #f5f0e8;
  font-variant-numeric: tabular-nums;
}

.voice-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

.voice-waveform.active {
  opacity: 1;
}

.waveform-bar {
  width: 4px;
  height: 10px;
  background: linear-gradient(180deg, #E7CF95, #D4A853 55%, #9D7425);
  border-radius: 2px;
  animation: none;
}

.voice-waveform.active .waveform-bar {
  animation: waveform 0.5s ease-in-out infinite;
}

.voice-waveform.active .waveform-bar:nth-child(1) { animation-delay: 0s; }
.voice-waveform.active .waveform-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-waveform.active .waveform-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-waveform.active .waveform-bar:nth-child(4) { animation-delay: 0.1s; }
.voice-waveform.active .waveform-bar:nth-child(5) { animation-delay: 0s; }

@keyframes waveform {
  0%, 100% { height: 10px; }
  50% { height: 30px; }
}

/* ═══════════════════════════════════════════════════
   VOICE SELECTOR
   ═══════════════════════════════════════════════════ */

.voice-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  margin-bottom: 6px;
}

.voice-option {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.voice-option:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.voice-option.active {
  border-color: rgba(212, 168, 83, 0.65);
  background: rgba(212, 168, 83, 0.15);
  color: #f5f0e8;
}

.voice-icon {
  font-size: 14px;
}

.voice-name {
  font-weight: 500;
}

[data-theme="light"] .voice-option {
  border-color: rgba(0, 0, 0, 0.15);
  background: rgba(0, 0, 0, 0.03);
  color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .voice-option:hover {
  border-color: rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.7);
}

[data-theme="light"] .voice-option.active {
  border-color: rgba(212, 168, 83, 0.65);
  background: rgba(212, 168, 83, 0.1);
  color: #333;
}

/* Voice hint */
.voice-hint {
  color: rgba(245, 240, 232, 0.58);
  font-size: 12px;
  margin-top: 10px;
  text-align: center;
}

.voice-cost-warning {
  color: #f5d48d;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 8px 16px;
  background: rgba(212, 168, 83, 0.12);
  border: 1px solid rgba(212, 168, 83, 0.25);
  border-radius: 8px;
  margin-top: 8px;
  width: 100%;
  max-width: 320px;
}

/* Voice cost info */
.voice-cost-info {
  color: rgba(245, 240, 232, 0.74);
  background: rgba(245, 240, 232, 0.05);
  font-size: 13px;
  margin-top: 15px;
  padding: 12px 16px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid rgba(245, 240, 232, 0.1);
  font-weight: 500;
}

/* Play response button (for autoplay blocked) */
.voice-play-response-btn {
  background: linear-gradient(135deg, #D4A853, #B88C32);
  color: #f8f5ef;
  border: 1px solid rgba(245, 240, 232, 0.16);
  border-radius: 12px;
  padding: 15px 30px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  animation: pulse-voice-response 2s infinite;
}

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

@keyframes pulse-voice-response {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 168, 83, 0.34); }
  50% { box-shadow: 0 0 20px 10px rgba(212, 168, 83, 0); }
}

/* ═══════════════════════════════════════════════════
   AUDIO PLAYER IN MESSAGES
   ═══════════════════════════════════════════════════ */

.voice-audio-player {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.replay-btn {
  background: rgba(212, 168, 83, 0.14);
  border: 1px solid rgba(212, 168, 83, 0.26);
  color: #e7cf95;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.replay-btn:hover {
  background: rgba(212, 168, 83, 0.2);
  transform: scale(1.02);
}

/* ═══════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .voice-mode-container {
    flex-direction: column;
    gap: 12px;
    padding: 10px 12px;
  }
  
  .voice-mode-toggle {
    width: 100%;
    justify-content: center;
  }
  
  .mode-btn {
    flex: 1;
    padding: 12px 16px;
  }
  
  .voice-record-btn {
    width: 120px;
    height: 120px;
    padding: 8px 18px 10px;
    gap: 3px;
  }
  
  .voice-record-btn .record-icon {
    font-size: 40px;
  }

  .voice-record-btn .record-text {
    font-size: 10.5px;
    letter-spacing: 0.05em;
  }
  
  .voice-interface {
    padding: 30px 15px;
  }

  .voice-selector {
    gap: 6px;
  }

  .voice-option {
    padding: 5px 10px;
    font-size: 12px;
  }
}

/* ═══════════════════════════════════════════════════
   MOBILE AUDIT — voice/chat upgrades (narrow screens, safe areas)
   Loaded after mobile-redesign-v4.css
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .chat-input-container {
    padding-top: 8px !important;
    padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
  }

  .voice-selector {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 10px;
    width: 100%;
    max-width: 100%;
    padding: 0 4px;
    box-sizing: border-box;
  }

  .voice-option {
    min-height: 44px;
    padding: 8px 12px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .voice-status {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    max-width: 100%;
    padding: 0 8px;
    box-sizing: border-box;
  }

  .voice-status .status-text {
    font-size: 14px;
    line-height: 1.35;
    max-width: 100%;
  }

  .voice-hint {
    font-size: 11px;
    line-height: 1.45;
    padding: 0 8px;
    max-width: 100%;
    box-sizing: border-box;
  }

  .voice-interface {
    padding-left: max(15px, env(safe-area-inset-left, 0px));
    padding-right: max(15px, env(safe-area-inset-right, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }

  .voice-mode-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .voice-record-btn {
    -webkit-tap-highlight-color: transparent;
  }

  .voice-play-response-btn {
    width: 100%;
    max-width: 320px;
    box-sizing: border-box;
    padding: 14px 20px;
  }

  /* Tall voice panel: last messages stay scrollable above fixed footer */
  body.patark-voice-mode-active #chatTab .chat-messages,
  body.patark-voice-mode-active .chat-messages {
    padding-bottom: 220px !important;
  }

  /* Teleprompter: keep the spoken line near mid-viewport when browser scrolls ancestors */
  body.patark-voice-mode-active .voice-sentence-chunk {
    scroll-margin-top: 38vh;
    scroll-margin-bottom: 12vh;
  }
}

@media (max-width: 380px) {
  .voice-option {
    flex: 1 1 calc(50% - 6px);
    min-width: min(140px, 100%);
    justify-content: center;
  }
}

