/**
 * BistroBot Push-to-Talk Button Styles
 * Styles for the push-to-talk button interface
 */

/* Push-to-Talk System - Uses CSS variables for positioning and sizing */
.ptt-container {
    display: none; /* Hidden by default until call starts */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    position: fixed;
    bottom: var(--layout-footer-height); /* Above footer only - prompt is now above PTT */
    left: 0;
    right: 0;
    height: var(--layout-ptt-height); /* PTT button height */
    z-index: 10000;
    width: 100%;
    pointer-events: none;
}

/* Translucent background bar fills the entire PTT container space */
.ptt-background-bar {
    background: transparent; /* Transparent - no visible background */
    backdrop-filter: none;
    /* Removed border-top to eliminate horizontal lines extending beyond button */
    height: 100%; /* Fill the entire PTT container */
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* Re-enable pointer events for the bar */
}

.ptt-container.visible {
    display: block;
    opacity: 1;
}

/* Hidden text area - keeping for status updates but invisible */
.ptt-text-area {
    display: none;
}

.ptt-status {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    margin: 0;
}

/* Pill-shaped PTT Button */
.ptt-button-wrap {
    display: flex;
    justify-content: center;
    pointer-events: auto; /* Re-enable pointer events for the button */
}

.ptt-button {
    position: relative;
    width: calc(100vw - 40px);  /* Full width minus 20px margin on each side */
    max-width: 600px; /* Reasonable max width for very large screens */
    height: calc(var(--conversation-ptt-height) - var(--ptt-internal-padding));  /* Fill PTT space minus padding */
    max-height: 80px; /* Don't make it too big on large screens */
    min-height: 45px; /* Don't make it too small on small screens */
    border-radius: min(calc((var(--conversation-ptt-height) - var(--ptt-internal-padding)) / 2), 40px); /* Half of height for perfect pill shape, capped at 40px */
    background: #ffffff;
    border: none; /* No border for cleaner look */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    cursor: pointer;
    outline: none !important;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-focus-ring-color: transparent !important;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: #374151;
}

.ptt-button:active {
    transform: scale(0.96);
    outline: none !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1) !important;
}

.ptt-button:focus {
    outline: none !important;
    box-shadow: 0 12px 50px rgba(79, 123, 247, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.ptt-button:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 15px 60px rgba(0, 0, 0, 0.18), 0 6px 20px rgba(0, 0, 0, 0.1);
    outline: none !important;
}

/* Remove any browser default button styling */
.ptt-button::-moz-focus-inner {
    border: 0 !important;
    outline: none !important;
}

/* Microphone icon */
.ptt-mic-icon {
    width: 40px;  /* Larger icon for taller button */
    height: 40px;
    color: #6b7280;
    transition: color 0.15s ease, transform 0.12s ease;
    flex-shrink: 0; /* Don't shrink the icon */
}

/* Hold to Talk text */
.ptt-text {
    white-space: nowrap;
    flex-shrink: 0; /* Don't shrink the text */
}

/* Active/Listening state */
.ptt-button.listening::before,
.ptt-button.listening::after {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: inherit;
    border: 2px solid rgba(79, 123, 247, 0.35);
    animation: ptt-ripple 1.7s ease-out infinite;
    pointer-events: none;
}

.ptt-button.listening::after {
    animation-delay: 0.65s;
}

.ptt-button.listening {
    border-color: rgba(79, 123, 247, 0.9);
    box-shadow: 0 0 0 4px rgba(79, 123, 247, 0.18),
                0 8px 30px rgba(79, 123, 247, 0.35);
    background: linear-gradient(90deg, rgba(79, 123, 247, 0.1), rgba(79, 123, 247, 0.05)), #ffffff;
}

.ptt-button.listening .ptt-mic-icon {
    color: #4F7BF7;
    filter: drop-shadow(0 4px 12px rgba(79, 123, 247, 0.55));
    transform: scale(1.1);
}

.ptt-button.listening .ptt-text {
    color: #4F7BF7;
}

@keyframes ptt-ripple {
    0% { transform: scale(1); opacity: 0.9; }
    70% { opacity: 0.25; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* Hide original widget controls during active call */
elevenlabs-convai button[aria-label="Mute microphone"] {
    display: none !important;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .ptt-button {
        width: calc(100vw - 30px);  /* Full width minus 15px margin on each side */
        height: 150px;  /* Bigger button for easier tapping */
        border-radius: 75px;  /* Half of height for perfect pill shape */
        font-size: 18px;
        gap: 15px;
    }
    
    .ptt-mic-icon {
        width: 50px;  /* 1.8x larger (28 * 1.8 ≈ 50) */
        height: 50px;
    }
    
    .ptt-text {
        font-size: 20px;  /* 1.8x larger (11 * 1.8 ≈ 20) */
    }
    
    /* Increase ripple for larger button */
    .ptt-button.listening::before,
    .ptt-button.listening::after {
        inset: -12px;
    }
    
    @keyframes ptt-ripple {
        0% { transform: scale(1); opacity: 0.9; }
        70% { opacity: 0.25; }
        100% { transform: scale(1.5); opacity: 0; }
    }
}

/* Extremely small mobile screens */
@media (max-width: 400px) {
    .ptt-button {
        width: calc(100vw - 24px);  /* Even less margin on tiny screens */
        font-size: 16px;
    }
}