/* Story Voice Controls - Floating UI Styling */
/* Optimized for user positioning preferences and context-aware design */

/* Main floating controls container */
.story-voice-floating-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Container for all voice controls */
.story-voice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 60px;
}

/* Main voice button */
.story-voice-main-button {
    position: relative;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.story-voice-main-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.story-voice-main-button:active {
    transform: scale(0.95);
}

/* Voice icon */
.story-voice-main-button .voice-icon {
    fill: white;
    width: 28px;
    height: 28px;
}

/* Voice pulse animation */
.voice-pulse {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid #667eea;
    opacity: 0;
    animation: none;
}

.story-voice-main-button.listening .voice-pulse {
    animation: voicePulse 2s ease-in-out infinite;
}

@keyframes voicePulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Dictation indicator */
.dictation-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #ff4757;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.story-voice-main-button.dictating .dictation-indicator {
    opacity: 1;
    animation: dictationBlink 1s ease-in-out infinite alternate;
}

@keyframes dictationBlink {
    0% { opacity: 1; }
    100% { opacity: 0.3; }
}

/* Positioning controls */
.story-voice-positioning {
    display: flex;
    gap: 4px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.story-voice-container:hover .story-voice-positioning,
.story-voice-container:focus-within .story-voice-positioning {
    opacity: 1;
    transform: translateY(0);
}

.position-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.position-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

/* Context selector */
.story-voice-context {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
    min-width: 120px;
}

.story-voice-container:hover .story-voice-context,
.story-voice-container:focus-within .story-voice-context {
    opacity: 1;
    transform: translateY(0);
}

.story-voice-context select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    backdrop-filter: blur(5px);
}

/* Quick actions */
.story-voice-quick-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.story-voice-container:hover .story-voice-quick-actions,
.story-voice-container:focus-within .story-voice-quick-actions {
    opacity: 1;
    transform: translateY(0);
}

.quick-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.quick-action-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.quick-action-btn:active {
    transform: scale(0.95);
}

/* Bottom controls bar */
.story-voice-bottom-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: 12px 20px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
}

.story-voice-bottom-controls.active {
    transform: translateY(0);
}

/* Voice status bar */
.voice-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.dictation-status {
    font-weight: 600;
    color: #2c3e50;
}

.dictation-status.active {
    color: #e74c3c;
}

.context-indicator {
    background: #3498db;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.context-indicator.personal { background: #9b59b6; }
.context-indicator.work { background: #34495e; }
.context-indicator.parenting { background: #e67e22; }
.context-indicator.networking { background: #2ecc71; }

.word-count {
    font-size: 12px;
    color: #7f8c8d;
}

/* Voice transcript display */
.voice-transcript-display {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    padding: 12px;
    min-height: 60px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 14px;
    line-height: 1.4;
    color: #2c3e50;
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 8px;
}

.voice-transcript-display:empty::before {
    content: "Your dictated text will appear here...";
    color: #95a5a6;
    font-style: italic;
}

/* Voice command hints */
.voice-command-hints {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #7f8c8d;
}

.hint {
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
}

/* Side panel for side-by-side mode */
.story-voice-side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 9997;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.side-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.02);
}

.side-panel-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.close-side-panel {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #7f8c8d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-side-panel:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2c3e50;
}

.side-panel-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.context-selector label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #2c3e50;
}

.dictation-controls .btn {
    font-size: 14px;
    font-weight: 500;
    padding: 10px;
}

.voice-transcript-live {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    padding: 12px;
    min-height: 80px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-suggestions h6,
.writing-stats h6 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
}

.suggestions-content {
    background: rgba(52, 152, 219, 0.05);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(52, 152, 219, 0.1);
    font-size: 13px;
    line-height: 1.4;
}

.stats-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
}

.stats-content div {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Context-aware styling */
.story-voice-container.personal {
    background: rgba(155, 89, 182, 0.95);
}

.story-voice-container.work {
    background: rgba(52, 73, 94, 0.95);
}

.story-voice-container.parenting {
    background: rgba(230, 126, 34, 0.95);
}

.story-voice-container.networking {
    background: rgba(46, 204, 113, 0.95);
}

/* Responsive design */
@media (max-width: 768px) {
    .story-voice-floating-controls {
        bottom: 80px; /* Avoid mobile keyboards */
        right: 16px;
    }
    
    .story-voice-side-panel {
        width: 100%;
        left: 0;
        right: 0;
    }
    
    .story-voice-bottom-controls {
        padding: 12px 16px;
    }
    
    .voice-status-bar {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }
    
    .voice-command-hints {
        flex-direction: column;
        gap: 4px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .story-voice-floating-controls,
    .story-voice-container,
    .position-btn,
    .quick-action-btn,
    .story-voice-bottom-controls,
    .story-voice-side-panel {
        transition: none;
        animation: none;
    }
    
    .voice-pulse,
    .dictation-indicator {
        animation: none;
    }
}

@media (prefers-high-contrast: high) {
    .story-voice-container {
        background: white;
        border: 2px solid black;
    }
    
    .story-voice-main-button {
        background: black;
        border: 2px solid white;
    }
    
    .position-btn,
    .quick-action-btn {
        background: white;
        border: 1px solid black;
    }
}

/* Focus indicators for keyboard navigation */
.story-voice-main-button:focus,
.position-btn:focus,
.quick-action-btn:focus,
.close-side-panel:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .story-voice-floating-controls,
    .story-voice-bottom-controls,
    .story-voice-side-panel {
        display: none !important;
    }
}