/* Hub Layout */
.hub-modal-content { background: #f8f9fa; }
.communication-hub-container { display: flex; height: calc(100vh - 2px); background: #fff; overflow: hidden; }
.hub-main-panel { flex: 1; display: flex; flex-direction: column; height: 100%; overflow: hidden; background: #fff; }

.hub-content-area {
    height: 100%;
}

/* Zone A: Header */
.hub-header { 
    padding: 1rem 2rem; 
    border-bottom: 1px solid #f1f3f5; 
    position: sticky; 
    top: 0;
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1); 
    background: #fff;
    box-shadow: 0 2px 15px rgba(0,0,0,0.02);
    flex-shrink: 0;
}
.hub-header.active-call { 
    background: linear-gradient(to right, #ffffff, #f0f7ff); 
    border-bottom: 2px solid #0d6efd;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
}

/* Patient Context */
.patient-context {
    min-width: 280px;
    min-height: 60px; /* Ensures consistent height before/after load */
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.patient-context h3.patient-header-name { 
    color: #111827; 
    letter-spacing: -0.025em; 
    margin: 0 0 4px 0 !important; 
    padding: 0 !important;
    line-height: 1.2 !important; 
    font-size: 1.35rem;
    font-weight: 700;
    min-height: 1.2em; /* Prevents collapse */
}

#current-call-patient-details {
    min-height: 28px; /* Height of the badges */
}
.patient-badge-sm { 
    background-color: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    padding: 4px 12px !important;
    border-radius: 50px !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}
.patient-badge-sm:hover {
    background-color: #f1f3f5 !important;
    border-color: #d1d5db !important;
}
.patient-badge-sm i {
    color: #0d6efd;
    font-size: 0.75rem;
}
.patient-badge-sm span {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
}

/* Call Button Styling */
#hub-header-call-btn {
    background-color: #0d6efd;
    border: none;
    border-radius: 10px;
    padding: 10px 24px;
    font-weight: 700;
    font-size: 0.9375rem;
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

#hub-header-call-btn:hover {
    background-color: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

#hub-header-call-btn:active {
    transform: translateY(0);
}

/* Timer Display */
.timer-display .fs-4 {
    font-family: 'JetBrains Mono', 'SF Mono', menlo, monospace;
    color: #1a1d1f;
    letter-spacing: -0.05em;
}
.timer-display .small {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Keypad Dropdown */
.hub-keypad-dropdown { position: absolute; top: 100%; right: 2rem; background: white; border: 1px solid #ddd; box-shadow: 0 10px 30px rgba(0,0,0,0.1); border-radius: 12px; padding: 1.5rem; z-index: 100; display: none; margin-top: 10px; }
.hub-keypad-dropdown.show { display: block; }
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad-btn { font-size: 1.2rem; font-weight: bold; height: 48px; border-radius: 8px; }

/* Pulse Animation for Active Call */
.call-pulse-indicator { position: relative; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(13, 110, 253, 0.1); }
.pulse-ring { position: absolute; inset: 0; border-radius: 50%; animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite; border: 2px solid #0d6efd; }
@keyframes pulse-ring { 0% { transform: scale(0.8); opacity: 0.5; } 100% { transform: scale(1.5); opacity: 0; } }

/* Enhanced RTM Components */
.letter-spacing-1 { letter-spacing: 0.05rem; }
.shadow-xs { box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

/* Progress Bar Markers */
.milestone-marker {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 3px;
    background-color: #fff;
    border: 1px solid #dee2e6;
    z-index: 2;
    border-radius: 2px;
    transform: translateX(-50%);
}

/* Timeline Enhancements */
/* Chat Overrides for Timeline */
.activity-timeline .hub-timeline-chat { 
    height: auto !important; 
    max-height: 350px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 6px;
    padding: 10px 0;
}

/* --- Premium Chat Bubble Styling --- */
.activity-timeline .chat-bubble {
    max-width: 85%;
    padding: 14px 18px;
    margin-bottom: 12px;
    position: relative;
    clear: both;
    font-size: 0.9rem;
    line-height: 1.55;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    word-wrap: break-word;
    white-space: normal !important;
    border: 1px solid transparent;
}

.activity-timeline .chat-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Chat Bubble Backgrounds */
.chat-incoming { 
    align-self: flex-start; 
    background: #ffffff; 
    border: 1px solid #e2e8f0 !important;
    color: #334155; 
    border-radius: 22px 22px 22px 4px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-outgoing { 
    align-self: flex-end; 
    background: #334155; /* Sophisticated Deep Slate Blue */
    color: #ffffff; 
    border-radius: 22px 22px 4px 22px !important;
    box-shadow: 0 4px 14px rgba(51, 65, 85, 0.15);
    border: 1px solid #1e293b !important;
}

.chat-time { 
    font-size: 0.68rem; 
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: block; 
    margin-top: 8px;
    color: #94a3b8;
    transition: all 0.2s ease;
}

.chat-outgoing .chat-time {
    color: #cbd5e1;
    text-align: right;
}

.chat-incoming .chat-time {
    color: #94a3b8;
}

/* Enhanced Hover states for metadata */
.chat-bubble:hover .chat-time {
    color: #64748b;
}

.chat-outgoing:hover .chat-time {
    color: #f1f5f9;
}

/* Special override for SMS Campaign Preview in Modal (Compact Look) */
#sms-campaign-assignment-preview .chat-bubble.chat-outgoing {
    background: #334155 !important;
    color: #ffffff !important;
    border-radius: 12px 12px 4px 12px !important;
    padding: 10px 14px !important;
    font-size: 0.85rem !important;
    line-height: 1.45 !important;
    border: 1px solid #1e293b !important;
    margin-bottom: 0 !important;
    width: auto !important;
    display: inline-block !important;
    max-width: 100% !important;
    box-shadow: 0 2px 5px rgba(51, 65, 85, 0.1) !important;
}

#sms-campaign-assignment-preview .card-body {
    padding: 0 !important;
    background-color: transparent !important;
}

#sms-campaign-assignment-preview .card {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin-bottom: 4px !important;
}

#sms-campaign-assignment-preview .badge.bg-light {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #e2e8f0 !important;
    margin-top: 4px;
}

/* Campaign Reply Block */
.chat-bubble.campaign-reply { 
    background: #fffbeb; 
    color: #92400e; 
    border: 1px solid #fde68a !important; 
    border-radius: 22px 22px 4px 22px !important;
}
.campaign-quote { 
    font-size: 0.85rem; 
    padding: 10px 14px; 
    margin-bottom: 12px; 
    border-radius: 12px; 
    background: rgba(251, 191, 36, 0.1); 
    border-left: 4px solid #fbbf24; 
    color: #92400e; 
}

/* Form inputs */
.chat-input-area .form-control { box-shadow: none; border-color: #dee2e6; }
.chat-input-area .btn { border-color: #dee2e6; }

/* RTM Dashboard */
.x-small { font-size: 0.7rem; }

/* Minimized Floating Overlay */
#comm-hub-minimized-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 280px;
    background: #fff;
    border-radius: 12px;
    z-index: 2001; /* Above standard Bootstrap modals */
    border: 1px solid #dee2e6;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

#comm-hub-minimized-overlay:hover { transform: translateY(-5px); }

/* Buttons in Sidebar */
.btn-comm-hub-minimize { border-radius: 8px; color: #6c757d; }
.btn-comm-hub-minimize:hover { background-color: #f8f9fa; color: #0d6efd; }


/* Unified Component Styles (Transferred from Inline) */
.hub-sidebar-fixed { width: 280px; min-width: 280px; flex-shrink: 0; }

.patient-header-name { font-size: 1.35rem; letter-spacing: -0.025em; font-weight: 700; color: #111827; }
.patient-badge-sm { font-size: 0.8rem; }
.divider-v-40 { height: 32px; width: 1px; background-color: #dee2e6; margin: 0 10px; opacity: 1 !important; }
.divider-v-32 { height: 32px; }

.rtm-month-label { font-size: 0.75rem; }
.rtm-info-icon-sm { font-size: 0.85rem; }
.rtm-billing-pill { 
    font-size: 0.75rem; 
    border: 1px solid rgba(255,255,255,0.5) !important; 
}

.rtm-progress-fixed-height { height: 8px; background-color: #e9ecef; }
.rtm-milestone-container { height: 14px; position: relative; }
.rtm-milestone-label { position: absolute; }
.rtm-milestone-label-center { transform: translateX(-50%); }
.rtm-milestone-label-end { transform: translateX(-100%); }

.activity-timeline { 
    padding-left: 20px; 
    position: relative; 
    overflow-y: auto !important;
    overflow-x: hidden;
    flex: 1;
}

/* Color helper classes for timeline borders */
.border-left-primary { border-left: 4px solid var(--bs-primary) !important; }
.border-left-success { border-left: 4px solid var(--bs-success) !important; }
.border-left-info { border-left: 4px solid var(--bs-info) !important; }
.border-left-danger { border-left: 4px solid var(--bs-danger) !important; }
.border-left-warning { border-left: 4px solid var(--bs-warning) !important; }
.border-left-secondary { border-left: 4px solid var(--bs-secondary) !important; }
.border-left-purple { border-left: 4px solid var(--bs-purple) !important; }

/* Text and Background Utility Classes for Hub Components */
.text-purple { color: var(--bs-purple) !important; }
.bg-purple { background-color: var(--bs-purple) !important; }


/* Sticky Header for Timeline Dates */
.timeline-date-separator {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    margin: 0 -20px 1.25rem -20px;
    padding: 0.75rem 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(241, 243, 245, 0.5);
}

.timeline-date-separator::before {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to left, #e9ecef, transparent);
}

.timeline-date-separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, #e9ecef, transparent);
}

.timeline-date-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #4b5563;
    background: #fff;
    padding: 6px 16px;
    border-radius: 50px;
    border: 1px solid #e5e7eb;
    margin: 0 15px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
    white-space: nowrap;
}

/* Timeline Card Structure */
.timeline-card {
    background: #fff;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.04);
    border: 1px solid #f1f3f5;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.timeline-card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
    border-color: #e9ecef;
}

.timeline-group-details {
    border-top: 1px solid #f1f3f5;
    padding-top: 10px;
    margin-top: 4px;
}

.timeline-group-details summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-height: 26px;
    padding: 3px 12px;
    border: 1px solid #dee2e6;
    border-radius: 50px;
    background: #f8f9fa;
    color: #6c757d;
    cursor: pointer;
    font-size: 0.725rem;
    font-weight: 600;
    line-height: 1.2;
    list-style: none;
    overflow-wrap: anywhere;
    transition: all 0.2s ease;
    user-select: none;
}

.timeline-group-details summary::-webkit-details-marker {
    display: none;
}

.timeline-group-details summary::before {
    content: "";
    width: 5px;
    height: 5px;
    flex: 0 0 5px;
    border-right: 1.25px solid currentColor;
    border-bottom: 1.25px solid currentColor;
    transform: translateY(-1px) rotate(-45deg);
    transition: transform 0.2s ease;
    margin-right: 2px;
}

.timeline-group-details[open] summary::before {
    transform: translateY(-2px) rotate(45deg);
}

.timeline-group-details summary:hover {
    background-color: #f1f3f5;
    border-color: #ced4da;
    color: #212529;
}

.timeline-group-details summary:focus {
    outline: none;
}

.timeline-group-details summary:focus-visible {
    border-color: rgba(13, 110, 253, 0.45);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.12);
}

.timeline-group-detail-list {
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.timeline-group-detail-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid #f8f9fa;
    font-size: 0.7rem;
    line-height: 1.35;
}

.timeline-group-detail-time {
    font-weight: 700;
    color: #374151;
    min-width: 0;
    white-space: nowrap;
}

.timeline-group-detail-meta,
.timeline-group-detail-sid {
    color: #6b7280;
    min-width: 0;
    overflow-wrap: anywhere;
}

.timeline-group-detail-sid {
    grid-column: 2;
    font-size: 0.62rem;
    opacity: 0.8;
}

@media (max-width: 575.98px) {
    .timeline-group-details summary {
        width: 100%;
        justify-content: flex-start;
    }

    .timeline-group-detail-row {
        grid-template-columns: 58px minmax(0, 1fr);
        gap: 6px;
    }
}

.rtm-duration-pill {
    font-size: 0.6rem;
    font-weight: 700;
    background: #f8f9fa;
    color: #64748b;
    border: 1px solid #e9ecef;
    padding: 2px 10px;
    border-radius: 50px;
    display: inline-block;
}

/* Custom scrollbar for activity timeline */
.activity-timeline::-webkit-scrollbar {
    width: 6px;
}
.activity-timeline::-webkit-scrollbar-track {
    background: transparent;
}
.activity-timeline::-webkit-scrollbar-thumb {
    background: #e9ecef;
    border-radius: 10px;
}
.activity-timeline::-webkit-scrollbar-thumb:hover {
    background: #dee2e6;
}

.timeline-rail-custom { 
    position: absolute; 
    left: 7px; 
    top: 0; 
    bottom: 0; 
    width: 2px; 
    background: #f1f3f5; 
}
.timeline-icon-compact {
    position: absolute;
    left: -20px;
    top: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    z-index: 3;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: var(--bs-box-shadow-sm) !important;
}

.sms-bubble-campaign { font-size: 0.55rem; letter-spacing: 0.5px; font-weight: 700; }

/* SMS Timeline Item Enhancements */
.timeline-item-sms .chat-bubble {
    width: 100%;
    max-width: 100% !important;
    margin-top: 6px;
    border-radius: 16px !important;
    padding: 14px 18px !important;
    font-size: 0.9rem !important;
    line-height: 1.55 !important;
    position: relative;
    border: 1px solid transparent;
    align-self: flex-start !important; /* Force left align in timeline */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.timeline-item-sms .chat-incoming {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #334155 !important;
    border-bottom-left-radius: 4px !important;
}

.timeline-item-sms .chat-outgoing {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #475569 !important;
    border-bottom-right-radius: 4px !important;
}

.timeline-item-sms .chat-outgoing.campaign-reply {
    background: #fffbeb !important;
    border-color: #fde68a !important;
    color: #92400e !important;
}

.hub-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}
.sms-max-height { max-height: 400px; }

/* Activity Scroller Cards */
.hub-activity-card strong { max-width: 110px; display: block; }
.hub-activity-card .badge-type { font-size: 0.65rem; letter-spacing: 1px; }

/* --- Metric Cards Overhaul --- */
.hub-metric-card {
    background: #fdfdfd;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease-in-out;
    min-width: 140px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.hub-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.06);
    border-color: #d1d5db;
    background: #ffffff;
}

.hub-metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    border: 1px solid #f1f5f9;
}

.hub-metric-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hub-metric-value {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 3px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.hub-metric-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    white-space: nowrap;
}

/* Color specific icon backgrounds for better polish */
.hub-metric-card:hover .hub-metric-icon {
    background: #fff;
}

/* Incoming Call Floating Card Override */
#voice-incoming-call-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 350px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 3000;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    display: none; /* Controlled by .show or JS */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}

#voice-incoming-call-toast.show {
    display: block !important;
    opacity: 1;
    transform: translateY(0) scale(1);
}

#voice-incoming-call-toast.showing {
    display: block !important;
}

#voice-incoming-call-toast .card-body {
    padding: 2rem;
    text-align: center;
}

.incoming-call-avatar-container {
    position: relative;
    width: 90px;
    height: 90px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.incoming-call-avatar {
    width: 80px;
    height: 80px;
    background: #f0f7ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: #0d6efd;
    z-index: 2;
    border: 4px solid #fff;
    box-shadow: 0 8px 20px rgba(13, 110, 253, 0.15);
}

.ripple-background {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    z-index: 1;
}

.ripple-circle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(13, 110, 253, 0.25);
    animation: ripple-v2 2.5s infinite;
}

.ripple-circle:nth-child(2) { animation-delay: 0.8s; }
.ripple-circle:nth-child(3) { animation-delay: 1.6s; }

@keyframes ripple-v2 {
    0% { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

.floating-call-card .patient-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
}

.floating-call-card .call-status {
    font-size: 0.875rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin-bottom: 2rem;
}

.floating-call-card .action-buttons {
    display: flex;
    gap: 12px;
}

.floating-call-card .action-buttons .btn {
    flex: 1;
    padding: 14px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-call-card .btn-answer {
    background: #10b981;
    border: none;
    color: white;
}

.floating-call-card .btn-answer:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.floating-call-card .btn-decline {
    background: #ef4444;
    border: none;
    color: white;
}

.floating-call-card .btn-decline:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.floating-call-card .btn:active {
    transform: translateY(0);
}

.floating-call-card .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 400px) {
    #voice-incoming-call-toast {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
        bottom: 20px;
    }
}
