/* ==========================================================================
   Retell Voice Agent UI Styles - Sophia
   ========================================================================== */

/* Voice CTA Buttons */
.btn.btn-voice {
    background: linear-gradient(100deg, #ff6a1a 0%, #ff8a2b 26%, #2a72ff 78%, #1466ff 100%);
    box-shadow: 0 0 25px rgba(255, 106, 26, 0.35), 0 10px 30px rgba(20, 102, 255, 0.25);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: none;
    font-size: 15.5px;
    font-weight: 700;
}

.btn.btn-voice:hover {
    box-shadow: 0 0 35px rgba(255, 106, 26, 0.5), 0 12px 35px rgba(20, 102, 255, 0.4);
    transform: translateY(-2px);
}

.btn-voice .voice-pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: inherit;
    top: 0;
    left: 0;
    z-index: 0;
    opacity: 0.4;
    animation: voice-pulse 2.2s infinite;
}

@keyframes voice-pulse {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.08); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

.btn-voice svg,
.btn-voice span {
    position: relative;
    z-index: 1;
}

.btn-voice-header {
    background: #0f131a;
    border: 1px solid rgba(255, 106, 26, 0.35);
    color: #fff !important;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.btn-voice-header:hover {
    border-color: #ff6a1a;
    background: #141923;
    transform: translateY(-1px);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    box-shadow: 0 0 8px #10b981;
    animation: blink-live 1.5s infinite ease-in-out;
}

@keyframes blink-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* Floating Launcher Pill */
.voice-floating-pill {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 22px;
    border-radius: 999px;
    background: rgba(10, 13, 18, 0.94);
    border: 1px solid rgba(255, 106, 26, 0.4);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 20px rgba(255, 106, 26, 0.25);
    color: #fff;
    cursor: pointer;
    font-family: var(--font-display, sans-serif);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    backdrop-filter: blur(14px);
    transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}

.voice-floating-pill:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: #ff6a1a;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5), 0 0 28px rgba(255, 106, 26, 0.45);
}

.voice-floating-pill .pill-waves {
    display: flex;
    align-items: center;
    gap: 2.5px;
    height: 16px;
}

.voice-floating-pill .wave-bar {
    width: 3px;
    height: 8px;
    background: #ff6a1a;
    border-radius: 2px;
    animation: wave-bounce 1.2s infinite ease-in-out;
}

.voice-floating-pill .wave-bar:nth-child(2) {
    animation-delay: 0.2s;
    height: 14px;
    background: #ff8a2b;
}

.voice-floating-pill .wave-bar:nth-child(3) {
    animation-delay: 0.4s;
    height: 10px;
    background: #1466ff;
}

@keyframes wave-bounce {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1.2); }
}

/* Call Interface Modal / Card */
.voice-agent-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.voice-agent-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.voice-agent-card {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 410px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    background: #090c10;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(20, 102, 255, 0.2);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s, visibility 0.3s;
    color: #fff;
}

.voice-agent-card.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Card Header */
.voice-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
}

.voice-agent-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.voice-avatar-wrap {
    position: relative;
    width: 44px;
    height: 44px;
}

.voice-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6a1a, #1466ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    box-shadow: 0 0 16px rgba(255, 106, 26, 0.4);
}

.voice-avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #090c10;
    background: #6b7280;
    transition: background 0.3s;
}

.voice-avatar-status.live { background: #10b981; box-shadow: 0 0 8px #10b981; }
.voice-avatar-status.connecting { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.voice-avatar-status.ended { background: #ef4444; }

.voice-agent-meta h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
}

.voice-agent-meta p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #94a3b8;
}

.voice-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.icon-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* Orb & Visualizer Area */
.voice-stage {
    padding: 28px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(circle at 50% 30%, rgba(20, 102, 255, 0.12), transparent 70%);
}

.voice-orb {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ff8a2b, #ff6a1a 45%, #1466ff 85%);
    box-shadow: 0 0 35px rgba(255, 106, 26, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.3);
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s;
    animation: orb-idle 4s infinite ease-in-out;
}

@keyframes orb-idle {
    0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(255, 106, 26, 0.35); }
    50% { transform: scale(1.05); box-shadow: 0 0 45px rgba(20, 102, 255, 0.45); }
}

.voice-orb.is-talking {
    animation: orb-talk 1s infinite ease-in-out alternate;
    box-shadow: 0 0 60px rgba(255, 106, 26, 0.7), 0 0 90px rgba(20, 102, 255, 0.5);
}

@keyframes orb-talk {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.18); filter: brightness(1.25); }
}

.voice-orb.is-listening {
    animation: orb-listen 1.6s infinite ease-in-out;
    box-shadow: 0 0 45px rgba(16, 185, 129, 0.5);
}

@keyframes orb-listen {
    0%, 100% { transform: scale(1.02); }
    50% { transform: scale(1.1); }
}

.voice-status-label {
    margin-top: 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-status-label .status-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
}

.voice-status-label.connecting .status-indicator { background: #f59e0b; animation: blink-live 1s infinite; }
.voice-status-label.live .status-indicator { background: #10b981; }
.voice-status-label.speaking .status-indicator { background: #ff6a1a; animation: blink-live 0.8s infinite; }
.voice-status-label.ended .status-indicator { background: #ef4444; }

.call-timer {
    margin-top: 4px;
    font-family: var(--font-mono, monospace);
    font-size: 12px;
    color: #94a3b8;
    letter-spacing: 0.05em;
}

/* Live Waveform Indicator */
.voice-bars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3.5px;
    height: 24px;
    margin-top: 12px;
}

.voice-bars .bar {
    width: 3px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
    transition: height 0.15s, background 0.2s;
}

.voice-bars.active .bar {
    background: linear-gradient(to top, #ff6a1a, #1466ff);
    animation: bar-active 1s infinite ease-in-out;
}

.voice-bars.active .bar:nth-child(1) { animation-delay: 0.1s; height: 12px; }
.voice-bars.active .bar:nth-child(2) { animation-delay: 0.3s; height: 18px; }
.voice-bars.active .bar:nth-child(3) { animation-delay: 0.2s; height: 22px; }
.voice-bars.active .bar:nth-child(4) { animation-delay: 0.4s; height: 16px; }
.voice-bars.active .bar:nth-child(5) { animation-delay: 0.15s; height: 10px; }

@keyframes bar-active {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1.3); }
}

/* Transcript Drawer */
.voice-transcript-wrapper {
    flex: 1;
    min-height: 140px;
    max-height: 220px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.25);
    padding: 14px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
    line-height: 1.5;
}

.transcript-msg {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.transcript-msg.agent {
    align-items: flex-start;
}

.transcript-msg.user {
    align-items: flex-end;
}

.transcript-author {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.transcript-msg.agent .transcript-author { color: #ff8a2b; }
.transcript-msg.user .transcript-author { color: #60a5fa; }

.transcript-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 88%;
    word-break: break-word;
}

.transcript-msg.agent .transcript-bubble {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border-bottom-left-radius: 3px;
}

.transcript-msg.user .transcript-bubble {
    background: #1466ff;
    color: #fff;
    border-bottom-right-radius: 3px;
}

.transcript-empty {
    margin: auto;
    text-align: center;
    color: #64748b;
    font-size: 12.5px;
    padding: 12px 0;
}

/* Call Control Footer */
.voice-controls-bar {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.call-action-btn {
    border-radius: 999px;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.btn-start-call {
    flex: 1;
    background: linear-gradient(100deg, #ff6a1a 0%, #1466ff 100%);
    color: #fff;
    box-shadow: 0 4px 20px rgba(255, 106, 26, 0.35);
}

.btn-start-call:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(255, 106, 26, 0.5);
}

.btn-start-call:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-end-call {
    flex: 1;
    background: #dc2626;
    color: #fff;
    box-shadow: 0 4px 18px rgba(220, 38, 38, 0.35);
}

.btn-end-call:hover {
    background: #ef4444;
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(220, 38, 38, 0.5);
}

.btn-mute {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-mute:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.btn-mute.is-muted {
    background: #ea580c;
    border-color: #ea580c;
    color: #fff;
}

/* Public Key Settings Modal */
.voice-settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 1005;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.voice-settings-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.voice-settings-dialog {
    background: #0d1117;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    width: 440px;
    max-width: 100%;
    padding: 24px;
    color: #fff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    transform: scale(0.95);
    transition: transform 0.25s;
}

.voice-settings-overlay.is-open .voice-settings-dialog {
    transform: scale(1);
}

.voice-settings-dialog h4 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    background: none;
    -webkit-text-fill-color: initial;
    text-transform: none;
    letter-spacing: -0.01em;
}

.voice-settings-dialog p {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 16px;
    line-height: 1.5;
}

.voice-input-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #cbd5e1;
    margin-bottom: 6px;
}

.voice-text-input {
    width: 100%;
    padding: 11px 14px;
    background: #161b22;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #fff;
    font-size: 13.5px;
    margin-bottom: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.voice-text-input:focus {
    border-color: #ff6a1a;
    box-shadow: 0 0 0 3px rgba(255, 106, 26, 0.2);
}

.voice-settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(100deg, #ff6a1a, #1466ff);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.voice-hint-link {
    color: #60a5fa;
    text-decoration: underline;
    font-size: 12px;
}

.voice-error-toast {
    margin: 10px 16px 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 12px;
    display: none;
    line-height: 1.4;
}

.voice-mic-warning {
    margin: 10px 16px 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fcd34d;
    font-size: 12px;
    line-height: 1.45;
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .voice-floating-pill {
        bottom: 16px;
        right: 16px;
        padding: 11px 18px;
        font-size: 13px;
    }

    .voice-agent-card {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        border-radius: 22px 22px 0 0;
        max-height: 88vh;
    }
}
