/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2d3748;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Demo area styling */
.demo-area {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.demo-area h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 0.5rem;
}

.demo-area p {
    text-align: center;
    color: #718096;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.text-input-container {
    position: relative;
}

#textInput {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    background: #f8fafc;
    transition: all 0.3s ease;
    outline: none;
}

#textInput:focus {
    border-color: #667eea;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#textInput::placeholder {
    color: #a0aec0;
}

/* Keyboard container */
.keyboard-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.keyboard-row.bottom-row {
    margin-top: 0.5rem;
}

/* Key styling */
.key {
    background: linear-gradient(145deg, #ffffff, #f1f5f9);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 45px;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.key:hover {
    background: linear-gradient(145deg, #f8fafc, #e2e8f0);
    border-color: #cbd5e0;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.key:active,
.key.haptic-feedback {
    transform: translateY(0);
    background: linear-gradient(145deg, #e2e8f0, #cbd5e0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Special key styling */
.shift-key,
.backspace-key,
.number-key,
.return-key {
    background: linear-gradient(145deg, #f7fafc, #edf2f7);
    color: #2d3748;
    font-weight: 600;
}

.space-key {
    flex: 1;
    max-width: 200px;
    background: linear-gradient(145deg, #f7fafc, #edf2f7);
    color: #2d3748;
    font-weight: 600;
}

/* Voice button styling */
.voice-key {
    position: relative;
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    border: none;
    min-width: 60px;
    min-height: 60px;
    border-radius: 12px;
    overflow: hidden;
}

.voice-key:hover {
    background: linear-gradient(145deg, #5a67d8, #6b46c1);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.voice-key:active {
    transform: translateY(0);
}

.voice-key.recording {
    background: linear-gradient(145deg, #f56565, #e53e3e);
    animation: pulse 1.5s infinite;
}

.voice-key.processing {
    background: linear-gradient(145deg, #ed8936, #dd6b20);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 101, 101, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(245, 101, 101, 0);
    }
}

.voice-icon {
    position: relative;
    z-index: 2;
}

.recording-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    z-index: 1;
}

.voice-key.recording .recording-indicator {
    opacity: 1;
    animation: recordingPulse 1s infinite;
}

@keyframes recordingPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.7;
    }
}

.processing-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    opacity: 0;
    z-index: 1;
}

.voice-key.processing .processing-spinner {
    opacity: 1;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Status message styling */
.status-container {
    margin-top: 1rem;
    text-align: center;
}

.status-message {
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 500;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    display: inline-block;
    backdrop-filter: blur(10px);
}

.status-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.status-message.info {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.status-message.success {
    background: rgba(72, 187, 120, 0.1);
    color: #48bb78;
    border: 1px solid rgba(72, 187, 120, 0.2);
}

.status-message.error {
    background: rgba(245, 101, 101, 0.1);
    color: #f56565;
    border: 1px solid rgba(245, 101, 101, 0.2);
}

/* Waveform canvas */
.waveform-canvas {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.waveform-canvas.active {
    opacity: 0.3;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        gap: 1.5rem;
    }
    
    .demo-area {
        padding: 1.5rem;
    }
    
    .demo-area h1 {
        font-size: 2rem;
    }
    
    .keyboard-container {
        padding: 1rem;
    }
    
    .key {
        min-width: 35px;
        min-height: 35px;
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    .voice-key {
        min-width: 50px;
        min-height: 50px;
    }
    
    .keyboard-row {
        gap: 0.3rem;
    }
}

@media (max-width: 480px) {
    .demo-area h1 {
        font-size: 1.75rem;
    }
    
    .key {
        min-width: 30px;
        min-height: 30px;
        padding: 0.4rem;
        font-size: 0.8rem;
    }
    
    .voice-key {
        min-width: 45px;
        min-height: 45px;
    }
    
    .keyboard-row {
        gap: 0.25rem;
    }
}

/* Accessibility improvements */
.key:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.voice-key:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Smooth transitions for better UX */
.keyboard {
    transition: transform 0.3s ease;
}

.keyboard:hover {
    transform: translateY(-2px);
}

/* Enhanced visual feedback */
.key::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.05));
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.key:hover::before {
    opacity: 1;
}