/**
 * Twilio Voice Integration Styles for Final Expense CRM
 */

/* Connection Status Indicator */
.twilio-status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #2c3e50;
    color: white;
    padding: 8px 15px;
    font-size: 12px;
    z-index: 1000;
    text-align: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.twilio-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.twilio-status.connected {
    background: #27ae60;
    color: white;
}

.twilio-status.disconnected {
    background: #e74c3c;
    color: white;
}

/* Screen Pop Overlay */
.twilio-screen-pop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-in;
}

.screen-pop-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

.screen-pop-header {
    background: #3498db;
    color: white;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.screen-pop-header h4 {
    margin: 0;
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.screen-pop-body {
    padding: 20px;
}

.caller-info {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.caller-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #f1f2f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-right: 15px;
    border: 3px solid #3498db;
}

.caller-details h5 {
    margin: 0 0 5px 0;
    font-size: 18px;
    color: #2c3e50;
}

.phone-number {
    font-size: 16px;
    color: #7f8c8d;
    margin: 0 0 5px 0;
    font-weight: 500;
}

.caller-meta {
    font-size: 14px;
    color: #95a5a6;
    margin: 0;
}

.contact-history {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.contact-history h6 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
}

.contact-history ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.contact-history li {
    font-size: 13px;
    color: #7f8c8d;
    margin-bottom: 5px;
    padding-left: 15px;
    position: relative;
}

.contact-history li:before {
    content: "•";
    color: #3498db;
    position: absolute;
    left: 0;
}

.call-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.call-actions .btn {
    flex: 1;
    min-width: 120px;
    font-weight: 500;
    border-radius: 6px;
    padding: 12px;
}

/* Call Interface */
.twilio-call-interface {
    position: fixed;
    top: 50px;
    right: 20px;
    width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

.call-interface-content {
    padding: 20px;
}

.call-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.call-header h5 {
    margin: 0;
    color: #2c3e50;
    font-size: 16px;
}

.call-timer {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #27ae60;
    font-weight: bold;
}

.call-contact {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #f1f2f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
    border: 2px solid #3498db;
}

.contact-info h6 {
    margin: 0 0 3px 0;
    font-size: 16px;
    color: #2c3e50;
}

.contact-info p {
    margin: 0;
    font-size: 14px;
    color: #7f8c8d;
}

.call-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.call-controls .btn {
    flex: 1;
    font-size: 12px;
    padding: 8px 4px;
    border-radius: 6px;
}

.call-notes textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    font-size: 13px;
    resize: vertical;
    margin-bottom: 8px;
}

.call-notes .btn {
    width: 100%;
    font-size: 12px;
    padding: 6px;
}

/* Click-to-Call Buttons */
.phone-clickable {
    color: #3498db !important;
    text-decoration: none !important;
    cursor: pointer;
    position: relative;
    padding-right: 20px;
}

/* Floating action button to reopen hidden phone panel */
.twilio-phone-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1001;
    display: none;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

.twilio-phone-fab:hover {
    background: #2d85c3;
}

.phone-clickable:hover {
    color: #2980b9 !important;
    text-decoration: underline !important;
}

.phone-clickable:after {
    content: "📞";
    position: absolute;
    right: 0;
    top: 0;
    font-size: 12px;
    opacity: 0.7;
}

.call-btn {
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 8px;
}

.call-btn:hover {
    background: #219a52;
    transform: scale(1.05);
}

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

/* Call History */
.call-history-widget {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.call-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.call-history-header h6 {
    margin: 0;
    color: #2c3e50;
    font-size: 16px;
}

.call-history-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f2f6;
}

.call-history-item:last-child {
    border-bottom: none;
}

.call-direction {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 14px;
}

.call-direction.inbound {
    background: #e8f5e8;
    color: #27ae60;
}

.call-direction.outbound {
    background: #e3f2fd;
    color: #3498db;
}

.call-direction.missed {
    background: #ffebee;
    color: #e74c3c;
}

.call-info {
    flex: 1;
}

.call-info .name {
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
    margin: 0 0 2px 0;
}

.call-info .details {
    font-size: 12px;
    color: #7f8c8d;
    margin: 0;
}

.call-duration {
    font-size: 12px;
    color: #95a5a6;
    text-align: right;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInRight {
    from { 
        opacity: 0;
        transform: translateX(100%);
    }
    to { 
        opacity: 1;
        transform: translateX(0);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .twilio-call-interface {
        position: fixed;
        top: 60px;
        left: 10px;
        right: 10px;
        width: auto;
    }
    
    .screen-pop-content {
        width: 95%;
        margin: 10px;
    }
    
    .call-actions {
        flex-direction: column;
    }
    
    .call-actions .btn {
        min-width: auto;
    }
    
    .call-controls {
        flex-wrap: wrap;
    }
    
    .call-controls .btn {
        font-size: 11px;
        padding: 6px 2px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .screen-pop-content,
    .twilio-call-interface,
    .call-history-widget {
        background: #2c3e50;
        color: white;
    }
    
    .screen-pop-header {
        background: #34495e;
    }
    
    .contact-history {
        background: #34495e;
    }
    
    .call-notes textarea {
        background: #34495e;
        color: white;
        border-color: #556983;
    }
}

/* Print Styles */
@media print {
    .twilio-screen-pop,
    .twilio-call-interface,
    .twilio-status-bar {
        display: none !important;
    }
}
.twilio-status-banner {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #0f1622;
  color: #e5e7eb;
  border: 1px solid #1f2a37;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  z-index: 2000;
}
.twilio-status-banner.ready { border-color: #065f46; color: #bbf7d0; }
.twilio-status-banner.warn { border-color: #92400e; color: #fde68a; }
.twilio-status-banner.error { border-color: #7f1d1d; color: #fecaca; }
