/* Enhanced Recording Modal Styles */
.modal {
    position: fixed;
    inset: 0;                  /* force full-screen overlay regardless of parent */
    background: rgba(0, 0, 0, 0);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.modal.show {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
}

.recording-modal-content {
    position: fixed;           /* center relative to viewport */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-card);
    border-radius: 1.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 36rem; /* wider card */
    margin: 0;                 /* no outer margin to avoid drift */
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal.show .recording-modal-content {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Recording Screen */
.recording-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    width: 100%;
}

.recording-visualizer-container {
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.audio-visualizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0.7;
}

.recording-status-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    pointer-events: none;
}

.recording-status {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.recording-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    font-family: 'Courier New', monospace;
}

.recording-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.recording-btn {
    padding: 1rem 2rem;
    border-radius: 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 140px;
    justify-content: center;
}

.recording-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), #3b82f6);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #2563eb);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

/* Preview Screen */
.preview-screen {
    display: flex;
    flex-direction: column;
    align-items: center; /* center inner blocks */
    gap: 2rem;
    width: 100%;
}

.audio-preview-header h3 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 0.2px;
}

/* Custom Audio Player */
.custom-audio-player {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.04));
    border-radius: 1.25rem;
    padding: 1.75rem;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 560px; /* contain width */
    margin: 0 auto;   /* center */
    box-shadow: 0 16px 32px rgba(0,0,0,0.25);
    backdrop-filter: blur(4px);
}

.audio-player-controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: center; /* horizontal center for flex children */
    justify-content: center; /* ensure full block centering */
    text-align: center; /* center inline content */
}

.play-pause-btn {
    width: 82px;
    height: 82px;
    border-radius: 50%;
    background: radial-gradient(ellipse at 30% 30%, #60a5fa 0%, #2563eb 70%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    transition: all 0.3s ease;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.35);
}

.play-pause-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 16px 28px rgba(37, 99, 235, 0.45);
}

.audio-info {
    display: flex;
    gap: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    justify-content: center; /* center timestamps */
}

.progress-container {
    width: 100%;
    max-width: 440px;
    margin: 0 auto; /* center progress bar */
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: linear-gradient(180deg, var(--bg-primary), rgba(255,255,255,0.03));
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s ease;
}

.speed-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center; /* center speed controls */
}

.speed-controls label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.speed-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.speed-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.9rem 1.6rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 640px) {
    .recording-modal-content {
        margin: 0.5rem;
        padding: 1.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .recording-visualizer-container {
        width: 160px;
        height: 160px;
    }
    
    .recording-timer {
        font-size: 1.25rem;
    }
    
    .recording-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .recording-btn {
        width: 100%;
        min-width: auto;
    }
    
    .preview-actions {
        flex-direction: column;
    }
    
    .audio-player-controls {
        gap: 0.75rem;
    }
    
    .play-pause-btn {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
}

/* Animation for recording state */
@keyframes recordingPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% { 
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

.recording-visualizer-container.recording {
    animation: recordingPulse 2s infinite;
    border-color: #ef4444;
}

.recording-visualizer-container.paused {
    border-color: #f59e0b;
}