/* PCAP Viewer Specific Styles - Tailwind Compatible */

/* Error Alert Styles */
.error-alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    max-width: 600px;
    width: 90%;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease-out;
}

.error-content {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
}

.error-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.error-message {
    flex: 1;
    color: #721c24;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
}

.error-close {
    background: none;
    border: none;
    color: #721c24;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.error-close:hover {
    background-color: rgba(114, 28, 36, 0.1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}


/* PCAP Viewer Specific Styles Only */

/* Upload section */
.upload-section {
    padding: 40px;
}



.upload-area {
    border: 3px dashed #ddd;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-area.dragover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: #667eea;
    margin-bottom: 20px;
}

.upload-content  svg {
    margin: 0 auto;
    margin-bottom: 20px;
}
.upload-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.upload-content p {
    color: #444;
    font-size: 1rem;
}

.upload-content p small {
    color: #777;
    font-size: 0.8rem;
}

/* File info */
.file-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
}

.file-info .filename {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 480px;
}

.file-info .btn-bordered {
    padding: 6px 12px;
    font-size: 0.85rem;
}

#loadedFileList {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.loaded-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.loaded-file-name {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.loaded-file-row .filename {
    max-width: none;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: #333;
}

.loaded-file-row .file-size {
    color: #666;
    font-size: 0.85rem;
    white-space: nowrap;
}

.loaded-file-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.loaded-file-row .btn-bordered,
.loaded-file-row .btn-clear {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.file-info .file-size {
    color: #666;
    font-size: 0.85rem;
    white-space: nowrap;
}

.file-info .btn-clear {
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}

/* PCAP-specific button styles only */
.btn-clear {
    border: 1px solid #dc3545;
    background: transparent;
    color: #dc3545;
    font-size: 1rem;
    font-weight: bold;
    line-height: 1;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-clear:hover {
    background: #c82333;
    color: white;
}

/* Loading section */
.loading-section {
    padding: 60px 40px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background: #f3f3f3;
    border-radius: 4px;
    margin: 20px auto 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #667eea;
    width: 0%;
}

.multi-select-controls {
    margin-bottom: 20px;
}

.multi-select-controls .btn {
    margin-right: 10px;
}

.multi-select-controls .btn:last-child {
    margin-right: 0;
}

.calls-list h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: #333;
}

.calls-container {
    display: block;
}

.calls-table-header {
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 5px;
}

.call-row {
    display: grid;
    grid-template-columns: 40px 140px 1fr 1fr 80px 100px 100px 80px 70px 120px;
    gap: 15px;
    align-items: center;
    padding: 10px 15px;
    font-size: 0.9rem;
}

.call-row.header-row {
    font-weight: 600;
    color: #666;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px 15px;
}

.call-item {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    background: white;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

.call-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
    background: #fafbff;
}

.call-item.selected {
    border: 2px solid #007bff !important;
    background-color: rgba(0, 123, 255, 0.03) !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15) !important;
}

.call-item.selected:hover {
    border-color: #0056b3 !important;
    background-color: rgba(0, 123, 255, 0.05) !important;
}

.call-checkbox-col {
    display: flex;
    justify-content: center;
}

.call-checkbox-col input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    transform: scale(0.9);
}

.call-time-col {
    font-size: 0.85rem;
}

.call-from-col,
.call-to-col {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.call-method-col {
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: #007bff;
}

.call-status-col {
    text-align: center;
}

.call-sip-status-col {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.sip-call-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1.2;
    border: 1px solid transparent;
}

.sip-call-status-ok {
    color: #065f46;
    background: #d1fae5;
    border-color: #a7f3d0;
}

.sip-call-status-warn {
    color: #92400e;
    background: #fef3c7;
    border-color: #fde68a;
}

.sip-call-status-error {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fecaca;
}

.sip-call-status-unknown {
    color: #6b7280;
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.call-duration-col,
.call-messages-col {
    text-align: center;
    font-size: 0.85rem;
}

.call-id-col {
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Diagram section */
.diagram-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.diagram-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.diagram-header-left h3 {
    margin: 0;
    color: #333;
}

.diagram-header-left .btn {
    font-weight: 500;
    padding: 10px 20px;
}

.diagram-header h3 {
    font-size: 1.5rem;
}

.diagram-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-bordered {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-bordered:hover {
    background: #f9fafb;
}

.pcap-diagram-toolbar .btn-bordered {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

#hostAliasBtn {
    gap: 6px;
    white-space: nowrap;
}

.host-alias-chevron {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    transition: transform 150ms ease;
}

#hostAliasBtn[aria-expanded="true"] .host-alias-chevron {
    transform: rotate(180deg);
}

.host-alias-panel {
    margin: 0 0 16px 0;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.host-alias-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.host-alias-heading h3 {
    margin: 0;
    font-size: 16px;
    color: #111827;
}

.host-alias-heading p {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: #4b5563;
}

.host-alias-empty {
    margin: 12px 0 0 0;
    font-size: 13px;
    color: #6b7280;
}

.host-alias-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.host-alias-name {
    width: 220px;
    flex: 0 0 220px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.host-alias-ips {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding-top: 6px;
}

.host-alias-ips label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #111827;
    cursor: pointer;
}

.host-alias-ips label.is-taken {
    color: #9ca3af;
    cursor: default;
}

.host-alias-remove {
    flex: 0 0 auto;
}

.diagram-container {
    border-radius: 0;
    min-height: 0;
    overflow: auto;
    position: relative;
    max-width: 100%;
    max-height: calc(100vh - 18rem);
    background: #fff;
}

/* Dual scrollbar container */
.diagram-scroll-wrapper {
    position: relative;
    width: 100%;
}

/* Top scrollbar container */
.diagram-top-scrollbar {
    overflow-x: auto;
    overflow-y: hidden;
    height: 20px;
    margin-bottom: 5px;
    /* Only show when content is scrollable */
    display: none;
}

.diagram-top-scrollbar::-webkit-scrollbar {
    height: 12px;
}

.diagram-top-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.diagram-top-scrollbar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
    border: 2px solid #f1f1f1;
}

.diagram-top-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Invisible content div to match the width of the main diagram */
.diagram-top-scrollbar-content {
    height: 1px;
    /* Width will be set by JavaScript to match diagram content */
    min-width: 100%;
}

/* Show top scrollbar when content is scrollable */
.diagram-container[data-scrollable="true"] + .diagram-top-scrollbar,
.diagram-scroll-wrapper[data-scrollable="true"] .diagram-top-scrollbar {
    display: block;
}

/* Custom scrollbar styles for webkit browsers */
.diagram-container::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}

.diagram-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.diagram-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
    border: 2px solid #f1f1f1;
}

.diagram-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}



/* Ensure SIP sequence diagrams can scroll properly */
.sip-sequence-diagram {
    min-width: max-content;
    position: relative;
}

/* Make timestamp column sticky for better visibility */
.sip-sequence-diagram .timestamp-header,
.sip-sequence-diagram .timestamp-cell {
    position: sticky;
    left: 0;
    z-index: 50;
}

/* Ensure proper background for sticky elements */
.sip-sequence-diagram .timestamp-header {
    background: #e9ecef;
}

.sip-sequence-diagram .timestamp-cell {
    background: #fafafa;
}

/* Additional scrolling improvements */
.diagram-container {
    /* Enable smooth scrolling */
    scroll-behavior: smooth;
    /* Ensure scrollbars are always visible on supported browsers */
    -webkit-overflow-scrolling: touch;
}

/* Add visual indicator for scrollable content */
.diagram-container::after {
    display: none;
}

/* Ensure the diagram content doesn't get cut off */
.sip-sequence-diagram .diagram-header,
.sip-sequence-diagram .messages-container {
    min-width: max-content;
}

/* Improve scrolling behavior for large diagrams - removed scroll snapping for natural scroll behavior */

/* Ensure timestamp column is always accessible - removed scroll snap alignment for natural scroll behavior */

/* Add visual feedback for scrollable content */
.diagram-container:hover {
    scrollbar-color: #a8a8a8 #e0e0e0;
}

/* Ensure proper z-index layering - messages should be above timestamp column */
.sip-sequence-diagram .diagram-header {
    z-index: 10;
}

.sip-sequence-diagram .messages-container {
    z-index: 15;
}

/* Ensure message content is visible above timestamp column */
.sip-sequence-diagram .message-arrow,
.sip-sequence-diagram .message-label {
    z-index: 20;
}

/* Additional fixes for message visibility */
.sip-sequence-diagram .message-row {
    position: relative;
    z-index: 15;
}

.sip-sequence-diagram .message-area {
    position: relative;
    z-index: 15;
}

/* Ensure messages starting from leftmost columns are visible */
.sip-sequence-diagram .message-arrow {
    position: absolute;
    z-index: 20;
}

/* Fix for messages that start very close to the timestamp column */
.sip-sequence-diagram .message-arrow[style*="left: 0px"],
.sip-sequence-diagram .message-arrow[style*="left: 1px"],
.sip-sequence-diagram .message-arrow[style*="left: 2px"] {
    z-index: 25;
}

/* Ensure message labels are always visible */
.sip-sequence-diagram .message-label {
    z-index: 30;
    position: absolute;
}

/* Fix stacking context issues with sticky timestamp column */
.sip-sequence-diagram .timestamp-header,
.sip-sequence-diagram .timestamp-cell {
    position: sticky;
    left: 0;
    z-index: 50;
    /* Ensure sticky elements don't create problematic stacking contexts */
    isolation: isolate;
}

/* Ensure messages container has proper stacking context */
.sip-sequence-diagram .messages-container {
    position: relative;
    z-index: 15;
    /* Create a new stacking context for messages */
    isolation: isolate;
}

/* Ensure individual message rows are properly layered */
.sip-sequence-diagram .message-row {
    position: relative;
    z-index: 15;
    /* Ensure each row creates its own stacking context */
    isolation: isolate;
}

/* Specific fix for messages that start very close to timestamp column */
.sip-sequence-diagram .message-arrow {
    position: absolute !important;
    z-index: 25 !important;
    /* Ensure arrows are always visible */
    pointer-events: auto;
}

/* Force visibility for messages that might be hidden */
.sip-sequence-diagram .message-arrow,
.sip-sequence-diagram .message-label {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure the first participant column messages are visible */
.sip-sequence-diagram .message-arrow[style*="left: 0px"],
.sip-sequence-diagram .message-arrow[style*="left: 1px"],
.sip-sequence-diagram .message-arrow[style*="left: 2px"],
.sip-sequence-diagram .message-arrow[style*="left: 3px"],
.sip-sequence-diagram .message-arrow[style*="left: 4px"],
.sip-sequence-diagram .message-arrow[style*="left: 5px"] {
    z-index: 30 !important;
    position: absolute !important;
}

/* Ensure message area doesn't clip arrows */
.sip-sequence-diagram .message-area {
    overflow: visible !important;
    position: relative;
    z-index: 15;
}

/* Ensure message arrows extend beyond their containers if needed */
.sip-sequence-diagram .message-arrow {
    overflow: visible !important;
    clip-path: none !important;
}

/* Fix for arrows that might be positioned very close to left edge */
.sip-sequence-diagram .message-arrow[style*="left: 10px"],
.sip-sequence-diagram .message-arrow[style*="left: 11px"],
.sip-sequence-diagram .message-arrow[style*="left: 12px"],
.sip-sequence-diagram .message-arrow[style*="left: 13px"],
.sip-sequence-diagram .message-arrow[style*="left: 14px"],
.sip-sequence-diagram .message-arrow[style*="left: 15px"] {
    z-index: 30 !important;
    position: absolute !important;
    /* Ensure these arrows are fully visible */
    clip: auto !important;
    overflow: visible !important;
}

/* Ensure all containers allow proper overflow for message arrows */
.sip-sequence-diagram .messages-container {
    overflow: visible !important;
}

.sip-sequence-diagram .message-row {
    overflow: visible !important;
}

.sip-sequence-diagram .message-row:hover .timestamp-cell {
    background-color: #ececec;
}

/* Ensure the entire diagram allows proper overflow */
.sip-sequence-diagram {
    overflow: visible !important;
}

/* Force visibility for all message elements */
.sip-sequence-diagram .message-arrow,
.sip-sequence-diagram .message-label,
.sip-sequence-diagram .lifeline {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}



/* Ensure proper spacing for sticky elements */
.sip-sequence-diagram .timestamp-header,
.sip-sequence-diagram .timestamp-cell {
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}

/* Add scroll indicator for wide diagrams */

.diagram-container:not([data-scrollable="false"]):hover::after {
    opacity: 1;
}

/* Hide scroll indicator when not needed */
.diagram-container[data-scrollable="false"]::after {
    display: none;
}


/* PCAP-specific responsive adjustments only */
@media (max-width: 768px) {
    .call-row {
        grid-template-columns: 30px 110px 1fr 1fr 60px 80px 90px 60px 50px 100px;
        gap: 8px;
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .call-row.header-row {
        padding: 10px;
    }

    .diagram-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .host-alias-heading,
    .host-alias-row {
        flex-direction: column;
    }

    .host-alias-name {
        width: 100%;
        flex-basis: auto;
    }

    .diagram-header-left {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

#shareModal.modal,
#pcapAuthModal.modal,
#messageModal.modal {
    background-color: rgb(15 23 42 / 0.5);
    backdrop-filter: blur(4px);
    padding: 1rem;
}

/* Share Modal specific styles */
.share-url-container {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    align-items: stretch;
}

.share-url-input {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    background: #f8f9fa;
    color: #333;
}

.share-url-input:focus {
    outline: none;
    border-color: #667eea;
}

.share-info {
    margin-top: 15px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.share-info p {
    margin: 5px 0;
}

.share-note {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4b5563;
    font-size: 13px;
}

.share-note-icon,
.share-btn-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.share-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.modal-content {
    background-color: white;
    margin: 0;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: #667eea;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.message-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.info-row {
    display: flex;
    margin-bottom: 8px;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    font-weight: 600;
    width: 120px;
    color: #666;
}

.info-value {
    flex: 1;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.message-headers,
.message-body {
    margin-bottom: 20px;
}

.message-headers h4,
.message-body h4 {
    margin-bottom: 10px;
    font-size: 1rem;
}

.message-headers pre,
.message-body pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 15px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* PCAP-specific utility classes only */
.mb-20 {
    margin-bottom: 20px;
}
.btn-view-calls {
    margin-left: 10px;
}
