/* ===========================================
   C4-AI - Media Upload & Voice Recorder
   =========================================== */

/* Media Section Container */
.media-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--content-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.media-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.media-section-title svg {
    width: 18px;
    height: 18px;
    stroke: var(--primary);
    fill: none;
    stroke-width: 2;
}

/* Tab Selector */
.media-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--card-bg);
    padding: 4px;
    border-radius: 10px;
}

.media-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-family);
}

.media-tab svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.media-tab:hover {
    color: var(--text-secondary);
}

.media-tab.active {
    background: var(--primary);
    color: white;
}

/* Tab Content */
.media-tab-content {
    display: none;
}

.media-tab-content.active {
    display: block;
}

/* URL Input */
.media-url-input {
    display: flex;
    gap: 8px;
}

.media-url-input input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-family: var(--font-family);
    background: var(--card-bg);
    color: var(--text-dark);
    direction: ltr;
    text-align: left;
}

.media-url-input input:focus {
    outline: none;
    border-color: var(--primary);
}

/* File Upload Area */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.file-upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.02);
}

.file-upload-area.dragging {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.file-upload-area.has-file {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.file-upload-area input {
    display: none;
}

.file-upload-area .upload-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    background: var(--content-bg);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-upload-area .upload-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--primary);
    fill: none;
    stroke-width: 2;
}

.file-upload-area h4 {
    font-size: 15px;
    color: var(--text-dark);
    margin: 0 0 4px;
}

.file-upload-area p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* Uploaded File Preview */
.uploaded-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.uploaded-file-preview .file-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--content-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.uploaded-file-preview .file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.uploaded-file-preview .file-thumb svg {
    width: 24px;
    height: 24px;
    stroke: var(--primary);
    fill: none;
    stroke-width: 2;
}

.uploaded-file-preview .file-details {
    flex: 1;
    min-width: 0;
}

.uploaded-file-preview .file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uploaded-file-preview .file-size {
    font-size: 12px;
    color: var(--text-muted);
}

.uploaded-file-preview .remove-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    color: var(--danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.uploaded-file-preview .remove-btn:hover {
    background: var(--danger);
    color: white;
}

.uploaded-file-preview .remove-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Voice Recorder */
.voice-recorder {
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-align: center;
}

.recorder-status {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.recorder-status.recording {
    color: var(--danger);
}

.recorder-status.paused {
    color: var(--warning);
}

/* Timer Display */
.recorder-timer {
    font-size: 32px;
    font-weight: 700;
    font-family: 'Vazirmatn', monospace;
    color: var(--text-dark);
    margin-bottom: 20px;
    letter-spacing: 2px;
}

/* Waveform Visualization */
.recorder-waveform {
    height: 48px;
    margin-bottom: 20px;
    background: var(--content-bg);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0 12px;
}

.wave-bar {
    width: 3px;
    background: var(--primary);
    border-radius: 2px;
    transition: height 0.1s;
}

.recorder-waveform.recording .wave-bar {
    animation: wave 0.5s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% { height: 8px; }
    50% { height: 32px; }
}

.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }
.wave-bar:nth-child(6) { animation-delay: 0.15s; }
.wave-bar:nth-child(7) { animation-delay: 0.25s; }
.wave-bar:nth-child(8) { animation-delay: 0.35s; }
.wave-bar:nth-child(9) { animation-delay: 0.05s; }
.wave-bar:nth-child(10) { animation-delay: 0.45s; }

/* Recorder Controls */
.recorder-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.recorder-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.recorder-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.recorder-btn.record {
    background: var(--danger);
    color: white;
    width: 64px;
    height: 64px;
}

.recorder-btn.record:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.recorder-btn.record.recording {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.recorder-btn.pause {
    background: var(--warning);
    color: white;
}

.recorder-btn.pause:hover {
    background: #e5a000;
}

.recorder-btn.stop {
    background: var(--content-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.recorder-btn.stop:hover {
    background: var(--border-color);
}

.recorder-btn.save {
    background: var(--success);
    color: white;
}

.recorder-btn.save:hover {
    background: #059669;
}

.recorder-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Recorded Audio Preview */
.recorded-audio-preview {
    margin-top: 16px;
    padding: 12px;
    background: var(--content-bg);
    border-radius: 10px;
}

.recorded-audio-preview audio {
    width: 100%;
    height: 40px;
}

.recorded-audio-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.recorded-audio-actions button {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.recorded-audio-actions button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.recorded-audio-actions .use-btn {
    background: var(--primary);
    color: white;
}

.recorded-audio-actions .use-btn:hover {
    background: #4f46e5;
}

.recorded-audio-actions .discard-btn {
    background: var(--content-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.recorded-audio-actions .discard-btn:hover {
    background: var(--border-color);
}

/* Upload Progress */
.upload-progress {
    margin-top: 12px;
}

.progress-bar {
    height: 6px;
    background: var(--content-bg);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Loading State */
.media-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
}

.media-loading .loader {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.media-loading p {
    font-size: 14px;
    color: var(--text-muted);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 480px) {
    .media-tabs {
        flex-direction: column;
    }
    
    .recorder-controls {
        flex-wrap: wrap;
    }
}
