/**
 * Graph Monitor 2.0 Modal Styles
 * Context menu and marker table styling
 */

/* Graph Modal 2.0 - Base */
.graph-modal-2 {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.graph-modal-2.active {
    display: flex !important;
}

.graph-modal-2-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    max-width: 90vw;
    max-height: 85vh;
    width: 1200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.graph-modal-2-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #dddfe0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
}

.graph-modal-2-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2d8998;
}

/* Header Actions Container */
.graph-modal-2-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.graph-modal-2-close-btn,
.graph-modal-2-action-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #dddfe0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #2c3e50;
}

.graph-modal-2-close-btn svg,
.graph-modal-2-action-btn svg {
    width: 18px;
    height: 18px;
}

.graph-modal-2-close-btn:hover,
.graph-modal-2-action-btn:hover {
    background: #ffffff;
    border-color: #2d8998;
    color: #2d8998;
}

.graph-modal-2-action-btn.active {
    background: #2d8998;
    border-color: #2d8998;
    color: white;
}

/* Overlay Management Panel for Graph Modal 2 */
.graph-modal-2-overlay-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
}

/* Panel Header */
.overlay-panel-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #2d8998 0%, #1e6b77 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.overlay-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.overlay-panel-title svg {
    opacity: 0.9;
}

.overlay-panel-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.overlay-panel-close svg {
    width: 18px;
    height: 18px;
    stroke: rgba(255, 255, 255, 0.9);
}

.overlay-panel-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* Panel Content */
.overlay-panel-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* Section Styling */
.overlay-section {
    margin-bottom: 20px;
}

.overlay-section:last-child {
    margin-bottom: 0;
}

.overlay-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    margin-bottom: 10px;
    padding-left: 4px;
}

/* Layer Items */
.overlay-layers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.overlay-layer-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.overlay-layer-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.overlay-layer-item.primary {
    background: linear-gradient(135deg, #f0fdfa 0%, #e0f7fa 100%);
    border-color: #2d8998;
    border-width: 2px;
}

/* Layer Header Row */
.overlay-layer-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.overlay-layer-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.8), 0 1px 3px rgba(0,0,0,0.15);
}

.overlay-layer-info {
    flex: 1;
    min-width: 0;
}

.overlay-layer-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.overlay-layer-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.overlay-layer-axis {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #64748b;
}

.overlay-layer-axis.left {
    background: #dbeafe;
    color: #1d4ed8;
}

.overlay-layer-axis.right {
    background: #fee2e2;
    color: #dc2626;
}

.overlay-layer-actions {
    display: flex;
    gap: 4px;
}

.overlay-layer-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.overlay-layer-btn svg {
    width: 14px;
    height: 14px;
    stroke: #64748b;
}

.overlay-layer-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.overlay-layer-btn:hover svg {
    stroke: #334155;
}

.overlay-layer-btn.remove:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.overlay-layer-btn.remove:hover svg {
    stroke: #dc2626;
}

/* Y-Offset Control */
.overlay-layer-offset {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.overlay-offset-label {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}

.overlay-offset-input {
    flex: 1;
    height: 28px;
    padding: 0 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
    background: #f8fafc;
    color: #334155;
    transition: all 0.15s ease;
}

.overlay-offset-input:focus {
    outline: none;
    border-color: #2d8998;
    background: white;
    box-shadow: 0 0 0 3px rgba(45, 137, 152, 0.1);
}

.overlay-offset-input::placeholder {
    color: #94a3b8;
}

/* Panel Footer */
.overlay-panel-footer {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
}

.overlay-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.overlay-btn svg {
    flex-shrink: 0;
}

.overlay-btn-add {
    background: linear-gradient(135deg, #2d8998 0%, #1e6b77 100%);
    color: white;
}

.overlay-btn-add:hover {
    background: linear-gradient(135deg, #35a0b0 0%, #247d8a 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 137, 152, 0.3);
}

.overlay-btn-clear {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.overlay-btn-clear:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* Empty State */
.overlay-empty-state {
    text-align: center;
    padding: 24px 16px;
    color: #94a3b8;
}

.overlay-empty-state svg {
    width: 40px;
    height: 40px;
    stroke: #cbd5e1;
    margin-bottom: 12px;
}

.overlay-empty-state p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* ============================================
   Comments Management Panel for Graph Modal 2
   ============================================ */
.graph-modal-2-comments-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
}

/* Comments Panel Header */
.comments-panel-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.comments-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.comments-panel-title svg {
    opacity: 0.9;
}

.comments-count-badge {
    background: rgba(255, 255, 255, 0.25);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.comments-panel-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.comments-panel-close svg {
    width: 18px;
    height: 18px;
    stroke: rgba(255, 255, 255, 0.9);
}

.comments-panel-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* Comments Panel Content */
.comments-panel-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Comment Item */
.comment-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    cursor: pointer;
}

.comment-item:hover {
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.comment-item.out-of-scope {
    opacity: 0.7;
    border-style: dashed;
}

.comment-item.out-of-scope:hover {
    border-color: #f59e0b;
}

.comment-item-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.comment-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.comment-item-icon.dot {
    background: rgba(59, 130, 246, 0.15);
}

.comment-item-icon.dot svg {
    width: 14px;
    height: 14px;
    stroke: #3b82f6;
}

.comment-item-icon.area {
    background: rgba(255, 180, 80, 0.2);
}

.comment-item-icon.area svg {
    width: 14px;
    height: 14px;
    stroke: #f59e0b;
}

.comment-item-info {
    flex: 1;
    min-width: 0;
}

.comment-item-text {
    font-size: 13px;
    color: #1e293b;
    line-height: 1.4;
    word-wrap: break-word;
    margin-bottom: 4px;
}

.comment-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #94a3b8;
}

.comment-item-time {
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-item-time svg {
    width: 12px;
    height: 12px;
}

.comment-item-user {
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-item-user svg {
    width: 12px;
    height: 12px;
}

.comment-item-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.comment-item-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.comment-item-btn svg {
    width: 14px;
    height: 14px;
    stroke: #64748b;
}

.comment-item-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.comment-item-btn:hover svg {
    stroke: #334155;
}

.comment-item-btn.delete:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.comment-item-btn.delete:hover svg {
    stroke: #dc2626;
}

.comment-item-btn.jump:hover {
    background: #e0e7ff;
    border-color: #a5b4fc;
}

.comment-item-btn.jump:hover svg {
    stroke: #4f46e5;
}

/* Out of scope indicator */
.comment-out-of-scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    margin-left: 8px;
}

/* Comments Empty State */
.comments-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}

.comments-empty-state svg {
    stroke: #cbd5e1;
    margin-bottom: 16px;
}

.comments-empty-state p {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
}

.comments-empty-state span {
    font-size: 12px;
}

/* Comments Panel Footer */
.comments-panel-footer {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
}

.comments-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.comments-btn svg {
    flex-shrink: 0;
}

.comments-btn-clear {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.comments-btn-clear:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* Overlay Management Item Styles */
.overlay-management-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid #dddfe0;
    border-radius: 8px;
    margin-bottom: 10px;
}

.overlay-item-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #dddfe0;
}

.overlay-item-info {
    flex: 1;
    min-width: 0;
}

.overlay-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-item-axis {
    font-size: 11px;
    color: #7f8c8d;
    margin-top: 2px;
}

.overlay-item-remove {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #dddfe0;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.overlay-item-remove svg {
    width: 14px;
    height: 14px;
    stroke: #e74c3c;
}

.overlay-item-remove:hover {
    background: #fee2e2;
    border-color: #e74c3c;
}

.graph-modal-2-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.graph-modal-2-canvas-container {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: white;
    min-height: 0;
}

#graphModal2Canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: default;
}

/* Context Menu */
.graph-modal-2-context-menu {
    position: fixed;
    background: #ffffff;
    border: 1px solid #dddfe0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    z-index: 100001;
    min-width: 160px;
}

.graph-modal-2-context-menu .context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.graph-modal-2-context-menu .context-menu-item:hover {
    background: #f8f9fa;
}

.graph-modal-2-context-menu .context-menu-item.disabled,
.graph-modal-2-context-menu .context-submenu-item.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}

.graph-modal-2-context-menu .context-menu-item svg {
    width: 16px;
    height: 16px;
    stroke: #2c3e50;
    flex-shrink: 0;
}

.graph-modal-2-context-menu .context-menu-item span {
    font-size: 13px;
    color: #2c3e50;
    font-weight: 500;
    flex: 1;
}

.graph-modal-2-context-menu .context-menu-has-submenu {
    position: relative;
}

.graph-modal-2-context-menu .submenu-arrow {
    width: 12px;
    height: 12px;
    margin-left: auto;
}

.graph-modal-2-context-menu .context-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background: #ffffff;
    border: 1px solid #dddfe0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    min-width: 140px;
    z-index: 10;
}

/* Ensure nested submenus are hidden by default */
.graph-modal-2-context-menu .context-submenu .context-submenu {
    display: none !important;
}

/* Show first level submenu */
.graph-modal-2-context-menu .context-menu-item.context-menu-has-submenu:hover>.context-submenu {
    display: block;
}

/* Show second level submenu ONLY on direct hover */
.graph-modal-2-context-menu .context-submenu-item.context-menu-has-submenu:hover>.context-submenu {
    display: block !important;
}

.graph-modal-2-context-menu .context-submenu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 13px;
    color: #2c3e50;
    white-space: nowrap;
}

.graph-modal-2-context-menu .context-submenu-item:hover {
    background: #f8f9fa;
}

/* Marker Table Panel */
.graph-modal-2-marker-table {
    position: fixed;
    background: white;
    border: 1px solid #dddfe0;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    max-width: 280px;
    z-index: 1000;
}

.marker-table-header {
    padding: 2px 10px;
    border-bottom: 1px solid #dddfe0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border-radius: 6px 6px 0 0;
    cursor: move;
    user-select: none;
}

.marker-table-title {
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
}

.marker-table-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.2s;
    color: #7f8c8d;
}

.marker-table-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2c3e50;
}

.marker-table-close-btn svg {
    width: 14px;
    height: 14px;
}

.marker-table-content {
    padding: 0px 10px;
    max-height: 300px;
    overflow-y: auto;
}

.marker-table-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.marker-table-content li {
    padding: 4px 0;
    font-size: 11px;
    color: #2c3e50;
    position: relative;
    line-height: 1.3;
}

.marker-table-content li::before {
    content: "•";
    color: #2d8998;
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

.marker-table-content li.marker-entry {
    font-weight: 700;
    color: #2d8998;
    margin-left: 10px;
}

.marker-table-content li.marker-entry::before {
    content: "○";
}

/* Nested marker list for multi-graph (future) */
.marker-table-content ul ul {
    margin-left: 1.5em;
}

.marker-table-content ul ul li {
    font-weight: 400;
    color: #34495e;
}

/* Empty state */
.marker-table-empty {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    font-size: 13px;
}

/* Scrollbar styling */
.marker-table-content::-webkit-scrollbar {
    width: 6px;
}

.marker-table-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.marker-table-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.marker-table-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Responsive */
@media (max-width: 1024px) {
    .graph-modal-2-container {
        max-width: 95vw;
        max-height: 90vh;
    }
}

@media (max-width: 768px) {
    .graph-modal-2-container {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .graph-modal-2-marker-table {
        min-width: 240px;
        max-width: calc(100vw - 40px);
    }
}

/* Overlay Selection Modal */
.overlay-selection-search {
    margin-bottom: 15px;
}

.overlay-selection-search input {
    width: 100%;
    padding: 10px;
    border: 1px solid #dddfe0;
    border-radius: 6px;
    font-size: 14px;
}

.overlay-assignment-list {
    border: 1px solid #dddfe0;
    border-radius: 6px;
    background: #fff;
}

.overlay-assignment-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.overlay-assignment-item:last-child {
    border-bottom: none;
}

.overlay-assignment-item:hover {
    background: #f8f9fa;
}

.overlay-assignment-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f1f1f1;
}

.overlay-assignment-info {
    display: flex;
    flex-direction: column;
}

.overlay-assignment-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.overlay-assignment-unit {
    font-size: 12px;
    color: #7f8c8d;
}

.overlay-assignment-status {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #4a5568;
}

.overlay-assignment-status.valid {
    background: #c6f6d5;
    color: #22543d;
}

.overlay-assignment-status.invalid {
    background: #fed7d7;
    color: #822727;
}

/* Graph Overlay Selection Modal - Specific styling */
#graphOverlaySelectionModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000 !important; /* Very high z-index to ensure visibility */
}

#graphOverlaySelectionModal .modal-container {
    background: white;
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#graphOverlaySelectionModal .modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#graphOverlaySelectionModal .modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #2d8998;
}

#graphOverlaySelectionModal .modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#graphOverlaySelectionModal .modal-close-btn:hover {
    color: #333;
}

#graphOverlaySelectionModal .modal-close-btn svg {
    width: 20px;
    height: 20px;
}

#graphOverlaySelectionModal .modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

#graphOverlaySelectionModal .modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ==================== DARK MODE ==================== */
@media (prefers-color-scheme: dark) {
    .graph-modal-2 {
        background: rgba(0, 0, 0, 0.6);
    }

    .graph-modal-2-container {
        background: #1f2937;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }

    .graph-modal-2-header {
        border-bottom-color: #374151;
        background: #111827;
    }

    .graph-modal-2-title {
        color: #2d8998;
    }

    .graph-modal-2-close-btn,
    .graph-modal-2-action-btn {
        background: rgba(255, 255, 255, 0.1);
        border-color: #4b5563;
        color: #e5e7eb;
    }

    .graph-modal-2-close-btn:hover,
    .graph-modal-2-action-btn:hover {
        background: #374151;
        border-color: #2d8998;
        color: #2d8998;
    }

    .graph-modal-2-canvas-container {
        background: #111315;
    }

    /* Context Menu Dark Mode */
    .graph-modal-2-context-menu {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .graph-modal-2-context-menu .context-menu-item:hover {
        background: #374151;
    }

    .graph-modal-2-context-menu .context-menu-item svg {
        stroke: #e5e7eb;
    }

    .graph-modal-2-context-menu .context-menu-item span {
        color: #e5e7eb;
    }

    .graph-modal-2-context-menu .context-submenu {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .graph-modal-2-context-menu .context-submenu-item {
        color: #e5e7eb;
    }

    .graph-modal-2-context-menu .context-submenu-item:hover {
        background: #374151;
    }

    /* Marker Table Dark Mode */
    .graph-modal-2-marker-table {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .marker-table-header {
        border-bottom-color: #374151;
        background: #111827;
    }

    .marker-table-title {
        color: #f3f4f6;
    }

    .marker-table-close-btn {
        color: #9ca3af;
    }

    .marker-table-close-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #f3f4f6;
    }

    .marker-table-content li {
        color: #e5e7eb;
    }

    .marker-table-content li::before {
        color: #2d8998;
    }

    .marker-table-content li.marker-entry {
        color: #2d8998;
    }

    .marker-table-content ul ul li {
        color: #cbd5e1;
    }

    .marker-table-empty {
        color: #9ca3af;
    }

    .marker-table-content::-webkit-scrollbar-track {
        background: #374151;
    }

    .marker-table-content::-webkit-scrollbar-thumb {
        background: #4b5563;
    }

    .marker-table-content::-webkit-scrollbar-thumb:hover {
        background: #6b7280;
    }

    /* Overlay Selection Dark Mode */
    .overlay-selection-search input {
        background: #111315;
        border-color: #374151;
        color: #e5e7eb;
    }

    .overlay-assignment-list {
        border-color: #374151;
        background: #1f2937;
    }

    .overlay-assignment-item {
        border-bottom-color: #374151;
    }

    .overlay-assignment-item:hover {
        background: #374151;
    }

    .overlay-assignment-item.disabled {
        background: #111827;
    }

    .overlay-assignment-name {
        color: #f3f4f6;
    }

    .overlay-assignment-unit {
        color: #9ca3af;
    }

    .overlay-assignment-status {
        background: #374151;
        color: #e5e7eb;
    }

    .overlay-assignment-status.valid {
        background: #065f46;
        color: #6ee7b7;
    }

    .overlay-assignment-status.invalid {
        background: #7f1d1d;
        color: #fca5a5;
    }

    /* Graph Overlay Selection Modal Dark Mode */
    #graphOverlaySelectionModal {
        background: rgba(0, 0, 0, 0.6);
    }

    #graphOverlaySelectionModal .modal-container {
        background: #1f2937;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    }

    #graphOverlaySelectionModal .modal-header {
        border-bottom-color: #374151;
    }

    #graphOverlaySelectionModal .modal-header h3 {
        color: #2d8998;
    }

    #graphOverlaySelectionModal .modal-close-btn {
        color: #9ca3af;
    }

    #graphOverlaySelectionModal .modal-close-btn:hover {
        color: #f3f4f6;
    }

    #graphOverlaySelectionModal .modal-body {
        background: #1f2937;
    }

    #graphOverlaySelectionModal .modal-footer {
        border-top-color: #374151;
        background: #111827;
    }

    /* Overlay Management Panel Dark Mode */
    .graph-modal-2-overlay-panel {
        background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
        border-left-color: #374151;
    }

    .overlay-panel-header {
        background: linear-gradient(135deg, #2d8998 0%, #1e6b77 100%);
    }

    .overlay-panel-close {
        background: rgba(255, 255, 255, 0.1);
    }

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

    .overlay-panel-content {
        background: transparent;
    }

    .overlay-section-label {
        color: #9ca3af;
    }

    .overlay-layer-item {
        background: #1f2937;
        border-color: #374151;
    }

    .overlay-layer-item:hover {
        border-color: #4b5563;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .overlay-layer-item.primary {
        background: linear-gradient(135deg, #1e3a3f 0%, #1a2f33 100%);
        border-color: #2d8998;
    }

    .overlay-layer-name {
        color: #f3f4f6;
    }

    .overlay-layer-axis {
        background: #374151;
        color: #9ca3af;
    }

    .overlay-layer-axis.left {
        background: #1e3a5f;
        color: #60a5fa;
    }

    .overlay-layer-axis.right {
        background: #4a1e1e;
        color: #f87171;
    }

    .overlay-layer-btn {
        background: #374151;
        border-color: #4b5563;
    }

    .overlay-layer-btn svg {
        stroke: #9ca3af;
    }

    .overlay-layer-btn:hover {
        background: #4b5563;
        border-color: #6b7280;
    }

    .overlay-layer-btn:hover svg {
        stroke: #e5e7eb;
    }

    .overlay-layer-btn.remove:hover {
        background: #7f1d1d;
        border-color: #dc2626;
    }

    .overlay-layer-btn.remove:hover svg {
        stroke: #fca5a5;
    }

    .overlay-layer-offset {
        border-top-color: #374151;
    }

    .overlay-offset-label {
        color: #9ca3af;
    }

    .overlay-offset-input {
        background: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }

    .overlay-offset-input:focus {
        background: #1f2937;
        border-color: #2d8998;
    }

    .overlay-offset-input::placeholder {
        color: #6b7280;
    }

    .overlay-panel-footer {
        background: #1f2937;
        border-top-color: #374151;
    }

    .overlay-btn-clear {
        background: #374151;
        color: #9ca3af;
        border-color: #4b5563;
    }

    .overlay-btn-clear:hover {
        background: #7f1d1d;
        color: #fca5a5;
        border-color: #dc2626;
    }

    .overlay-empty-state {
        color: #6b7280;
    }

    .overlay-empty-state svg {
        stroke: #4b5563;
    }

    .overlay-management-item {
        background: #1f2937;
        border-color: #374151;
    }

    .overlay-item-name {
        color: #f3f4f6;
    }

    .overlay-item-axis {
        color: #9ca3af;
    }

    .overlay-item-remove {
        background: #1f2937;
        border-color: #374151;
    }

    .overlay-item-remove:hover {
        background: #450a0a;
        border-color: #ef4444;
    }

    .graph-modal-2-action-btn.active {
        background: #2d8998;
        border-color: #2d8998;
        color: white;
    }
}