/**
 * WebRTC Phone Styles
 * أنماط نظام الهاتف عبر المتصفح
 */

/* ============================================
   Popup Base Styles
   ============================================ */
.webrtc-popup {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.3s ease;
}

.webrtc-popup.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ============================================
   Incoming Call Popup
   ============================================ */
.webrtc-popup.incoming-call {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 380px;
    max-width: 95vw;
}

.webrtc-popup.incoming-call.show {
    transform: translate(-50%, -50%) scale(1);
}

.webrtc-popup .popup-content {
    padding: 24px;
    text-align: center;
}

.webrtc-popup .popup-header {
    margin-bottom: 20px;
}

.webrtc-popup .popup-header h5 {
    margin: 10px 0 0;
    color: #333;
    font-weight: 600;
}

.webrtc-popup .popup-body {
    margin-bottom: 24px;
}

.webrtc-popup .caller-avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: #fff;
}

.webrtc-popup .caller-info h4 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.webrtc-popup .caller-info p {
    margin: 0;
    color: #666;
    font-size: 1.1rem;
    direction: ltr;
}

.webrtc-popup .popup-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.webrtc-popup .popup-actions .btn {
    flex: 1;
    max-width: 140px;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 50px;
}

.webrtc-popup .popup-actions .btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
}

.webrtc-popup .popup-actions .btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e83e8c 100%);
    border: none;
}

/* ============================================
   Active Call Popup
   ============================================ */
.webrtc-popup.active-call {
    top: 20px;
    right: 20px;
    left: auto;
    width: 300px;
    transform: translateY(-20px);
}

html[dir="rtl"] .webrtc-popup.active-call {
    right: auto;
    left: 20px;
}

.webrtc-popup.active-call.show {
    transform: translateY(0);
}

.webrtc-popup.active-call .popup-content {
    padding: 16px;
}

.webrtc-popup.active-call .popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.webrtc-popup.active-call .popup-header i {
    font-size: 1.2rem;
}

.webrtc-popup.active-call #call-status {
    flex: 1;
    font-weight: 500;
}

.webrtc-popup.active-call #call-timer {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #28a745;
}

.webrtc-popup.active-call .popup-body.compact {
    margin-bottom: 12px;
}

.webrtc-popup.active-call .caller-info-small {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    direction: ltr;
}

.webrtc-popup.active-call .popup-actions.compact {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.webrtc-popup.active-call .popup-actions .btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.webrtc-popup.active-call .popup-actions .btn-danger {
    width: auto;
    padding: 0 16px;
    border-radius: 20px;
}

/* ============================================
   Customer Data Card
   ============================================ */
.webrtc-popup .customer-data {
    margin-top: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: right;
}

.webrtc-popup .customer-card {
    text-align: right;
}

.webrtc-popup .customer-type {
    margin-bottom: 8px;
}

.webrtc-popup .customer-details p {
    margin: 4px 0;
    font-size: 0.9rem;
}

.webrtc-popup .customer-actions {
    margin-top: 12px;
    text-align: center;
}

/* ============================================
   Status Indicator
   ============================================ */
.webrtc-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
}

html[dir="rtl"] .webrtc-status {
    margin-left: 0;
    margin-right: 8px;
}

.webrtc-status.online {
    background: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.2);
}

.webrtc-status.offline {
    background: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

.webrtc-status.busy {
    background: #ffc107;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.2);
}

/* ============================================
   Phone Widget (Mini)
   ============================================ */
.webrtc-phone-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
}

html[dir="rtl"] .webrtc-phone-widget {
    right: auto;
    left: 20px;
}

.webrtc-phone-widget .phone-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.webrtc-phone-widget .phone-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.webrtc-phone-widget .phone-btn.online {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}

.webrtc-phone-widget .phone-btn.offline {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4);
}

.webrtc-phone-widget .status-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.webrtc-phone-widget .status-dot.online {
    background: #28a745;
}

.webrtc-phone-widget .status-dot.offline {
    background: #dc3545;
}

/* ============================================
   Dialpad Modal
   ============================================ */
.dialpad-modal .dialpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 250px;
    margin: 0 auto;
}

.dialpad-modal .dialpad-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: #fff;
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dialpad-modal .dialpad-btn:hover {
    background: #f8f9fa;
    border-color: #667eea;
}

.dialpad-modal .dialpad-btn:active {
    background: #667eea;
    color: #fff;
}

.dialpad-modal .dialpad-btn small {
    display: block;
    font-size: 0.6rem;
    color: #999;
    letter-spacing: 1px;
}

/* ============================================
   Pulse Animation
   ============================================ */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.pulse-animation {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================
   Ring Animation
   ============================================ */
@keyframes ring {
    0% {
        transform: rotate(0);
    }
    10% {
        transform: rotate(15deg);
    }
    20% {
        transform: rotate(-15deg);
    }
    30% {
        transform: rotate(15deg);
    }
    40% {
        transform: rotate(-15deg);
    }
    50% {
        transform: rotate(0);
    }
    100% {
        transform: rotate(0);
    }
}

.ring-animation {
    animation: ring 1s ease-in-out infinite;
}

/* ============================================
   Dark Mode Support
   ============================================ */
.dark-mode .webrtc-popup {
    background: #2d3748;
    color: #e2e8f0;
}

.dark-mode .webrtc-popup .popup-header h5,
.dark-mode .webrtc-popup .caller-info h4 {
    color: #e2e8f0;
}

.dark-mode .webrtc-popup .caller-info p {
    color: #a0aec0;
}

.dark-mode .webrtc-popup.active-call .popup-header {
    border-bottom-color: #4a5568;
}

.dark-mode .webrtc-popup .customer-data {
    background: #1a202c;
}

.dark-mode .dialpad-modal .dialpad-btn {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

.dark-mode .dialpad-modal .dialpad-btn:hover {
    background: #4a5568;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 576px) {
    .webrtc-popup.incoming-call {
        width: 95vw;
        border-radius: 12px;
    }
    
    .webrtc-popup.active-call {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
    }
    
    html[dir="rtl"] .webrtc-popup.active-call {
        right: 20px;
        left: 20px;
    }
    
    .webrtc-phone-widget {
        bottom: 80px;
    }
}
