/**
 * Voice Messages Styles
 * أنماط الرسائل الصوتية
 *
 * @package Smart_Hospital
 */

/* ========================================
   Voice Record Button (FAB) - Twitter Style
======================================== */
.voice-record-fab {
    position: fixed;
    bottom: calc(var(--nav-height, 70px) + 16px);
    right: 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.voice-record-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e63946 0%, #d62839 100%);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.voice-record-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(230, 57, 70, 0.5);
}

.voice-record-btn:active {
    transform: scale(0.95);
}

.voice-record-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.voice-record-btn .mic-icon {
    display: block;
}

.voice-record-btn .stop-icon {
    display: none;
}

.voice-record-btn.recording {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    box-shadow: 0 4px 20px rgba(46, 204, 113, 0.4);
    animation: pulse-recording 1.5s ease-in-out infinite;
}

.voice-record-btn.recording .mic-icon {
    display: none;
}

.voice-record-btn.recording .stop-icon {
    display: block;
}

@keyframes pulse-recording {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(46, 204, 113, 0.4);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 6px 30px rgba(46, 204, 113, 0.6);
    }
}

/* Hide label by default - Twitter style */
.voice-record-label {
    display: none;
}

/* ========================================
   Recording Modal
======================================== */
.voice-recording-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.voice-recording-modal.active {
    display: flex;
}

.voice-modal-content {
    background: white;
    border-radius: 24px;
    width: 100%;
    max-width: 360px;
    padding: 32px 24px;
    text-align: center;
    animation: slideUp 0.3s ease;
}

/* Recording Visualizer */
.voice-visualizer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 80px;
    margin: 20px 0;
}

.voice-visualizer .bar {
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, #e63946 0%, #d62839 100%);
    border-radius: 2px;
    animation: soundBar 0.5s ease-in-out infinite alternate;
}

.voice-modal-content.recording .voice-visualizer .bar {
    background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
}

.voice-visualizer .bar:nth-child(1) { animation-delay: 0s; height: 30px; }
.voice-visualizer .bar:nth-child(2) { animation-delay: 0.1s; height: 50px; }
.voice-visualizer .bar:nth-child(3) { animation-delay: 0.2s; height: 70px; }
.voice-visualizer .bar:nth-child(4) { animation-delay: 0.3s; height: 50px; }
.voice-visualizer .bar:nth-child(5) { animation-delay: 0.4s; height: 30px; }
.voice-visualizer .bar:nth-child(6) { animation-delay: 0.3s; height: 50px; }
.voice-visualizer .bar:nth-child(7) { animation-delay: 0.2s; height: 70px; }
.voice-visualizer .bar:nth-child(8) { animation-delay: 0.1s; height: 50px; }
.voice-visualizer .bar:nth-child(9) { animation-delay: 0s; height: 30px; }

@keyframes soundBar {
    from {
        transform: scaleY(0.3);
    }
    to {
        transform: scaleY(1);
    }
}

/* Static visualizer when not recording */
.voice-modal-content:not(.recording) .voice-visualizer .bar {
    animation: none;
    opacity: 0.3;
}

/* Timer Display */
.voice-timer {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--dark);
    font-variant-numeric: tabular-nums;
    margin-bottom: 8px;
}

.voice-status {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 24px;
}

.voice-modal-content.recording .voice-status {
    color: #2ecc71;
}

/* Modal Actions */
.voice-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.voice-modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.voice-modal-btn svg {
    width: 20px;
    height: 20px;
}

.voice-btn-cancel {
    background: var(--light);
    color: var(--gray);
}

.voice-btn-cancel:hover {
    background: #e0e0e0;
}

.voice-btn-send {
    background: linear-gradient(135deg, #0077b6 0%, #005a8c 100%);
    color: white;
}

.voice-btn-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 119, 182, 0.3);
}

.voice-btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.voice-btn-record {
    background: linear-gradient(135deg, #e63946 0%, #d62839 100%);
    color: white;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 0;
}

.voice-btn-record:hover {
    transform: scale(1.05);
}

.voice-btn-record.recording {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

/* Preview Section */
.voice-preview-section {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--light);
}

.voice-preview-section.active {
    display: block;
}

.voice-preview-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--light);
    border-radius: 12px;
    margin-bottom: 16px;
}

.voice-preview-play {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.voice-preview-play svg {
    width: 20px;
    height: 20px;
}

.voice-preview-waveform {
    flex: 1;
    height: 32px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.voice-preview-waveform .wave-bar {
    width: 3px;
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    opacity: 0.3;
}

.voice-preview-waveform .wave-bar.active {
    opacity: 1;
}

.voice-preview-duration {
    font-size: 0.85rem;
    color: var(--gray);
    font-variant-numeric: tabular-nums;
    min-width: 45px;
    text-align: left;
}

/* Priority Selector */
.voice-priority-section {
    margin-top: 16px;
}

.voice-priority-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 8px;
    display: block;
    text-align: right;
}

.voice-priority-options {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.voice-priority-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    background: var(--light);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.voice-priority-option input {
    display: none;
}

.voice-priority-option .priority-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.voice-priority-option.normal .priority-dot { background: #0077b6; }
.voice-priority-option.high .priority-dot { background: #f39c12; }
.voice-priority-option.urgent .priority-dot { background: #e63946; }

.voice-priority-option:has(input:checked) {
    background: var(--primary);
    color: white;
}

.voice-priority-option:has(input:checked) .priority-dot {
    background: white;
}

/* ========================================
   Voice Message Player (in message list)
======================================== */
.voice-message-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(0, 119, 182, 0.08);
    border-radius: 12px;
    margin-top: 10px;
}

.voice-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.voice-play-btn:hover {
    transform: scale(1.05);
    background: #005a8c;
}

.voice-play-btn svg {
    width: 18px;
    height: 18px;
}

.voice-waveform {
    flex: 1;
    height: 32px;
    display: flex;
    align-items: center;
}

.voice-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 119, 182, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.voice-progress {
    width: 0%;
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.voice-duration {
    font-size: 0.8rem;
    color: var(--gray);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
}

/* Playing state */
.voice-message-player.playing .voice-play-btn {
    background: #e63946;
}

.voice-message-player.playing .play-icon {
    display: none;
}

.voice-message-player.playing .pause-icon {
    display: block;
}

/* ========================================
   Message Type Badge
======================================== */
.message-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(230, 57, 70, 0.1);
    color: #e63946;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.message-type-badge svg {
    width: 14px;
    height: 14px;
}

/* ========================================
   Toast Notification
======================================== */
.voice-toast {
    position: fixed;
    bottom: calc(var(--nav-height, 70px) + 80px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--dark);
    color: white;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1002;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.voice-toast.success {
    background: #2ecc71;
}

.voice-toast.error {
    background: #e63946;
}

.voice-toast svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Sending State
======================================== */
.voice-sending-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    border-radius: 24px;
}

.voice-sending-overlay.active {
    display: flex;
}

.voice-sending-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========================================
   Responsive
======================================== */
@media (max-width: 400px) {
    .voice-modal-content {
        padding: 24px 16px;
    }
    
    .voice-timer {
        font-size: 2rem;
    }
    
    .voice-modal-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    
    .voice-priority-options {
        flex-wrap: wrap;
    }
}

/* Safe area for iPhone notch */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .voice-record-fab {
        bottom: calc(var(--nav-height, 70px) + env(safe-area-inset-bottom) + 16px);
    }
}

/* RTL Support - للعربية الزر على اليسار */
[dir="rtl"] .voice-record-fab,
.rtl .voice-record-fab {
    right: auto;
    left: 20px;
}
