/* Modal Styles */

#sms-history-section:not(.active) {
    display: none;
}

#sms-history-section.active {
    max-height: 500px;
}

.timeline-modal {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 100%;
    height: 100%;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.timeline-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.timeline-modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: white;
}

.timeline-modal-close {
    border: none;
    background: rgba(255, 255, 255, 0.2);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: white;
    padding: 8px 12px;
    line-height: 1;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.timeline-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.timeline-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
    background-color: #f8fafc;
}

/* Custom Scrollbar Styling */
.timeline-modal-body::-webkit-scrollbar {
    width: 6px;
}

.timeline-modal-body::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 3px;
}

.timeline-modal-body::-webkit-scrollbar-thumb {
    background-color: #c1c8cd;
    border-radius: 3px;
}

.timeline-modal-body::-webkit-scrollbar-thumb:hover {
    background-color: #9aa5ab;
}

/* Timeline Item Styles */
.timeline-item {
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
    position: relative;
}

.message-sender {
    font-size: 0.6rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 75%;
    word-wrap: break-word;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 0.7rem;
}

.message-meta {
    font-size: 0.5rem;
    color: #64748b;
    margin: 4px 8px 0;
    font-weight: 400;
    opacity: 0.8;
}

/* CUSTOMER messages (inbound) */
.customer-message {
    align-items: flex-start;
}

.customer-message .message-sender {
    color: #334155;
    margin-left: 8px;
}

.customer-message .message-bubble {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #1e293b;
    border-bottom-left-radius: 6px;
    border: 1px solid #e2e8f0;
}

.customer-message .message-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #f1f5f9;
}

/* HAWX/AGENT messages (outbound) */
.agent-message {
    align-items: flex-end;
}

.agent-message .message-sender {
    color: #1d4ed8;
    margin-right: 8px;
    text-align: right;
}

.agent-message .message-sender::before {
    content: '🏢 ';
    margin-right: 4px;
}

.agent-message .message-bubble {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-bottom-right-radius: 6px;
    border: 1px solid #2563eb;
}

.agent-message .message-bubble::before {
    content: '';
    position: absolute;
    right: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #3b82f6;
}

.agent-message .message-meta {
    text-align: right;
}

/* Tool Styles (Combined) */
.tool-interaction {
    margin: 24px auto;
    max-width: 95%;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e1e5e9;
}

.tool-interaction details {
    border: none;
    border-radius: 8px;
    background-color: transparent;
}

.tool-interaction summary {
    position: relative;
    padding: 12px 16px 12px 44px;
    font-weight: 500;
    cursor: pointer;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 8px;
    outline: none;
    color: #475569;
    font-size: 0.85rem;
    border-bottom: 1px solid #e1e5e9;
    transition: background-color 0.2s;
}

.tool-interaction summary:hover {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.tool-interaction details[open] summary {
    border-radius: 8px 8px 0 0;
}

.tool-interaction summary::before {
    content: '⚙️';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
}

.tool-interaction summary::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: translateY(-50%) rotate(45deg);
    transition: transform 0.2s;
}

.tool-interaction details[open] summary::after {
    transform: translateY(-50%) rotate(-135deg);
}

.tool-interaction summary code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    background-color: #dbeafe;
    color: #1e40af;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.tool-content {
    padding: 0;
    margin: 0;
    background-color: white;
}

.tool-content h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    margin: 0;
    padding: 12px 16px 8px;
    background-color: #f8fafc;
    font-weight: 600;
}

.tool-content h4:first-of-type {
    border-top: 1px solid #e1e5e9;
}

.tool-content pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.8rem;
    max-height: 280px;
    overflow-y: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

.tool-content pre:last-child {
    border-radius: 0 0 8px 8px;
}

/* Enhanced syntax highlighting for JSON */
.tool-content pre {
    line-height: 1.4;
}

/* Empty state styling */
.timeline-modal-body p {
    text-align: center;
    color: #64748b;
    font-style: italic;
    margin: 40px 0;
}

/* Loading state */
.timeline-modal-body p:only-child {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    font-size: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .timeline-modal {
        width: 95%;
        height: 90%;
        margin: 20px;
    }
    
    .timeline-modal-header {
        padding: 16px 20px;
    }
    
    .timeline-modal-body {
        padding: 16px;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 0.9rem;
    }
    
    .tool-interaction {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .message-bubble {
        max-width: 90%;
    }
    
    .timeline-modal-header h3 {
        font-size: 1.1rem;
    }
}