/**
 * ECS Voice Widget — styles and animations
 *
 * Scoping rule: EVERY selector is prefixed .ecs-voice- or #ecs-voice-
 * to prevent collisions with WooCommerce, jQuery UI, and theme styles.
 *
 * @package ECS_Operations
 * @since   1.0.0
 */

/* ==========================================================================
   Root container — system font stack
   ========================================================================== */

#ecs-voice-widget-root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================================================
   Floating Action Button (FAB)
   ========================================================================== */

#ecs-voice-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0073aa;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: ecs-voice-fab-entrance 0.2s ease-out 0.3s both;
    transition: background-color 0.15s ease;
    padding: 0;
}

#ecs-voice-fab:hover {
    background: #005a87;
}

#ecs-voice-fab:active {
    transform: scale(0.95);
}

#ecs-voice-fab svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
}

/* ==========================================================================
   Modal overlay (backdrop)
   ========================================================================== */

.ecs-voice-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide via [hidden] attribute — overrides the flex display above */
#ecs-voice-modal[hidden] {
    display: none !important;
}

/* Modal open transition class added by JS */
.ecs-voice-modal-visible .ecs-voice-modal-inner {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================================================
   Modal inner container
   ========================================================================== */

.ecs-voice-modal-inner {
    max-width: 440px;
    width: calc(100% - 32px);
    max-height: 80vh;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #dddddd;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

/* When modal becomes visible, animate inner container in */
#ecs-voice-modal:not([hidden]) .ecs-voice-modal-inner {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================================================
   Modal header
   ========================================================================== */

.ecs-voice-modal-header {
    background: #f5f5f5;
    padding: 16px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#ecs-voice-modal-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    color: #1a1a1a;
}

#ecs-voice-status {
    font-size: 16px;
    font-weight: 400;
    color: #555555;
}

#ecs-voice-timer {
    font-size: 14px;
    font-weight: 400;
    color: #0073aa;
}

/* ==========================================================================
   Processing indicator — three pulsing dots
   ========================================================================== */

.ecs-voice-processing {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 12px 0;
    flex-shrink: 0;
}

.ecs-voice-processing[hidden] {
    display: none !important;
}

.ecs-voice-processing span {
    width: 10px;
    height: 10px;
    background: #0073aa;
    border-radius: 50%;
    display: inline-block;
    animation: ecs-voice-pulse 1.2s infinite ease-in-out;
}

.ecs-voice-processing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ecs-voice-processing span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ==========================================================================
   Live transcript panel
   ========================================================================== */

.ecs-voice-transcript {
    min-height: 120px;
    max-height: 240px;
    overflow-y: auto;
    padding: 16px;
    font-size: 16px;
    font-weight: 400;
    color: #1a1a1a;
    line-height: 1.5;
    scroll-behavior: smooth;
    flex-shrink: 0;
}

/* Speaker label — agent */
.ecs-voice-transcript-agent {
    font-size: 14px;
    font-weight: 600;
    color: #0073aa;
}

/* Speaker label — user */
.ecs-voice-transcript-user {
    font-size: 14px;
    font-weight: 600;
    color: #555555;
}

/* Interim (in-progress) transcript text */
.ecs-voice-transcript-interim {
    font-style: italic;
    color: #888888;
}

/* Empty state placeholder */
.ecs-voice-transcript-empty {
    font-size: 14px;
    color: #888888;
    font-style: italic;
    text-align: center;
}

/* ==========================================================================
   Call controls
   ========================================================================== */

.ecs-voice-controls {
    padding: 16px;
    border-top: 1px solid #dddddd;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-shrink: 0;
}

/* Start Call button */
#ecs-voice-btn-call {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: #0073aa;
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    cursor: pointer;
    min-height: 44px;
    transition: background-color 0.15s ease;
}

#ecs-voice-btn-call:hover {
    background: #005a87;
}

#ecs-voice-btn-call:active {
    transform: scale(0.97);
}

/* Mute button */
#ecs-voice-btn-mute {
    font-size: 14px;
    font-weight: 400;
    color: #ffffff;
    background: #6c757d;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    min-height: 44px;
    transition: background-color 0.15s ease;
}

#ecs-voice-btn-mute[hidden] {
    display: none !important;
}

/* Mute button — active/muted state (toggled by JS adding this class) */
#ecs-voice-btn-mute.ecs-voice-btn-muted {
    background: #f0ad4e;
}

/* End Call button */
#ecs-voice-btn-end {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: #d63638;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    min-height: 44px;
    transition: background-color 0.15s ease;
}

#ecs-voice-btn-end:hover {
    background: #b02a2c;
}

#ecs-voice-btn-end[hidden] {
    display: none !important;
}

/* ==========================================================================
   Post-call summary
   ========================================================================== */

.ecs-voice-summary {
    padding: 16px;
    border-top: 1px solid #dddddd;
    flex-shrink: 0;
}

.ecs-voice-summary[hidden] {
    display: none !important;
}

.ecs-voice-summary-heading {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 8px;
}

.ecs-voice-summary-body {
    font-size: 14px;
    font-weight: 400;
    color: #555555;
    line-height: 1.5;
    margin: 0 0 16px;
}

/* Actions slot — empty in Phase 02C; Phase 4 populates with redirect links */
#ecs-voice-actions-slot {
    /* intentionally empty */
}

.ecs-voice-summary-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Call Again button — same style as Start Call */
#ecs-voice-btn-call-again {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: #0073aa;
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    cursor: pointer;
    min-height: 44px;
    transition: background-color 0.15s ease;
}

#ecs-voice-btn-call-again:hover {
    background: #005a87;
}

#ecs-voice-btn-call-again:active {
    transform: scale(0.97);
}

/* Close button */
#ecs-voice-btn-close {
    background: transparent;
    border: 1px solid #dddddd;
    color: #333333;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    min-height: 44px;
    font-size: 14px;
    font-weight: 400;
    transition: border-color 0.15s ease;
}

#ecs-voice-btn-close:hover {
    border-color: #999999;
}

/* Audio container — hidden from view but present for LiveKit audio elements */
#ecs-voice-audio-container[hidden] {
    display: none !important;
}

/* ==========================================================================
   Animations
   ========================================================================== */

/* FAB entrance on page load */
@keyframes ecs-voice-fab-entrance {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

/* Processing indicator dot pulse */
@keyframes ecs-voice-pulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   Reduced motion — respect user OS preference
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    #ecs-voice-fab,
    .ecs-voice-processing span,
    .ecs-voice-modal-inner {
        animation: none !important;
        transition: none !important;
    }

    /* Ensure inner modal is always visible (no fade-in when animations disabled) */
    .ecs-voice-modal-inner {
        opacity: 1 !important;
        transform: scale(1) !important;
    }
}
