/**
 * AWKE Voice Input Styles
 * Beautiful UI for speech-to-text functionality
 * 
 * @package Advanced_Widget_Kit
 * @since 2.3.0
 */

/* ==========================================================================
   Voice Field Wrapper
   ========================================================================== */

.awke-voice-field-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* ==========================================================================
   Voice Button
   ========================================================================== */

.awke-voice-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff;
    border: 2px solid #ddd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    padding: 0;
    outline: none;
}

.awke-voice-btn:hover {
    background: #f8f9fa;
    border-color: #667eea;
    transform: translateY(-50%) scale(1.1);
}

.awke-voice-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Mic Icon */
.awke-mic-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    transition: all 0.3s ease;
}

.awke-voice-btn:hover .awke-mic-icon {
    color: #5568d3;
}

/* Stop Icon */
.awke-stop-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: all 0.3s ease;
    animation: stopPulse 1s ease-in-out infinite;
}

@keyframes stopPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Voice Status Text (hidden by default, shown on hover for accessibility) */
.awke-voice-status {
    position: absolute;
    right: 45px;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.awke-voice-btn:hover .awke-voice-status {
    opacity: 1;
}

/* Tooltip arrow */
.awke-voice-status::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid #333;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

/* ==========================================================================
   Listening State
   ========================================================================== */

.awke-voice-btn.awke-listening {
    background: #ef4444;
    border-color: #dc2626;
    animation: pulse 1.5s ease-in-out infinite;
}

.awke-voice-btn.awke-listening .awke-mic-icon {
    color: #ffffff;
}

.awke-voice-btn.awke-listening .awke-stop-icon {
    color: #ffffff;
}

.awke-voice-btn.awke-listening:hover {
    background: #dc2626;
    border-color: #b91c1c;
}

.awke-voice-btn.awke-listening:hover .awke-stop-icon {
    animation: stopPulse 0.5s ease-in-out infinite;
}

/* Pulse animation */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Active field indicator */
.awke-voice-active {
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

/* ==========================================================================
   Error State
   ========================================================================== */

.awke-voice-btn.awke-error {
    background: #fee;
    border-color: #fcc;
    animation: shake 0.5s;
}

.awke-voice-btn.awke-error .awke-mic-icon {
    color: #dc2626;
}

/* Shake animation */
@keyframes shake {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateY(-50%) translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateY(-50%) translateX(5px); }
}

/* Error tooltip */
.awke-voice-error {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #dc2626;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.awke-voice-error::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #dc2626;
}

/* ==========================================================================
   Textarea Support
   ========================================================================== */

/* For textarea, position button at top right */
.awke-voice-field-wrapper textarea + .awke-voice-btn {
    top: 15px;
    transform: none;
}

.awke-voice-field-wrapper textarea + .awke-voice-btn.awke-listening {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .awke-voice-btn {
        width: 36px;
        height: 36px;
    }
    
    .awke-mic-icon svg {
        width: 14px;
        height: 14px;
    }
    
    .awke-voice-status {
        right: 40px;
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .awke-voice-lang-btn {
        right: 45px;
        height: 28px;
        padding: 0 8px;
    }
    
    .awke-lang-selector {
        width: 280px;
        max-height: 320px;
    }
    
    .awke-lang-selector-list {
        max-height: 200px;
    }
    
    .awke-lang-notification {
        bottom: 20px;
        right: 20px;
        max-width: 250px;
        padding: 12px 15px;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .awke-voice-btn {
        background: #1f2937;
        border-color: #374151;
    }
    
    .awke-voice-btn:hover {
        background: #111827;
        border-color: #667eea;
    }
    
    .awke-voice-status {
        background: #1f2937;
        border-color: #374151;
    }
    
    .awke-voice-status::after {
        border-left-color: #1f2937;
    }
    
    .awke-voice-lang-btn {
        background: #1f2937;
        border-color: #374151;
    }
    
    .awke-voice-lang-btn:hover {
        background: #111827;
        border-color: #667eea;
    }
    
    .awke-lang-selector {
        background: #1f2937;
        border-color: #374151;
    }
    
    .awke-lang-selector-header {
        background: #111827;
        border-bottom-color: #374151;
    }
    
    .awke-lang-selector-title {
        color: #f9fafb;
    }
    
    .awke-lang-selector-search {
        background: #1f2937;
        border-bottom-color: #374151;
    }
    
    .awke-lang-search-input {
        background: #111827;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .awke-lang-item:hover {
        background: #374151;
    }
    
    .awke-lang-item.active {
        background: #312e81;
    }
    
    .awke-lang-item.active:hover {
        background: #3730a3;
    }
    
    .awke-lang-name {
        color: #f9fafb;
    }
    
    .awke-lang-notification {
        background: #1f2937;
        border-color: #374151;
    }
    
    .awke-lang-notification-text {
        color: #f9fafb;
    }
    
    /* Dark Mode Scrollbar */
    .awke-lang-selector-list::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #818cf8 0%, #8b5cf6 100%);
    }
    
    .awke-lang-selector-list::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(180deg, #6366f1 0%, #7c3aed 100%);
    }
    
    .awke-lang-selector-list {
        scrollbar-color: #818cf8 transparent;
    }
    
    /* Dark Mode Fade Effect */
    .awke-lang-selector::after {
        background: linear-gradient(to bottom, transparent, #1f2937);
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.awke-voice-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Screen reader text */
.awke-voice-btn .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==========================================================================
   Language Selector Button
   ========================================================================== */

.awke-voice-lang-btn {
    position: absolute;
    right: 55px;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff;
    border: 2px solid #ddd;
    border-radius: 20px;
    height: 32px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    outline: none;
    font-size: 12px;
    font-weight: 600;
}

.awke-voice-lang-btn:hover {
    background: #f8f9fa;
    border-color: #667eea;
    transform: translateY(-50%) scale(1.05);
}

.awke-voice-lang-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.awke-lang-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    transition: color 0.3s ease;
}

.awke-lang-code {
    color: #667eea;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.awke-voice-lang-btn:hover .awke-lang-icon,
.awke-voice-lang-btn:hover .awke-lang-code {
    color: #5568d3;
}

/* For textarea, position language button at top */
.awke-voice-field-wrapper textarea + .awke-voice-btn + .awke-voice-lang-btn {
    top: 15px;
    transform: none;
}

/* ==========================================================================
   Language Selector Dropdown
   ========================================================================== */

.awke-lang-selector {
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    width: 300px;
    max-height: 380px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

.awke-lang-selector.awke-lang-selector-above {
    top: auto;
    bottom: calc(100% + 5px);
    animation: slideUp 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Selector Header */
.awke-lang-selector-header {
    padding: 15px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.awke-lang-selector-title {
    font-weight: 600;
    color: #111827;
    font-size: 14px;
}

.awke-lang-selector-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.awke-lang-selector-close:hover {
    background: #e5e7eb;
    color: #111827;
}

/* Search Box */
.awke-lang-selector-search {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
}

.awke-lang-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
}

.awke-lang-search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Language List */
.awke-lang-selector-list {
    overflow-y: auto;
    max-height: 240px;
    padding: 5px 5px 25px 5px; /* Extra padding at bottom for fade effect */
    position: relative;
}

/* Fade effect at bottom to indicate more content */
.awke-lang-selector::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to bottom, transparent, #ffffff);
    pointer-events: none;
    border-radius: 0 0 12px 12px;
}

/* Custom Scrollbar - Modern Design */
.awke-lang-selector-list::-webkit-scrollbar {
    width: 6px;
}

.awke-lang-selector-list::-webkit-scrollbar-track {
    background: transparent;
    margin: 5px 0;
}

.awke-lang-selector-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.awke-lang-selector-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5568d3 0%, #6b3fa2 100%);
    width: 8px;
}

/* Firefox Scrollbar */
.awke-lang-selector-list {
    scrollbar-width: thin;
    scrollbar-color: #667eea transparent;
}

/* Language Item */
.awke-lang-item {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.awke-lang-item:hover {
    background: #f3f4f6;
}

.awke-lang-item.active {
    background: #ede9fe;
    color: #667eea;
}

.awke-lang-item.active:hover {
    background: #ddd6fe;
}

.awke-lang-name {
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.awke-lang-item.active .awke-lang-name {
    color: #667eea;
    font-weight: 600;
}

.awke-lang-check {
    color: #667eea;
    font-weight: bold;
    font-size: 16px;
}

/* ==========================================================================
   Language Change Notification
   ========================================================================== */

.awke-lang-notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10001;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    max-width: 300px;
}

.awke-lang-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.awke-lang-notification-icon {
    font-size: 24px;
    line-height: 1;
}

.awke-lang-notification-text {
    font-size: 14px;
    color: #374151;
    line-height: 1.4;
}

.awke-lang-notification-text strong {
    color: #667eea;
    font-weight: 600;
}

/* ==========================================================================
   Compatibility with Grammarly
   ========================================================================== */

/* Ensure Grammarly button doesn't overlap with voice button */
.awke-voice-field-wrapper input,
.awke-voice-field-wrapper textarea {
    padding-right: 110px !important; /* Space for both voice and language buttons */
}

/* Grammarly editor indicator */
.awke-voice-field-wrapper [data-gramm_editor="true"] {
    /* Grammarly will add its own indicator */
}

