/* Realtime API Voice Chat Styles */

.realtime-voice-chat-container {
    position: relative;
    margin: 12px 16px 16px;
    padding: 12px;
    overflow: visible;
    background: var(--medisim-bg-primary, #FFFFFF);
    border-radius: var(--medisim-radius-xs, 8px);
    border: 1px solid var(--medisim-border-tertiary, #E5E7EB);
    box-shadow:
      0 4px 6px -1px var(--medisim-shadow-intensity-2, rgba(0, 0, 0, 0.05)),
      0 2px 4px -2px var(--medisim-shadow-intensity-2, rgba(0, 0, 0, 0.05));
}

.voice-chat-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;  /* ⬅️ push ends apart */
  margin-bottom: 10px;
}

#realtime_voice_chat_container .voice-chat-hide-button {
  background: none;
  border: none;
  padding: 0;
  margin: 5px;
  margin-top: -4px;
  cursor: pointer;
  font-size: 14px;
  color: #555;
}

#realtime_voice_chat_container .voice-chat-hide-button:hover {
  color: #222;
}

.realtime-voice-btn,
.realtime-voice-btn-end {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.realtime-voice-btn {
    background: #28a745;
    color: white;
}

.realtime-voice-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Disabled state */
#realtime_voice_chat_container .realtime-voice-btn.realtime-voice-btn-disabled,
#realtime_voice_chat_container .realtime-voice-btn:disabled {
  background-color: #c9c9c9;
  color: #555;
  cursor: not-allowed;
  opacity: 1;
  border-color: #bfbfbf;
  box-shadow: none;
}

/* Prevent hover animation on disabled voice buttons */
#realtime_voice_chat_container .realtime-voice-btn:disabled,
#realtime_voice_chat_container .realtime-voice-btn.realtime-voice-btn-disabled {
    transform: none;
    box-shadow: none;
}

#realtime_voice_chat_container .realtime-voice-btn:disabled:hover,
#realtime_voice_chat_container .realtime-voice-btn.realtime-voice-btn-disabled:hover {
    background-color: #c9c9c9; /* keep disabled background */
    color: #555;               /* keep readable text */
    transform: none;           /* override hover transform */
    box-shadow: none;          /* prevent hover shadow */
    cursor: not-allowed;
}


.realtime-voice-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.realtime-voice-btn-end {
    background: #dc3545;
    color: white;
    margin-left: 10px;
}

.realtime-voice-btn-end:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.voice-chat-status {
    display: flex;
    align-items: center;
    gap: 15px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.voice-status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border-radius: 20px;
    border: 1px solid #dee2e6;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
}

.status-dot.connecting {
    background: #ffc107;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.connected {
    background: #28a745;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.error {
    background: #dc3545;
}

.status-dot.disconnected {
    background: #6c757d;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 0 8px transparent;
        opacity: 0.5;
    }
}

.status-text {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.voice-chat-instructions {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #007bff;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
        padding-top: 15px;
        padding-bottom: 15px;
    }
}

.voice-chat-instructions h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #007bff;
}

.voice-chat-instructions p {
    margin: 8px 0;
    color: #495057;
    line-height: 1.6;
}

.voice-chat-instructions ul {
    margin: 10px 0;
    padding-left: 25px;
}

.voice-chat-instructions li {
    margin: 5px 0;
    color: #6c757d;
}

.realtime-voice-notice {
    position: relative;
    margin: 15px 0;
    padding: 12px 44px 12px 12px;
    border: 1px solid #ffc107;
    border-radius: 6px;
    background: #fff3cd;
    color: #856404;
}

.realtime-voice-notice__content {
    font-size: 14px;
    line-height: 1.45;
}

.realtime-voice-notice__dismiss {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: currentColor;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.realtime-voice-notice__dismiss:hover,
.realtime-voice-notice__dismiss:focus-visible {
    background: rgba(133, 100, 4, 0.12);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .realtime-voice-chat-container {
        padding: 5px;
    }

    .realtime-voice-btn,
    .realtime-voice-btn-end {
        font-size: 14px;
        padding: 8px 16px;
    }

    .voice-chat-status {
        flex-direction: column;
        align-items: flex-start;
    }

    .realtime-voice-btn-end {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
}

/* Integration with existing chat UI */
#chat_message_autocomplete_wrapper.hidden-for-voice,
#write_chat_container.hidden-for-voice {
    display: none !important;
}

/* Loading state */
.realtime-voice-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.realtime-voice-btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
/* Ensure the tooltip isn't clipped by its containers */
.realtime-voice-chat-container,
.voice-chat-controls-row,
.voice-chat-start-wrapper {
  overflow: visible;
}

/* The info trigger */
.voice-chat-start-wrapper #use_voice_info {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--medisim-button-border-radius-icon-only, 8px);
  color: var(--medisim-fg-secondary, #545A7B);
  line-height: 1;
  cursor: pointer;
}

.voice-chat-start-wrapper #use_voice_info:after {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("/wp-content/themes/medioppi2026/assets/images/ui-icons/info.svg") center / 16px 16px no-repeat;
          mask: url("/wp-content/themes/medioppi2026/assets/images/ui-icons/info.svg") center / 16px 16px no-repeat;
}

.voice-chat-start-wrapper #use_voice_info:hover,
.voice-chat-start-wrapper #use_voice_info:focus-visible,
.voice-chat-start-wrapper #use_voice_info.is-visible {
  background: var(--medisim-bg-secondary, #F6F7F9);
  color: var(--medisim-fg-primary, #0A1343);
  outline: 0;
}

/* Tooltip itself */
.voice-chat-start-wrapper #use_voice_info .info_modal {
  display: none;
  position: fixed;
  top: var(--medisim-voice-info-top, 0);
  left: var(--medisim-voice-info-left, 24px);
  z-index: 1000000;
  box-sizing: border-box;
  width: var(--medisim-voice-info-width, min(420px, calc(100vw - 48px)));
  max-height: min(360px, 70vh);
  padding: 14px 16px;
  overflow: auto;
  border: 1px solid var(--medisim-border-secondary, #B5B8C7);
  border-radius: 8px;
  background: var(--medisim-bg-primary, #FFFFFF);
  box-shadow: 0 16px 36px rgba(10, 19, 67, 0.18);
  color: var(--medisim-fg-primary, #0A1343);
  font-family: var(--medisim-font-family-primary, "Instrument Sans"), system-ui, sans-serif;
  font-size: var(--medisim-font-size-text-sm, 14px);
  font-weight: var(--medisim-font-weight-regular, 400);
  line-height: 1.5;
  white-space: normal;
  transform: translateY(-100%);
}

/* Show on hover */
.voice-chat-start-wrapper #use_voice_info:hover .info_modal,
.voice-chat-start-wrapper #use_voice_info:focus-within .info_modal,
.voice-chat-start-wrapper #use_voice_info.is-visible .info_modal {
  display: block;
}

/* Optional: tidy list spacing inside the tooltip */
.voice-chat-start-wrapper #use_voice_info .info_modal ul {
  margin: 0.5em 0 1em;
  padding-left: 1.2em;
}

.voice-chat-start-wrapper #use_voice_info .info_modal li {
  list-style: disc;
  margin: 0.25em 0;
  color: inherit;
  line-height: 1.5;
}

.voice-chat-start-wrapper #use_voice_info .info_modal p {
  margin: 0 0 0.75em;
  color: inherit;
  line-height: 1.5;
}

.voice-chat-start-wrapper #use_voice_info .info_modal p:last-child,
.voice-chat-start-wrapper #use_voice_info .info_modal ul:last-child {
  margin-bottom: 0;
}

@media screen and (max-width: 750px) {
  .voice-chat-start-wrapper #use_voice_info .info_modal {
    max-height: min(420px, calc(100vh - 164px));
  }
}
